From 2331cd048edcbc9c2f28eec343d194d817bd1fd4 Mon Sep 17 00:00:00 2001 From: Julian Herrero Date: Mon, 3 Dec 2018 16:11:37 +0100 Subject: [PATCH 1/2] Add pending specs for proposal notifications limits --- spec/features/proposal_notifications_spec.rb | 49 +++++++++++++++++++- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/spec/features/proposal_notifications_spec.rb b/spec/features/proposal_notifications_spec.rb index f374a42c8..a4852b414 100644 --- a/spec/features/proposal_notifications_spec.rb +++ b/spec/features/proposal_notifications_spec.rb @@ -422,8 +422,53 @@ feature 'Proposal Notifications' do context "Limits" do - pending "Cannot send more than one notification within established interval" - pending "use timecop to make sure notifications can be sent after time interval" + scenario "Cannot send more than one notification within established interval" do + author = create(:user) + proposal = create(:proposal, author: author) + + login_as author.reload + + visit new_proposal_notification_path(proposal_id: proposal.id) + fill_in "Title", with: "Thank you for supporting my proposal" + fill_in "Message", with: "Please share it with others so we can make it happen!" + click_button "Send message" + + expect(page).to have_content "Your message has been sent correctly." + + visit new_proposal_notification_path(proposal_id: proposal.id) + fill_in "Title", with: "Thank you again for supporting my proposal" + fill_in "Message", with: "Please share it again with others so we can make it happen!" + click_button "Send message" + + expect(page).to have_content "You have to wait a minium of 3 days between notifications" + expect(page).not_to have_content "Your message has been sent correctly." + end + + scenario "Use time traveling to make sure notifications can be sent after time interval" do + author = create(:user) + proposal = create(:proposal, author: author) + + login_as author.reload + + visit new_proposal_notification_path(proposal_id: proposal.id) + fill_in "Title", with: "Thank you for supporting my proposal" + fill_in "Message", with: "Please share it with others so we can make it happen!" + click_button "Send message" + + expect(page).to have_content "Your message has been sent correctly." + + travel 3.days + 1.second + + visit new_proposal_notification_path(proposal_id: proposal.id) + fill_in "Title", with: "Thank you again for supporting my proposal" + fill_in "Message", with: "Please share it again with others so we can make it happen!" + click_button "Send message" + + expect(page).to have_content "Your message has been sent correctly." + expect(page).not_to have_content "You have to wait a minium of 3 days between notifications" + + travel_back + end end From ab1e9a931010c0dc3d261d8349bbf87bcbcaab6c Mon Sep 17 00:00:00 2001 From: Julian Herrero Date: Thu, 10 Jan 2019 13:48:42 +0100 Subject: [PATCH 2/2] Fix typo --- config/locales/en/activerecord.yml | 2 +- spec/features/proposal_notifications_spec.rb | 4 ++-- spec/models/proposal_notification_spec.rb | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/config/locales/en/activerecord.yml b/config/locales/en/activerecord.yml index f08b7c788..aab700334 100644 --- a/config/locales/en/activerecord.yml +++ b/config/locales/en/activerecord.yml @@ -355,7 +355,7 @@ en: proposal_notification: attributes: minimum_interval: - invalid: "You have to wait a minium of %{interval} days between notifications" + invalid: "You have to wait a minimum of %{interval} days between notifications" signature: attributes: document_number: diff --git a/spec/features/proposal_notifications_spec.rb b/spec/features/proposal_notifications_spec.rb index a4852b414..b3a61eaff 100644 --- a/spec/features/proposal_notifications_spec.rb +++ b/spec/features/proposal_notifications_spec.rb @@ -440,7 +440,7 @@ feature 'Proposal Notifications' do fill_in "Message", with: "Please share it again with others so we can make it happen!" click_button "Send message" - expect(page).to have_content "You have to wait a minium of 3 days between notifications" + expect(page).to have_content "You have to wait a minimum of 3 days between notifications" expect(page).not_to have_content "Your message has been sent correctly." end @@ -465,7 +465,7 @@ feature 'Proposal Notifications' do click_button "Send message" expect(page).to have_content "Your message has been sent correctly." - expect(page).not_to have_content "You have to wait a minium of 3 days between notifications" + expect(page).not_to have_content "You have to wait a minimum of 3 days between notifications" travel_back end diff --git a/spec/models/proposal_notification_spec.rb b/spec/models/proposal_notification_spec.rb index d7ba529c4..0548c03d2 100644 --- a/spec/models/proposal_notification_spec.rb +++ b/spec/models/proposal_notification_spec.rb @@ -50,7 +50,7 @@ describe ProposalNotification do Setting[:proposal_notification_minimum_interval_in_days] = 3 end - it "is not valid if below minium interval" do + it "is not valid if below minimum interval" do proposal = create(:proposal) notification1 = create(:proposal_notification, proposal: proposal) @@ -60,7 +60,7 @@ describe ProposalNotification do expect(notification2).not_to be_valid end - it "is valid if notifications above minium interval" do + it "is valid if notifications above minimum interval" do proposal = create(:proposal) notification1 = create(:proposal_notification, proposal: proposal, created_at: 4.days.ago)