From 07eda42de4977dfdd4644447a292c6d4b861489e Mon Sep 17 00:00:00 2001 From: cryptogopher Date: Tue, 19 Jan 2021 12:57:57 +0100 Subject: [PATCH] New test: test_index_options_add_column --- test/fixtures/goals.yml | 1 + test/fixtures/quantities.yml | 9 +++++++++ test/fixtures/roles.yml | 1 + test/system/targets_test.rb | 16 ++++++++++++++++ 4 files changed, 27 insertions(+) diff --git a/test/fixtures/goals.yml b/test/fixtures/goals.yml index 2fc82e1..3aeece0 100644 --- a/test/fixtures/goals.yml +++ b/test/fixtures/goals.yml @@ -2,6 +2,7 @@ goals_binding: project_id: 1 is_binding: true name: "<%= I18n.t 'targets.form.binding_goal' %>" + goals_non_binding: project_id: 1 is_binding: false diff --git a/test/fixtures/quantities.yml b/test/fixtures/quantities.yml index c081970..39c499c 100644 --- a/test/fixtures/quantities.yml +++ b/test/fixtures/quantities.yml @@ -6,3 +6,12 @@ quantities_energy: rgt: 2 name: Energy description: Total energy + +quantities_proteins: + project_id: 1 + domain: diet + parent: null + lft: 3 + rgt: 4 + name: Proteins + description: Total amount of proteins diff --git a/test/fixtures/roles.yml b/test/fixtures/roles.yml index c4d1400..3c2adae 100644 --- a/test/fixtures/roles.yml +++ b/test/fixtures/roles.yml @@ -6,6 +6,7 @@ roles_body_trackers_manager: permissions: | - :manage_body_trackers - :view_body_trackers + roles_body_trackers_viewer: name: View body trackers builtin: false diff --git a/test/system/targets_test.rb b/test/system/targets_test.rb index 0e236d5..84fb9a1 100644 --- a/test/system/targets_test.rb +++ b/test/system/targets_test.rb @@ -21,6 +21,17 @@ class TargetsTest < BodyTrackingSystemTestCase assert_selector 'div#targets', visible: :yes, exact_text: t(:label_no_data) end + def test_index_options_add_column + visit project_targets_path(@project1) + assert_no_selector 'table#targets thead th', text: quantities(:quantities_proteins).name + within 'fieldset#options' do + select quantities(:quantities_proteins).name + click_on t(:button_add) + end + assert_selector 'table#targets thead th', text: quantities(:quantities_proteins).name + 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) assert_no_selector 'form#new-target-form' @@ -77,6 +88,11 @@ class TargetsTest < BodyTrackingSystemTestCase # * restoring user input # * removing empty targets + # TODO: test edit and update separately def test_update + visit project_targets_path(@project1) + within 'table#targets tbody tr' do + click_link t(:button_edit) + end end end