adds email delivery of selected and unselected investments

This commit is contained in:
rgarcia
2017-05-12 13:57:31 +02:00
parent 6217dbae63
commit 712e576e75
8 changed files with 116 additions and 24 deletions

View File

@@ -321,5 +321,51 @@ feature 'Emails' do
expect(email).to have_body_text(investment.unfeasibility_explanation)
end
scenario "Selected investment" do
author1 = create(:user)
author2 = create(:user)
author3 = create(:user)
investment1 = create(:budget_investment, :selected, author: author1, budget: budget)
investment2 = create(:budget_investment, :selected, author: author2, budget: budget)
investment3 = create(:budget_investment, :unselected, author: author3, budget: budget)
reset_mailer
budget.email_selected
expect(find_email investment1.author.email).to be
expect(find_email investment2.author.email).to be
expect(find_email investment3.author.email).to_not be
email = open_last_email
investment = investment2
expect(email).to have_subject("Your investment project '#{investment.code}' has been selected")
expect(email).to deliver_to(investment.author.email)
expect(email).to have_body_text(investment.title)
end
scenario "Unselected investment" do
author1 = create(:user)
author2 = create(:user)
author3 = create(:user)
investment1 = create(:budget_investment, :unselected, author: author1, budget: budget)
investment2 = create(:budget_investment, :unselected, author: author2, budget: budget)
investment3 = create(:budget_investment, :selected, author: author3, budget: budget)
reset_mailer
budget.email_unselected
expect(find_email investment1.author.email).to be
expect(find_email investment2.author.email).to be
expect(find_email investment3.author.email).to_not be
email = open_last_email
investment = investment2
expect(email).to have_subject("Your investment project '#{investment.code}' has not been selected")
expect(email).to deliver_to(investment.author.email)
expect(email).to have_body_text(investment.title)
end
end
end