more specs for staff action logging
This commit is contained in:
parent
6c3426d266
commit
b177827841
|
@ -369,4 +369,42 @@ describe StaffActionLogger do
|
||||||
expect(user_history.action).to eq(UserHistory.actions[:create_category])
|
expect(user_history.action).to eq(UserHistory.actions[:create_category])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'log_lock_trust_level' do
|
||||||
|
let(:user) { Fabricate(:user) }
|
||||||
|
|
||||||
|
it "raises an error when argument is missing" do
|
||||||
|
expect { logger.log_lock_trust_level(nil) }.to raise_error(Discourse::InvalidParameters)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "creates a new UserHistory record" do
|
||||||
|
user.trust_level_locked = true
|
||||||
|
expect { logger.log_lock_trust_level(user) }.to change { UserHistory.count }.by(1)
|
||||||
|
user_history = UserHistory.last
|
||||||
|
expect(user_history.action).to eq(UserHistory.actions[:lock_trust_level])
|
||||||
|
|
||||||
|
user.trust_level_locked = false
|
||||||
|
expect { logger.log_lock_trust_level(user) }.to change { UserHistory.count }.by(1)
|
||||||
|
user_history = UserHistory.last
|
||||||
|
expect(user_history.action).to eq(UserHistory.actions[:unlock_trust_level])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'log_user_activate' do
|
||||||
|
let(:user) { Fabricate(:user) }
|
||||||
|
|
||||||
|
it "raises an error when argument is missing" do
|
||||||
|
expect { logger.log_user_activate(nil, nil) }.to raise_error(Discourse::InvalidParameters)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "creates a new UserHistory record" do
|
||||||
|
reason = "Staff activated from admin"
|
||||||
|
expect {
|
||||||
|
logger.log_user_activate(user, reason)
|
||||||
|
}.to change { UserHistory.count }.by(1)
|
||||||
|
user_history = UserHistory.last
|
||||||
|
expect(user_history.action).to eq(UserHistory.actions[:activate_user])
|
||||||
|
expect(user_history.details).to eq(reason)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -58,6 +58,14 @@ describe UserBlocker do
|
||||||
SystemMessage.expects(:create).never
|
SystemMessage.expects(:create).never
|
||||||
expect(block_user).to eq(false)
|
expect(block_user).to eq(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "logs it with context" do
|
||||||
|
SystemMessage.stubs(:create).returns(Fabricate.build(:post))
|
||||||
|
expect {
|
||||||
|
UserBlocker.block(user, Fabricate(:admin))
|
||||||
|
}.to change { UserHistory.count }.by(1)
|
||||||
|
expect(UserHistory.last.context).to be_present
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'unblock' do
|
describe 'unblock' do
|
||||||
|
@ -81,6 +89,12 @@ describe UserBlocker do
|
||||||
SystemMessage.expects(:create).never
|
SystemMessage.expects(:create).never
|
||||||
unblock_user
|
unblock_user
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "logs it" do
|
||||||
|
expect {
|
||||||
|
unblock_user
|
||||||
|
}.to change { UserHistory.count }.by(1)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'hide_posts' do
|
describe 'hide_posts' do
|
||||||
|
|
Loading…
Reference in New Issue