Skip to content

Commit

Permalink
Updated tests for is_administrator
Browse files Browse the repository at this point in the history
  • Loading branch information
edwoodward committed Jan 25, 2021
1 parent 20bfbee commit 2aa8722
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions spec/representers/api/v1/user_representer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,19 @@
end
end

context 'is_administrator' do
it 'can be read' do
expect(representer.to_hash['is_administrator']).to eq user.is_administrator
end

it 'cannot be written (attempts are silently ignored)' do
hash = { 'is_administrator' => true }

expect(user).not_to receive(:is_administrator=)
expect { representer.from_hash(hash) }.not_to change { user.reload.is_administrator }
end
end

context 'grant_tutor_access' do
it 'can be read' do
expect(representer.to_hash['grant_tutor_access']).to eq user.grant_tutor_access
Expand Down
1 change: 1 addition & 0 deletions spec/support/user_hash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def user_matcher(user, include_private_data: false)
uuid: user.uuid,
support_identifier: user.support_identifier,
is_test: user.is_test?,
is_administrator: user.is_administrator?,
salesforce_contact_id: user.salesforce_contact_id,
applications: a_collection_containing_exactly(
*user.applications.map { |app| { id: app.id, name: app.name } }
Expand Down

0 comments on commit 2aa8722

Please sign in to comment.