diff --git a/app/views/budgets/groups/show.html.erb b/app/views/budgets/groups/show.html.erb index 8f9f9ae86..0ae0a2a50 100644 --- a/app/views/budgets/groups/show.html.erb +++ b/app/views/budgets/groups/show.html.erb @@ -1,9 +1,9 @@
- <%# link_to participatory_budget_path, class: "back" do %> + <%= link_to budget_path(@budget), class: "back" do %> <%= t('shared.back') %> - <%# end %> + <% end %>

<%# t("spending_proposals.welcome.districts") %>

@@ -13,8 +13,9 @@ <% slice.each do |heading| %> - <%= link_to heading.name, budget_investments_path(heading_id: heading.id), - data: { no_turbolink: true } %>
+ <%= link_to heading.name, + budget_investments_path(heading_id: heading.id), + data: { no_turbolink: true } %>
<% end %>
diff --git a/app/views/budgets/investments/_header.html.erb b/app/views/budgets/investments/_header.html.erb index f0d487564..468d1b3c6 100644 --- a/app/views/budgets/investments/_header.html.erb +++ b/app/views/budgets/investments/_header.html.erb @@ -4,7 +4,7 @@
- <%= link_to @budget, class: "back" do %> + <%= link_to budget_group_path(@budget, @heading.group), class: "back" do %> <%= t("shared.back") %> <% end %> diff --git a/app/views/budgets/show.html.erb b/app/views/budgets/show.html.erb index 2e362bd6c..a874a28a8 100644 --- a/app/views/budgets/show.html.erb +++ b/app/views/budgets/show.html.erb @@ -22,11 +22,18 @@ <% @budget.groups.each do |group| %> - <%= link_to group.name, budget_group_path(@budget, group) %> + <% if group.headings.count == 1 %> + <%= link_to group.name, + budget_investments_path(@budget, heading_id: group.headings.first.id), + data: { no_turbolink: true } %> + <% else %> + <%= link_to group.name, budget_group_path(@budget, group) %> + <% end %> +
<% end %>
-
+
\ No newline at end of file diff --git a/spec/features/budgets/ballots_spec.rb b/spec/features/budgets/ballots_spec.rb index a8b2f8ae0..cd25ae7a5 100644 --- a/spec/features/budgets/ballots_spec.rb +++ b/spec/features/budgets/ballots_spec.rb @@ -151,12 +151,105 @@ feature 'Ballots' do end + context "Group and Heading Navigation" do + + scenario "Groups" do + city = create(:budget_group, budget: budget, name: "City") + districts = create(:budget_group, budget: budget, name: "Districts") + + visit budget_path(budget) + + expect(page).to have_link "City" + expect(page).to have_link "Districts" + end + + scenario "Headings" do + city = create(:budget_group, budget: budget, name: "City") + districts = create(:budget_group, budget: budget, name: "Districts") + + city_heading1 = create(:budget_heading, group: city, name: "Investments Type1") + city_heading2 = create(:budget_heading, group: city, name: "Investments Type2") + district_heading1 = create(:budget_heading, group: districts, name: "District 1") + district_heading2 = create(:budget_heading, group: districts, name: "District 2") + + visit budget_path(budget) + click_link "City" + + expect(page).to have_link "Investments Type1" + expect(page).to have_link "Investments Type2" + + click_link "Go back" + click_link "Districts" + + expect(page).to have_link "District 1" + expect(page).to have_link "District 2" + + end + + scenario "Investments" do + city = create(:budget_group, budget: budget, name: "City") + districts = create(:budget_group, budget: budget, name: "Districts") + + city_heading1 = create(:budget_heading, group: city, name: "Investments Type1") + city_heading2 = create(:budget_heading, group: city, name: "Investments Type2") + district_heading1 = create(:budget_heading, group: districts, name: "District 1") + district_heading2 = create(:budget_heading, group: districts, name: "District 2") + + city_investment1 = create(:budget_investment, :feasible, :finished, heading: city_heading1) + city_investment2 = create(:budget_investment, :feasible, :finished, heading: city_heading1) + district1_investment1 = create(:budget_investment, :feasible, :finished, heading: district_heading1) + district1_investment2 = create(:budget_investment, :feasible, :finished, heading: district_heading1) + district2_investment1 = create(:budget_investment, :feasible, :finished, heading: district_heading2) + + visit budget_path(budget) + click_link "City" + click_link "Investments Type1" + + expect(page).to have_css(".budget-investment", count: 2) + expect(page).to have_content city_investment1.title + expect(page).to have_content city_investment2.title + + click_link "Go back" + click_link "Go back" + + click_link "Districts" + click_link "District 1" + + expect(page).to have_css(".budget-investment", count: 2) + expect(page).to have_content district1_investment1.title + expect(page).to have_content district1_investment2.title + + click_link "Go back" + click_link "District 2" + + expect(page).to have_css(".budget-investment", count: 1) + expect(page).to have_content district2_investment1.title + end + + scenario "Redirect to first heading if there is only one", :focus do + city = create(:budget_group, budget: budget, name: "City") + districts = create(:budget_group, budget: budget, name: "Districts") + + city_heading = create(:budget_heading, group: city, name: "City") + district_heading1 = create(:budget_heading, group: districts, name: "District 1") + district_heading2 = create(:budget_heading, group: districts, name: "District 2") + + city_investment = create(:budget_investment, :feasible, :finished, heading: city_heading) + + visit budget_path(budget) + click_link "City" + + expect(page).to have_content city_investment.title + end + + end + #Break up or simplify with helpers context "Balloting in multiple headings" do scenario "Independent progress bar for headings", :js do - city = create(:budget_group, budget: budget) - districts = create(:budget_group, budget: budget) + city = create(:budget_group, budget: budget, name: "City") + districts = create(:budget_group, budget: budget, name: "Districts") city_heading = create(:budget_heading, group: city, name: "All city", price: 10000000) district_heading1 = create(:budget_heading, group: districts, name: "District 1", price: 1000000)