mirror of
https://github.com/discourse/discourse.git
synced 2025-02-07 20:08:26 +00:00
FIX: Response is no longer forbidden with JSON errors for changing trust
level.
This commit is contained in:
parent
6844edc564
commit
2096861d79
@ -171,12 +171,12 @@ describe Admin::UsersController do
|
|||||||
it "raises an error when the user doesn't have permission" do
|
it "raises an error when the user doesn't have permission" do
|
||||||
Guardian.any_instance.expects(:can_change_trust_level?).with(@another_user).returns(false)
|
Guardian.any_instance.expects(:can_change_trust_level?).with(@another_user).returns(false)
|
||||||
xhr :put, :trust_level, user_id: @another_user.id
|
xhr :put, :trust_level, user_id: @another_user.id
|
||||||
response.should be_forbidden
|
response.should_not be_success
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns a 404 if the username doesn't exist" do
|
it "returns a 404 if the username doesn't exist" do
|
||||||
xhr :put, :trust_level, user_id: 123123
|
xhr :put, :trust_level, user_id: 123123
|
||||||
response.should be_forbidden
|
response.should_not be_success
|
||||||
end
|
end
|
||||||
|
|
||||||
it "upgrades the user's trust level" do
|
it "upgrades the user's trust level" do
|
||||||
@ -184,6 +184,7 @@ describe Admin::UsersController do
|
|||||||
xhr :put, :trust_level, user_id: @another_user.id, level: 2
|
xhr :put, :trust_level, user_id: @another_user.id, level: 2
|
||||||
@another_user.reload
|
@another_user.reload
|
||||||
@another_user.trust_level.should == 2
|
@another_user.trust_level.should == 2
|
||||||
|
response.should be_success
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises an error when demoting a user below their current trust level" do
|
it "raises an error when demoting a user below their current trust level" do
|
||||||
@ -195,7 +196,7 @@ describe Admin::UsersController do
|
|||||||
stat.save!
|
stat.save!
|
||||||
@another_user.update_attributes(trust_level: TrustLevel.levels[:basic])
|
@another_user.update_attributes(trust_level: TrustLevel.levels[:basic])
|
||||||
xhr :put, :trust_level, user_id: @another_user.id, level: TrustLevel.levels[:newuser]
|
xhr :put, :trust_level, user_id: @another_user.id, level: TrustLevel.levels[:newuser]
|
||||||
response.should be_forbidden
|
response.should_not be_success
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user