Fix "go back" link in ballot page
Since the `@ballot_referer` variable was only set in the lines controller, it didn't work when we accessed the ballot page without adding a line. Note it still doesn't work if we access the ballot page directly by entering the URL in the browser's address bar.
This commit is contained in:
@@ -7,7 +7,6 @@ module Budgets
|
||||
before_action :load_tag_cloud
|
||||
before_action :load_categories
|
||||
before_action :load_investments
|
||||
before_action :load_ballot_referer
|
||||
|
||||
authorize_resource :budget
|
||||
authorize_resource :ballot
|
||||
@@ -67,10 +66,6 @@ module Budgets
|
||||
@categories = Tag.category.order(:name)
|
||||
end
|
||||
|
||||
def load_ballot_referer
|
||||
@ballot_referer = session[:ballot_referer]
|
||||
end
|
||||
|
||||
def load_map
|
||||
@investments ||= []
|
||||
@investments_map_coordinates = MapLocation.where(investment: @investments).map(&:json_data)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<div class="budget-header">
|
||||
<div class="row">
|
||||
<%= back_link_to @ballot_referer %>
|
||||
<%= back_link_to session[:ballot_referer] %>
|
||||
|
||||
<h1 class="text-center"><%= t("budgets.ballots.show.title") %></h1>
|
||||
|
||||
|
||||
@@ -422,28 +422,45 @@ describe "Ballots" do
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Back link after removing an investment from Ballot", :js do
|
||||
create(:budget_investment, :selected, heading: new_york, price: 10, title: "Sully monument")
|
||||
describe "Back link", :js do
|
||||
scenario "after adding and removing an investment from the ballot" do
|
||||
create(:budget_investment, :selected, heading: new_york, price: 10, title: "Sully monument")
|
||||
|
||||
login_as(user)
|
||||
visit budget_investments_path(budget, heading_id: new_york.id)
|
||||
add_to_ballot("Sully monument")
|
||||
login_as(user)
|
||||
visit budget_investments_path(budget, heading_id: new_york.id)
|
||||
add_to_ballot("Sully monument")
|
||||
|
||||
within(".budget-heading") do
|
||||
click_link "Check and confirm my ballot"
|
||||
within(".budget-heading") do
|
||||
click_link "Check and confirm my ballot"
|
||||
end
|
||||
|
||||
expect(page).to have_content("You have voted one investment")
|
||||
|
||||
within(".ballot-list li", text: "Sully monument") do
|
||||
find(".icon-x").click
|
||||
end
|
||||
|
||||
expect(page).to have_content("You have voted 0 investments")
|
||||
|
||||
click_link "Go back"
|
||||
|
||||
expect(page).to have_current_path(budget_investments_path(budget, heading_id: new_york.id))
|
||||
end
|
||||
|
||||
expect(page).to have_content("You have voted one investment")
|
||||
scenario "before adding any investments" do
|
||||
login_as(user)
|
||||
visit budget_investments_path(budget, heading_id: new_york.id)
|
||||
|
||||
within(".ballot-list li", text: "Sully monument") do
|
||||
find(".icon-x").click
|
||||
within(".budget-heading") do
|
||||
click_link "Check and confirm my ballot"
|
||||
end
|
||||
|
||||
expect(page).to have_content("You have voted 0 investments")
|
||||
|
||||
click_link "Go back"
|
||||
|
||||
expect(page).to have_current_path(budget_investments_path(budget, heading_id: new_york.id))
|
||||
end
|
||||
|
||||
expect(page).to have_content("You have voted 0 investments")
|
||||
|
||||
click_link "Go back"
|
||||
|
||||
expect(page).to have_current_path(budget_investments_path(budget, heading_id: new_york.id))
|
||||
end
|
||||
|
||||
context "Permissions" do
|
||||
|
||||
Reference in New Issue
Block a user