Hide incompatible and non-winner investments by default

This commit is contained in:
Bertocq
2017-07-10 19:41:04 +02:00
parent 49f48ddf4b
commit 11a793d63f
3 changed files with 22 additions and 18 deletions

View File

@@ -1,4 +1,6 @@
<div class="small-12 medium-9 column <%= results_type == :compatible ? 'success' : 'js-discarded' %>" id="<%= results_type %>-container"> <div class="small-12 medium-9 column <%= results_type == :compatible ? 'success' : 'js-discarded' %>"
style="<%= results_type != :compatible ? 'display: none' : '' %>"
id="<%= results_type %>-container">
<h3 class="inline-block"> <h3 class="inline-block">
<%= title %> <%= title %>
@@ -28,7 +30,9 @@
<tbody> <tbody>
<% amount_available = heading_price %> <% amount_available = heading_price %>
<% investments.each do |investment| %> <% investments.each do |investment| %>
<tr id="<%= dom_id(investment) %>" class="budget-investments <%= investment.winner? ? 'success' : 'js-discarded' %>"> <tr id="<%= dom_id(investment) %>"
class="budget-investments <%= investment.winner? ? 'success' : 'js-discarded' %>"
style="<%= investment.winner? ? '' : 'display: none' %>">
<td> <td>
<% if investment.winner? %> <% if investment.winner? %>
<span class="icon-check"> <span class="icon-check">

View File

@@ -35,7 +35,7 @@
</ul> </ul>
</div> </div>
<span class="float-right"><%= 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")} %></span> <span class="float-right"><%= 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")} %></span>
<%= render 'results_table', results_type: :compatible, <%= render 'results_table', results_type: :compatible,

View File

@@ -17,6 +17,21 @@ feature 'Results' do
visit budget_path(budget) visit budget_path(budget)
click_link "See results" 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 within("#budget-investments-compatible") do
expect(page).to have_content investment1.title expect(page).to have_content investment1.title
expect(page).to have_content investment2.title expect(page).to have_content investment2.title
@@ -31,21 +46,6 @@ feature 'Results' do
end end
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 scenario "If budget is in a phase different from finished results can't be accessed" do
budget.update phase: (Budget::PHASES - ["finished"]).sample budget.update phase: (Budget::PHASES - ["finished"]).sample
visit budget_path(budget) visit budget_path(budget)