adds time limit between notifications
This commit is contained in:
@@ -22,4 +22,38 @@ describe ProposalNotification do
|
||||
expect(notification).to_not be_valid
|
||||
end
|
||||
|
||||
describe "minimum interval between notifications" do
|
||||
|
||||
before(:each) do
|
||||
Setting[:proposal_notification_minimum_interval_in_days] = 3
|
||||
end
|
||||
|
||||
it "should not be valid if below minium interval" do
|
||||
proposal = create(:proposal)
|
||||
|
||||
notification1 = create(:proposal_notification, proposal: proposal)
|
||||
notification2 = build(:proposal_notification, proposal: proposal)
|
||||
|
||||
proposal.reload
|
||||
expect(notification2).to_not be_valid
|
||||
end
|
||||
|
||||
it "should be valid if notifications above minium interval" do
|
||||
proposal = create(:proposal)
|
||||
|
||||
notification1 = create(:proposal_notification, proposal: proposal, created_at: 4.days.ago)
|
||||
notification2 = build(:proposal_notification, proposal: proposal)
|
||||
|
||||
proposal.reload
|
||||
expect(notification2).to be_valid
|
||||
end
|
||||
|
||||
it "should be valid if no notifications sent" do
|
||||
notification1 = build(:proposal_notification)
|
||||
|
||||
expect(notification1).to be_valid
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user