FIX: Don't raise an error when trying to log nothing

This commit is contained in:
Robin Ward 2014-12-15 14:14:12 -05:00
parent 748c13f4a7
commit b2e2a99898
2 changed files with 16 additions and 0 deletions

View file

@ -144,6 +144,8 @@ class StaffActionLogger
end end
def log_show_emails(users) def log_show_emails(users)
return if users.blank?
values = [] values = []
users.each do |user| users.each do |user|

View file

@ -33,6 +33,20 @@ describe StaffActionLogger do
end end
end end
describe "log_show_emails" do
it "logs the user history" do
-> { logger.log_show_emails([admin]) }.should change(UserHistory, :count).by(1)
end
it "doesn't raise an exception with nothing to log" do
-> { logger.log_show_emails([]) }.should_not raise_error
end
it "doesn't raise an exception with nil input" do
-> { logger.log_show_emails(nil) }.should_not raise_error
end
end
describe 'log_post_deletion' do describe 'log_post_deletion' do
let(:deleted_post) { Fabricate(:post) } let(:deleted_post) { Fabricate(:post) }