Skip to content

Commit d62a26d

Browse files
committed
refactor date time tests
1 parent 2b98f23 commit d62a26d

File tree

2 files changed

+12
-30
lines changed

2 files changed

+12
-30
lines changed

test/action_view/cases/test_form_for_helpers.rb

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -433,48 +433,39 @@ def test_time_zone_select_with_validate_options
433433
end
434434

435435
def test_date_select
436-
input_html = ''
437-
438436
form_for(@post, validate: true) do |f|
439-
input_html = f.date_select(:cost)
440-
concat input_html
437+
concat f.date_select(:cost)
441438
end
442439

443440
validators = { 'post[cost]' => { presence: [{ message: "can't be blank" }] } }
444441
expected = whole_form_for('/posts', 'new_post', 'new_post', validators: validators) do
445-
input_html
442+
date_select :post, :cost
446443
end
447444

448445
assert_dom_equal expected, output_buffer
449446
end
450447

451448
def test_time_select
452-
input_html = ''
453-
454449
form_for(@post, validate: true) do |f|
455-
input_html = f.time_select(:cost)
456-
concat input_html
450+
concat f.time_select(:cost)
457451
end
458452

459453
validators = { 'post[cost]' => { presence: [{ message: "can't be blank" }] } }
460454
expected = whole_form_for('/posts', 'new_post', 'new_post', validators: validators) do
461-
input_html
455+
time_select :post, :cost
462456
end
463457

464458
assert_dom_equal expected, output_buffer
465459
end
466460

467461
def test_datetime_select
468-
input_html = ''
469-
470462
form_for(@post, validate: true) do |f|
471-
input_html = f.datetime_select(:cost)
472-
concat input_html
463+
concat f.datetime_select(:cost)
473464
end
474465

475466
validators = { 'post[cost]' => { presence: [{ message: "can't be blank" }] } }
476467
expected = whole_form_for('/posts', 'new_post', 'new_post', validators: validators) do
477-
input_html
468+
datetime_select :post, :cost
478469
end
479470

480471
assert_dom_equal expected, output_buffer

test/action_view/cases/test_form_with_helpers.rb

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -463,48 +463,39 @@ def test_form_with_time_zone_select_with_validate_options
463463
end
464464

465465
def test_date_select
466-
input_html = ''
467-
468466
form_with(model: @post, validate: true) do |f|
469-
input_html = f.date_select(:cost)
470-
concat input_html
467+
concat f.date_select(:cost)
471468
end
472469

473470
validators = { 'post[cost]' => { presence: [{ message: "can't be blank" }] } }
474471
expected = whole_form_with('/posts', validators: validators) do
475-
input_html
472+
date_select :post, :cost
476473
end
477474

478475
assert_dom_equal expected, output_buffer
479476
end
480477

481478
def test_time_select
482-
input_html = ''
483-
484479
form_with(model: @post, validate: true) do |f|
485-
input_html = f.time_select(:cost)
486-
concat input_html
480+
concat f.time_select(:cost)
487481
end
488482

489483
validators = { 'post[cost]' => { presence: [{ message: "can't be blank" }] } }
490484
expected = whole_form_with('/posts', validators: validators) do
491-
input_html
485+
time_select :post, :cost
492486
end
493487

494488
assert_dom_equal expected, output_buffer
495489
end
496490

497491
def test_datetime_select
498-
input_html = ''
499-
500492
form_with(model: @post, validate: true) do |f|
501-
input_html = f.datetime_select(:cost)
502-
concat input_html
493+
concat f.datetime_select(:cost)
503494
end
504495

505496
validators = { 'post[cost]' => { presence: [{ message: "can't be blank" }] } }
506497
expected = whole_form_with('/posts', validators: validators) do
507-
input_html
498+
datetime_select :post, :cost
508499
end
509500

510501
assert_dom_equal expected, output_buffer

0 commit comments

Comments
 (0)