From c0cffca1e65d7db4d5a6fe0edbb30438dcc03727 Mon Sep 17 00:00:00 2001 From: Scott Albertson Date: Fri, 1 Nov 2013 13:27:48 -0700 Subject: [PATCH] Test title updating --- spec/controllers/users_controller_spec.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index f8539afd7c1..d5d2a24f0b6 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -875,7 +875,7 @@ describe UsersController do end end - context 'without permission to update' do + context 'without permission to update any attributes' do it 'does not allow the update' do user = Fabricate(:user, name: 'Billy Bob') log_in_user(user) @@ -889,6 +889,20 @@ describe UsersController do expect(user.reload.name).not_to eq 'Jim Tom' end end + + context 'without permission to update title' do + it 'does not allow the user to update their title' do + user = Fabricate(:user, title: 'Emperor') + log_in_user(user) + guardian = Guardian.new(user) + guardian.stubs(can_grant_title?: false).with(user) + Guardian.stubs(new: guardian).with(user) + + put :update, username: user.username, title: 'Minion' + + expect(user.reload.title).not_to eq 'Minion' + end + end end end