diff --git a/test/system/units_test.rb b/test/system/units_test.rb index 55c0b7b..bf7ccef 100644 --- a/test/system/units_test.rb +++ b/test/system/units_test.rb @@ -35,21 +35,21 @@ class UnitsTest < ApplicationSystemTestCase add_link.click assert_equal 'disabled', add_link[:disabled] - params = nil + values = nil within 'tbody > tr:has(input[type=text], textarea)' do assert_selector ':focus' maxlength = all(:fillable_field).to_h { |f| [f[:name], f[:maxlength].to_i || 2**16] } - params = { + values = { symbol: random_string(rand([1..3, 4..maxlength['unit[symbol]']].sample), except: units.map(&:symbol)), description: random_string(rand(0..maxlength['unit[description]'])) }.with_indifferent_access within :field, 'unit[multiplier]' do |field| - params[:multiplier] = random_number(field[:max], field[:step]) + values[:multiplier] = random_number(field[:max], field[:step]) end if type == :add_subunit - params.each_pair { |name, value| fill_in "unit[#{name}]", with: value } + values.each_pair { |name, value| fill_in "unit[#{name}]", with: value } assert_difference ->{ Unit.count }, 1 do click_on t('helpers.submit.create') @@ -63,7 +63,7 @@ class UnitsTest < ApplicationSystemTestCase assert_no_selector :element, :a, 'disabled': 'disabled', exact_text: Regexp.union(LINK_LABELS.fetch_values(:add_unit, :add_subunit)) assert_selector '.flash.notice', text: t('units.create.success', unit: Unit.last.symbol) - assert_equal params, Unit.last.attributes.slice(*params.keys) + assert_equal values, Unit.last.attributes.slice(*values.keys) end # TODO: check proper form/button redisplay and flash messages on add/edit