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
def log_show_emails(users)
return if users.blank?
values = []
users.each do |user|

View File

@ -33,6 +33,20 @@ describe StaffActionLogger do
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
let(:deleted_post) { Fabricate(:post) }