diff options
author | Claire <claire.github-309c@sitedethib.com> | 2023-02-13 19:35:35 +0100 |
---|---|---|
committer | Claire <claire.github-309c@sitedethib.com> | 2023-02-13 19:35:35 +0100 |
commit | ce84d163ccaa1f38f9fe5dc829a5da80495632c2 (patch) | |
tree | 1242ecad08be2afc048d652dedf07115adbd115b /spec/serializers/rest | |
parent | ee4250545236e4330c46b43f4abfe94ad323d4d4 (diff) | |
parent | d6930b3847405dc9f8c1a54fb74d488a3c9a775e (diff) |
Merge branch 'main' into glitch-soc/merge-upstream
Conflicts: - `.prettierignore`: Upstream added a line at the end, glitch-soc had extra entries at the end. Added upstream's new line before glitch-soc's. - `Gemfile.lock`: Upstream updated dependencies while glitch-soc has an extra one (hcaptcha). Updated dependencies like upstream did. - `app/controllers/api/v1/statuses_controller.rb`: Not a real conflict, upstream added a parameter (`allowed_mentions`) where glitch-soc already had an extra one (`content_type`). Added upstream's new parameter. - `app/javascript/styles/fonts/roboto-mono.scss`: A lot of lines were changed upstream due to code style changes, and a lot of those lines had path changes to accomodate glitch-soc's theming system. Applied upstream's style changes. - `app/javascript/styles/fonts/roboto.scss`: A lot of lines were changed upstream due to code style changes, and a lot of those lines had path changes to accomodate glitch-soc's theming system. Applied upstream's style changes.
Diffstat (limited to 'spec/serializers/rest')
-rw-r--r-- | spec/serializers/rest/account_serializer_spec.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/serializers/rest/account_serializer_spec.rb b/spec/serializers/rest/account_serializer_spec.rb new file mode 100644 index 000000000..ce29df3a7 --- /dev/null +++ b/spec/serializers/rest/account_serializer_spec.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe REST::AccountSerializer do + let(:role) { Fabricate(:user_role, name: 'Role', highlighted: true) } + let(:user) { Fabricate(:user, role: role) } + let(:account) { user.account} + + subject { JSON.parse(ActiveModelSerializers::SerializableResource.new(account, serializer: REST::AccountSerializer).to_json) } + + context 'when the account is suspended' do + before do + account.suspend! + end + + it 'returns empty roles' do + expect(subject['roles']).to eq [] + end + end + + context 'when the account has a highlighted role' do + let(:role) { Fabricate(:user_role, name: 'Role', highlighted: true) } + + it 'returns the expected role' do + expect(subject['roles'].first).to include({ 'name' => 'Role' }) + end + end + + context 'when the account has a non-highlighted role' do + let(:role) { Fabricate(:user_role, name: 'Role', highlighted: false) } + + it 'returns empty roles' do + expect(subject['roles']).to eq [] + end + end +end |