From 8f2a45556188062a768da9ea281634d53474745a Mon Sep 17 00:00:00 2001 From: cryptogopher Date: Wed, 26 Aug 2020 02:07:36 +0200 Subject: [PATCH] Added defaults load test --- app/controllers/body_trackers_controller.rb | 2 +- test/system/body_trackers_test.rb | 18 ++++++++++++++++++ test/system/targets_test.rb | 2 -- 3 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 test/system/body_trackers_test.rb diff --git a/app/controllers/body_trackers_controller.rb b/app/controllers/body_trackers_controller.rb index 8da8a8c..51c8c32 100644 --- a/app/controllers/body_trackers_controller.rb +++ b/app/controllers/body_trackers_controller.rb @@ -46,7 +46,7 @@ class BodyTrackersController < ApplicationController failed_objects += available_quantities.values.reject { |o| o.persisted? || o.save } end - new_quantities_count = @project.quantities(true).size - quantities_count + new_quantities_count = @project.quantities.reload.size - quantities_count flash[:notice] += ", #{new_quantities_count > 0 ? new_quantities_count : "no" } new" \ " #{'quantity'.pluralize(new_quantities_count)}" diff --git a/test/system/body_trackers_test.rb b/test/system/body_trackers_test.rb new file mode 100644 index 0000000..f620aa3 --- /dev/null +++ b/test/system/body_trackers_test.rb @@ -0,0 +1,18 @@ +require File.expand_path('../../application_system_test_case', __FILE__) + +class BodyTrackersTest < BodyTrackingSystemTestCase + def setup + super + @project1 = projects(:projects_001) + log_user 'jsmith', 'jsmith' + end + + def test_defaults_load + visit project_body_trackers_path(@project1) + accept_alert t('layouts.sidebar.confirm_defaults') do + click_link t('layouts.sidebar.link_defaults') + end + assert_selector 'div#flash_notice' + assert_no_selector 'div#flash_error' + end +end diff --git a/test/system/targets_test.rb b/test/system/targets_test.rb index a3bd56f..0e236d5 100644 --- a/test/system/targets_test.rb +++ b/test/system/targets_test.rb @@ -3,9 +3,7 @@ require File.expand_path('../../application_system_test_case', __FILE__) class TargetsTest < BodyTrackingSystemTestCase def setup super - @project1 = projects(:projects_001) - log_user 'jsmith', 'jsmith' end