Change variable name

This commit is contained in:
cryptogopher 2024-12-17 00:14:34 +01:00
parent e15b983b56
commit f472526aa8

View File

@ -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