From 11a8086599e449a8055136dd9b4234a14df9aca6 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Sat, 14 Jan 2017 16:12:45 +0100 Subject: [PATCH] adds specs --- spec/features/emails_spec.rb | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/spec/features/emails_spec.rb b/spec/features/emails_spec.rb index fe6c18774..9dba7aa0d 100644 --- a/spec/features/emails_spec.rb +++ b/spec/features/emails_spec.rb @@ -261,4 +261,39 @@ feature 'Emails' do end + context "Budgets" do + + let(:author) { create(:user, :level_two) } + let(:budget) { create(:budget) } + let(:group) { create(:budget_group, name: "Health", budget: budget) } + let!(:heading) { create(:budget_heading, name: "More hospitals", group: group) } + + scenario "Investment created" do + Setting["feature.budgets"] = true + + login_as(author) + visit new_budget_investment_path(budget_id: budget.id) + + select 'Health: More hospitals', from: 'budget_investment_heading_id' + fill_in 'budget_investment_title', with: 'Build a hospital' + fill_in 'budget_investment_description', with: 'We have lots of people that require medical attention' + fill_in 'budget_investment_external_url', with: 'http://http://hospitalsforallthepeople.com/' + check 'budget_investment_terms_of_service' + + click_button 'Create Investment' + expect(page).to have_content 'Investment created successfully' + + email = open_last_email + investment = Budget::Investment.last + + expect(email).to have_subject("Thank you for creating a proposal!") + expect(email).to deliver_to(investment.author.email) + expect(email).to have_body_text(author.name) + expect(email).to have_body_text(investment.title) + expect(email).to have_body_text(investment.budget.name) + expect(email).to have_body_text(budget_path(budget)) + end + + end + end