From 80b10d108a012a5d33e5a2c04104345a588d4d3b Mon Sep 17 00:00:00 2001 From: cryptogopher Date: Thu, 21 Jan 2021 11:17:51 +0100 Subject: [PATCH] Test pass: test_index_table_header_close_exposure Allow closing last quantity column --- app/helpers/body_trackers_helper.rb | 3 ++- app/views/measurements/_readouts.html.erb | 2 +- app/views/targets/_index.html.erb | 10 +++++++--- test/system/targets_test.rb | 9 +++++++++ 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/app/helpers/body_trackers_helper.rb b/app/helpers/body_trackers_helper.rb index 39158e7..ad5bba8 100644 --- a/app/helpers/body_trackers_helper.rb +++ b/app/helpers/body_trackers_helper.rb @@ -59,7 +59,8 @@ module BodyTrackersHelper # * int > 0 - quantity name-labelled cell with 'int' size colspan # * int < 0 - quantity name-labelled cell with 'int' size rowspan # * 0 - non-labelled cell without col-/rowspan - spec = [] + spec = [Hash.new(0)] + return spec if quantities.empty? default_row = Hash.new(0) # Determine colspans first... diff --git a/app/views/measurements/_readouts.html.erb b/app/views/measurements/_readouts.html.erb index 543435a..8c74fa9 100644 --- a/app/views/measurements/_readouts.html.erb +++ b/app/views/measurements/_readouts.html.erb @@ -63,7 +63,7 @@ - <% next unless @quantities.length > 0 %> + <% next if @quantities.empty? %> <% extra_quantities.each_slice(@quantities.length) do |eqs| %> <% eqs.each do |q| %> diff --git a/app/views/targets/_index.html.erb b/app/views/targets/_index.html.erb index f0829f2..b53f69d 100644 --- a/app/views/targets/_index.html.erb +++ b/app/views/targets/_index.html.erb @@ -15,8 +15,9 @@ <% header.each_with_index do |row, i| %> <% if i == 0 %> - <%= l(:field_effective_from) %> + + <%= l(:field_effective_from) %> + <% end %> <% row.each do |q, span| %> @@ -83,9 +84,12 @@ <%= q.name %>

<%= targets.delete(q) %>

<% end %> - <%= action_links(date) %> + + <%= action_links(date) %> + + <% next if @quantities.empty? %> <% targets.each_slice(@quantities.length) do |extras| %> <% extras.each do |q, t| %> diff --git a/test/system/targets_test.rb b/test/system/targets_test.rb index 0fdbde3..70281da 100644 --- a/test/system/targets_test.rb +++ b/test/system/targets_test.rb @@ -31,6 +31,15 @@ class TargetsTest < BodyTrackingSystemTestCase assert_selector 'table#targets thead th', text: quantities(:quantities_proteins).name end + def test_index_table_header_close_exposure + visit project_targets_path(@project1) + within 'table#targets thead th', text: quantities(:quantities_energy).name do + click_link class: 'icon-close' + end + assert_no_selector 'table#targets thead th', text: quantities(:quantities_energy).name + assert_selector 'table#targets thead th' + end + # TODO: rename to test_new; move checking of default values here def test_index_show_and_hide_new_target_form visit project_targets_path(@project1)