From 072faf928f15067e995698f66895a43caaa5ae2b Mon Sep 17 00:00:00 2001 From: kikito Date: Mon, 14 Mar 2016 16:58:57 +0100 Subject: [PATCH] adds specs for preserving filtering params when using the admin links for spending proposals changes the order in which specs are executed for travis another change for travis another change for travis --- .../admin/spending_proposals/edit.html.erb | 2 +- .../features/admin/spending_proposals_spec.rb | 70 +++++++++++++++++-- 2 files changed, 65 insertions(+), 7 deletions(-) diff --git a/app/views/admin/spending_proposals/edit.html.erb b/app/views/admin/spending_proposals/edit.html.erb index a0fd82a3d..67160b926 100644 --- a/app/views/admin/spending_proposals/edit.html.erb +++ b/app/views/admin/spending_proposals/edit.html.erb @@ -1,4 +1,4 @@ -<%= link_to admin_spending_proposals_path(@spending_proposal, SpendingProposal.filter_params(params)), class: 'back' do %> +<%= link_to admin_spending_proposal_path(@spending_proposal, SpendingProposal.filter_params(params)), class: 'back' do %> <%= t("admin.spending_proposals.show.back") %> <% end %> diff --git a/spec/features/admin/spending_proposals_spec.rb b/spec/features/admin/spending_proposals_spec.rb index 6530400c1..fcfec8638 100644 --- a/spec/features/admin/spending_proposals_spec.rb +++ b/spec/features/admin/spending_proposals_spec.rb @@ -66,11 +66,6 @@ feature 'Admin spending proposals' do expect(page).to have_link("Realocate visitors") expect(page).to have_link("Destroy the city") - select "District 9", from: "geozone_id" - - expect(page).to have_link("Realocate visitors") - expect(page).to_not have_link("Destroy the city") - select "All city", from: "geozone_id" expect(page).to have_link("Destroy the city") @@ -79,6 +74,28 @@ feature 'Admin spending proposals' do select "All zones", from: "geozone_id" expect(page).to have_link("Realocate visitors") expect(page).to have_link("Destroy the city") + + select "District 9", from: "geozone_id" + + expect(page).to_not have_link("Destroy the city") + expect(page).to have_link("Realocate visitors") + + click_link("Realocate visitors") + click_link("Back") + + expect(page).to_not have_link("Destroy the city") + expect(page).to have_link("Realocate visitors") + + click_link("Realocate visitors") + click_on("Edit classification") + expect(page).to have_button("Update") + click_on("Back") + expect(page).to_not have_button("Update") + click_on("Back") + + expect(page).to_not have_link("Destroy the city") + expect(page).to have_link("Realocate visitors") + end scenario "Filtering by admin", :js do @@ -94,13 +111,36 @@ feature 'Admin spending proposals' do select "Admin 1", from: "administrator_id" - expect(page).to have_link("Realocate visitors") + expect(page).to have_content('There is 1 spending proposal') expect(page).to_not have_link("Destroy the city") + expect(page).to have_link("Realocate visitors") select "All administrators", from: "administrator_id" + expect(page).to have_content('There are 2 spending proposals') expect(page).to have_link("Destroy the city") expect(page).to have_link("Realocate visitors") + + select "Admin 1", from: "administrator_id" + expect(page).to have_content('There is 1 spending proposal') + click_link("Realocate visitors") + click_link("Back") + + expect(page).to have_content('There is 1 spending proposal') + expect(page).to_not have_link("Destroy the city") + expect(page).to have_link("Realocate visitors") + + click_link("Realocate visitors") + click_on("Edit classification") + expect(page).to have_button("Update") + click_on("Back") + expect(page).to_not have_button("Update") + click_on("Back") + + expect(page).to have_content('There is 1 spending proposal') + expect(page).to_not have_link("Destroy the city") + expect(page).to have_link("Realocate visitors") + end scenario "Current filter is properly highlighted" do @@ -183,10 +223,28 @@ feature 'Admin spending proposals' do visit admin_spending_proposals_path(tag_name: 'Education') + expect(page).to_not have_content("More hospitals") expect(page).to have_css(".spending_proposal", count: 2) expect(page).to have_content("Educate the children") expect(page).to have_content("More schools") + + click_link("Educate the children") + click_link("Back") + expect(page).to_not have_content("More hospitals") + expect(page).to have_content("Educate the children") + expect(page).to have_content("More schools") + + click_link("Educate the children") + click_on("Edit classification") + expect(page).to have_button("Update") + click_on("Back") + expect(page).to_not have_button("Update") + click_on("Back") + + expect(page).to_not have_content("More hospitals") + expect(page).to have_content("Educate the children") + expect(page).to have_content("More schools") end end