Change variable name
This commit is contained in:
parent
e15b983b56
commit
f472526aa8
@ -35,21 +35,21 @@ class UnitsTest < ApplicationSystemTestCase
|
|||||||
add_link.click
|
add_link.click
|
||||||
assert_equal 'disabled', add_link[:disabled]
|
assert_equal 'disabled', add_link[:disabled]
|
||||||
|
|
||||||
params = nil
|
values = nil
|
||||||
within 'tbody > tr:has(input[type=text], textarea)' do
|
within 'tbody > tr:has(input[type=text], textarea)' do
|
||||||
assert_selector ':focus'
|
assert_selector ':focus'
|
||||||
|
|
||||||
maxlength = all(:fillable_field).to_h { |f| [f[:name], f[:maxlength].to_i || 2**16] }
|
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),
|
symbol: random_string(rand([1..3, 4..maxlength['unit[symbol]']].sample),
|
||||||
except: units.map(&:symbol)),
|
except: units.map(&:symbol)),
|
||||||
description: random_string(rand(0..maxlength['unit[description]']))
|
description: random_string(rand(0..maxlength['unit[description]']))
|
||||||
}.with_indifferent_access
|
}.with_indifferent_access
|
||||||
within :field, 'unit[multiplier]' do |field|
|
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
|
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
|
assert_difference ->{ Unit.count }, 1 do
|
||||||
click_on t('helpers.submit.create')
|
click_on t('helpers.submit.create')
|
||||||
@ -63,7 +63,7 @@ class UnitsTest < ApplicationSystemTestCase
|
|||||||
assert_no_selector :element, :a, 'disabled': 'disabled',
|
assert_no_selector :element, :a, 'disabled': 'disabled',
|
||||||
exact_text: Regexp.union(LINK_LABELS.fetch_values(:add_unit, :add_subunit))
|
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_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
|
end
|
||||||
|
|
||||||
# TODO: check proper form/button redisplay and flash messages on add/edit
|
# TODO: check proper form/button redisplay and flash messages on add/edit
|
||||||
|
Loading…
x
Reference in New Issue
Block a user