Skip to content

Commit

Permalink
refactor date time tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalRemis committed Apr 26, 2020
1 parent 2b98f23 commit d62a26d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 30 deletions.
21 changes: 6 additions & 15 deletions test/action_view/cases/test_form_for_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -433,48 +433,39 @@ def test_time_zone_select_with_validate_options
end

def test_date_select
input_html = ''

form_for(@post, validate: true) do |f|
input_html = f.date_select(:cost)
concat input_html
concat f.date_select(:cost)
end

validators = { 'post[cost]' => { presence: [{ message: "can't be blank" }] } }
expected = whole_form_for('/posts', 'new_post', 'new_post', validators: validators) do
input_html
date_select :post, :cost
end

assert_dom_equal expected, output_buffer
end

def test_time_select
input_html = ''

form_for(@post, validate: true) do |f|
input_html = f.time_select(:cost)
concat input_html
concat f.time_select(:cost)
end

validators = { 'post[cost]' => { presence: [{ message: "can't be blank" }] } }
expected = whole_form_for('/posts', 'new_post', 'new_post', validators: validators) do
input_html
time_select :post, :cost
end

assert_dom_equal expected, output_buffer
end

def test_datetime_select
input_html = ''

form_for(@post, validate: true) do |f|
input_html = f.datetime_select(:cost)
concat input_html
concat f.datetime_select(:cost)
end

validators = { 'post[cost]' => { presence: [{ message: "can't be blank" }] } }
expected = whole_form_for('/posts', 'new_post', 'new_post', validators: validators) do
input_html
datetime_select :post, :cost
end

assert_dom_equal expected, output_buffer
Expand Down
21 changes: 6 additions & 15 deletions test/action_view/cases/test_form_with_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -463,48 +463,39 @@ def test_form_with_time_zone_select_with_validate_options
end

def test_date_select
input_html = ''

form_with(model: @post, validate: true) do |f|
input_html = f.date_select(:cost)
concat input_html
concat f.date_select(:cost)
end

validators = { 'post[cost]' => { presence: [{ message: "can't be blank" }] } }
expected = whole_form_with('/posts', validators: validators) do
input_html
date_select :post, :cost
end

assert_dom_equal expected, output_buffer
end

def test_time_select
input_html = ''

form_with(model: @post, validate: true) do |f|
input_html = f.time_select(:cost)
concat input_html
concat f.time_select(:cost)
end

validators = { 'post[cost]' => { presence: [{ message: "can't be blank" }] } }
expected = whole_form_with('/posts', validators: validators) do
input_html
time_select :post, :cost
end

assert_dom_equal expected, output_buffer
end

def test_datetime_select
input_html = ''

form_with(model: @post, validate: true) do |f|
input_html = f.datetime_select(:cost)
concat input_html
concat f.datetime_select(:cost)
end

validators = { 'post[cost]' => { presence: [{ message: "can't be blank" }] } }
expected = whole_form_with('/posts', validators: validators) do
input_html
datetime_select :post, :cost
end

assert_dom_equal expected, output_buffer
Expand Down

0 comments on commit d62a26d

Please sign in to comment.