2015-10-11 05:41:23 -04:00
|
|
|
require 'rails_helper'
|
2014-04-03 14:34:21 -04:00
|
|
|
|
|
|
|
describe Jobs::PendingFlagsReminder do
|
|
|
|
context "notify_about_flags_after is 0" do
|
|
|
|
before { SiteSetting.stubs(:notify_about_flags_after).returns(0) }
|
|
|
|
|
|
|
|
it "never emails" do
|
|
|
|
PostAction.stubs(:flagged_posts_count).returns(1)
|
|
|
|
Email::Sender.any_instance.expects(:send).never
|
|
|
|
described_class.new.execute({})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "notify_about_flags_after is 48" do
|
|
|
|
before { SiteSetting.stubs(:notify_about_flags_after).returns(48) }
|
|
|
|
|
2016-02-19 15:21:05 -05:00
|
|
|
it "doesn't send message when flags are less than 48 hours old" do
|
2014-04-03 14:34:21 -04:00
|
|
|
Fabricate(:flag, created_at: 47.hours.ago)
|
|
|
|
PostAction.stubs(:flagged_posts_count).returns(1)
|
2016-02-19 15:21:05 -05:00
|
|
|
PostCreator.expects(:create).never
|
2014-04-03 14:34:21 -04:00
|
|
|
described_class.new.execute({})
|
|
|
|
end
|
|
|
|
|
2016-02-19 15:21:05 -05:00
|
|
|
it "sends message when there is a flag older than 48 hours" do
|
2014-04-03 14:34:21 -04:00
|
|
|
Fabricate(:flag, created_at: 49.hours.ago)
|
|
|
|
PostAction.stubs(:flagged_posts_count).returns(1)
|
2016-02-19 15:21:05 -05:00
|
|
|
PostCreator.expects(:create).once.returns(true)
|
2014-04-03 14:34:21 -04:00
|
|
|
described_class.new.execute({})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|