From 11a793d63f201e8ab7a1c81794e3815928a8db28 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Mon, 10 Jul 2017 19:41:04 +0200 Subject: [PATCH] Hide incompatible and non-winner investments by default --- .../budgets/results/_results_table.html.erb | 8 +++-- app/views/budgets/results/show.html.erb | 2 +- spec/features/budgets/results_spec.rb | 30 +++++++++---------- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/app/views/budgets/results/_results_table.html.erb b/app/views/budgets/results/_results_table.html.erb index 993060562..f391e8d50 100644 --- a/app/views/budgets/results/_results_table.html.erb +++ b/app/views/budgets/results/_results_table.html.erb @@ -1,4 +1,6 @@ -
+

<%= title %> @@ -28,7 +30,9 @@ <% amount_available = heading_price %> <% investments.each do |investment| %> - + <% if investment.winner? %> diff --git a/app/views/budgets/results/show.html.erb b/app/views/budgets/results/show.html.erb index 278ae012b..eb31124ec 100644 --- a/app/views/budgets/results/show.html.erb +++ b/app/views/budgets/results/show.html.erb @@ -35,7 +35,7 @@

- <%= link_to t("budgets.results.hide_discarded_link"), "#", class: "js-toggle-link button hollow margin-bottom", data: {'toggle-selector' => '.js-discarded', 'toggle-text' => t("budgets.results.show_all_link")} %> + <%= link_to t("budgets.results.show_all_link"), "#", class: "js-toggle-link button hollow margin-bottom", data: {'toggle-selector' => '.js-discarded', 'toggle-text' => t("budgets.results.hide_discarded_link")} %> <%= render 'results_table', results_type: :compatible, diff --git a/spec/features/budgets/results_spec.rb b/spec/features/budgets/results_spec.rb index 0e70fdaab..3b2d05c65 100644 --- a/spec/features/budgets/results_spec.rb +++ b/spec/features/budgets/results_spec.rb @@ -17,6 +17,21 @@ feature 'Results' do visit budget_path(budget) click_link "See results" + within("#budget-investments-compatible") do + expect(page).to have_content investment1.title + expect(page).to have_content investment2.title + expect(page).not_to have_content investment3.title + expect(page).not_to have_content investment4.title + + expect(investment1.title).to appear_before(investment2.title) + end + end + + scenario "Show non winner & incomaptible investments", :js do + visit budget_path(budget) + click_link "See results" + click_link "Show all" + within("#budget-investments-compatible") do expect(page).to have_content investment1.title expect(page).to have_content investment2.title @@ -31,21 +46,6 @@ feature 'Results' do end end - scenario "Displays non winner investments", :js do - visit budget_path(budget) - click_link "See results" - click_link "Hide discarded" - - within("#budget-investments-compatible") do - expect(page).to have_content investment1.title - expect(page).to have_content investment2.title - expect(page).not_to have_content investment3.title - expect(page).not_to have_content investment4.title - - expect(investment1.title).to appear_before(investment2.title) - end - end - scenario "If budget is in a phase different from finished results can't be accessed" do budget.update phase: (Budget::PHASES - ["finished"]).sample visit budget_path(budget)