From 48fafc7389645479d8566c234d3f44bd15a5961b Mon Sep 17 00:00:00 2001 From: Emelia Smith Date: Sat, 27 Jul 2024 17:31:14 +0200 Subject: [PATCH] Fix specs --- .../rest/account_serializer_spec.rb | 8 +++---- .../credential_account_serializer_spec.rb | 21 +++++++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 spec/serializers/rest/credential_account_serializer_spec.rb diff --git a/spec/serializers/rest/account_serializer_spec.rb b/spec/serializers/rest/account_serializer_spec.rb index a57b3105d95..1b9937561e3 100644 --- a/spec/serializers/rest/account_serializer_spec.rb +++ b/spec/serializers/rest/account_serializer_spec.rb @@ -5,7 +5,7 @@ require 'rails_helper' describe REST::AccountSerializer do subject { serialized_record_json(account, described_class) } - let(:role) { Fabricate(:user_role, name: 'Role', highlighted: true) } + let(:role) { Fabricate(:user_role, name: 'Fancy User', highlighted: true) } let(:user) { Fabricate(:user, role: role) } let(:account) { user.account } @@ -20,10 +20,10 @@ describe REST::AccountSerializer do end context 'when the account has a highlighted role' do - let(:role) { Fabricate(:user_role, name: 'Role', highlighted: true) } + let(:role) { Fabricate(:user_role, name: 'Fancy User', highlighted: true) } it 'returns the expected role' do - expect(subject['roles'].first).to include({ 'name' => 'Role' }) + expect(subject['roles'].first).to include({ 'name' => 'Fancy User' }) end it 'does not expose the roles permissions' do @@ -32,7 +32,7 @@ describe REST::AccountSerializer do end context 'when the account has a non-highlighted role' do - let(:role) { Fabricate(:user_role, name: 'Role', highlighted: false) } + let(:role) { Fabricate(:user_role, name: 'Fancy User', highlighted: false) } it 'returns empty roles' do expect(subject['roles']).to eq [] diff --git a/spec/serializers/rest/credential_account_serializer_spec.rb b/spec/serializers/rest/credential_account_serializer_spec.rb new file mode 100644 index 00000000000..5ccef6a4121 --- /dev/null +++ b/spec/serializers/rest/credential_account_serializer_spec.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe REST::CredentialAccountSerializer do + subject { serialized_record_json(account, described_class) } + + let(:role) { Fabricate(:user_role, name: 'Fancy User') } + let(:user) { Fabricate(:user, role: role) } + let(:account) { user.account } + + context 'when the account has a role' do + it 'returns the expected role' do + expect(subject['roles'].first).to include({ 'name' => 'Fancy User' }) + end + + it 'exposes the role permissions' do + expect(subject['roles'].first).to include({ 'permissions' => role.computed_permissions.to_s }) + end + end +end