diff --git a/lib/guardian.rb b/lib/guardian.rb index 7c55d4917be..33a239ccae6 100644 --- a/lib/guardian.rb +++ b/lib/guardian.rb @@ -139,7 +139,7 @@ class Guardian end def can_change_trust_level?(user) - can_administer?(user) + user && is_staff? end def can_block_user?(user) diff --git a/spec/components/guardian_spec.rb b/spec/components/guardian_spec.rb index 947639752e4..1758f014127 100644 --- a/spec/components/guardian_spec.rb +++ b/spec/components/guardian_spec.rb @@ -1041,5 +1041,25 @@ describe Guardian do end end + + describe 'can_change_trust_level?' do + + it 'is false without a logged in user' do + Guardian.new(nil).can_change_trust_level?(user).should be_false + end + + it 'is false for regular users' do + Guardian.new(user).can_change_trust_level?(user).should be_false + end + + it 'is true for moderators' do + Guardian.new(moderator).can_change_trust_level?(user).should be_true + end + + it 'is true for admins' do + Guardian.new(admin).can_change_trust_level?(user).should be_true + end + end + end