When banning a user, a reason can be provided. The user will see this reason when trying to log in. Also log bans and unbans in the staff action logs.

This commit is contained in:
Neil Lalonde
2013-11-01 10:47:03 -04:00
parent 52b0c1c45f
commit 92a0729937
17 changed files with 180 additions and 26 deletions

View File

@@ -115,4 +115,39 @@ describe StaffActionLogger do
json['header'].should == site_customization.header
end
end
describe "log_user_ban" do
let(:user) { Fabricate(:user) }
it "raises an error when arguments are missing" do
expect { logger.log_user_ban(nil, nil) }.to raise_error(Discourse::InvalidParameters)
expect { logger.log_user_ban(nil, "He was bad.") }.to raise_error(Discourse::InvalidParameters)
end
it "reason arg is optional" do
expect { logger.log_user_ban(user, nil) }.to_not raise_error
end
it "creates a new UserHistory record" do
reason = "He was a big meanie."
log_record = logger.log_user_ban(user, reason)
log_record.should be_valid
log_record.details.should == reason
log_record.target_user.should == user
end
end
describe "log_user_unban" do
let(:user) { Fabricate(:user, banned_at: 1.day.ago, banned_till: 7.days.from_now) }
it "raises an error when argument is missing" do
expect { logger.log_user_unban(nil) }.to raise_error(Discourse::InvalidParameters)
end
it "creates a new UserHistory record" do
log_record = logger.log_user_unban(user)
log_record.should be_valid
log_record.target_user.should == user
end
end
end