Skip to content

Commit

Permalink
Added tests for alert
Browse files Browse the repository at this point in the history
  • Loading branch information
MariaCheca committed Jan 17, 2018
1 parent 7172768 commit 5804e80
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
44 changes: 44 additions & 0 deletions spec/features/admin/budget_investments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,50 @@
expect(page).not_to have_content "Refugees, Solidarity"
end

scenario "Shows alert when 'Valuation finished' is checked", :js do
budget_investment = create(:budget_investment)

visit admin_budget_budget_investment_path(budget_investment.budget, budget_investment)
click_link 'Edit dossier'

expect(page).to have_content 'Valuation finished'

find_field('budget_investment[valuation_finished]').click

page.accept_confirm("Are you sure you want to mark this report as completed? If you do it, it can no longer be modified.")

expect(page).to have_field('budget_investment[valuation_finished]', checked: true)
end

scenario "Shows alert with unfeasible status when 'Valuation finished' is checked", :js do
budget_investment = create(:budget_investment)

visit admin_budget_budget_investment_path(budget_investment.budget, budget_investment)
click_link 'Edit dossier'

expect(page).to have_content 'Valuation finished'

find_field('budget_investment_feasibility_unfeasible').click
find_field('budget_investment[valuation_finished]').click

page.accept_confirm("Are you sure you want to mark this report as completed? If you do it, it can no longer be modified.\nAn email will be sent immediately to the author of the project with the report of unfeasibility.")

expect(page).to have_field('budget_investment[valuation_finished]', checked: true)
end

scenario "Undoes check in 'Valuation finished' if user clicks 'cancel' on alert", :js do
budget_investment = create(:budget_investment)

visit admin_budget_budget_investment_path(budget_investment.budget, budget_investment)
click_link 'Edit dossier'

dismiss_confirm do
find_field('budget_investment[valuation_finished]').click
end

expect(page).to have_field('budget_investment[valuation_finished]', checked: false)
end

scenario "Errors on update" do
budget_investment = create(:budget_investment)

Expand Down
2 changes: 1 addition & 1 deletion spec/features/emails_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@

choose 'budget_investment_feasibility_unfeasible'
fill_in 'budget_investment_unfeasibility_explanation', with: 'This is not legal as stated in Article 34.9'
check 'budget_investment_valuation_finished'
find_field('budget_investment[valuation_finished]').click
click_button 'Save changes'

expect(page).to have_content "Dossier updated"
Expand Down
2 changes: 1 addition & 1 deletion spec/features/valuation/budget_investments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@
visit valuation_budget_budget_investment_path(@budget, @investment)
click_link 'Edit dossier'

check 'budget_investment_valuation_finished'
find_field('budget_investment[valuation_finished]').click
click_button 'Save changes'

visit valuation_budget_budget_investments_path(@budget)
Expand Down

0 comments on commit 5804e80

Please sign in to comment.