Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dates helper #828

Merged
merged 4 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions test/system/dates_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,12 @@ class DatesHelperTest < ApplicationSystemTestCase
click_on "Back"

# Assert today's date is displayed correctly.
assert page.has_text? "Today at #{time.strftime("%l:%M %p").strip}"
assert_text I18n.l(time, format: :default)

# Assert yesterday's date is displayed correctly.
travel_to time + 1.day
visit current_url # Refresh the page
assert page.has_text? "Yesterday at #{time.strftime("%l:%M %p").strip}"

# Assert the month and day is shown for anything before then.
travel_to time + 2.days
visit current_url

# We have to assert these two things separately so it doesn't fail on the last day of the year when the year is present.
assert page.has_text? time.strftime("%B %-d").strip.to_s
assert page.has_text? "at #{time.strftime("%l:%M %p").strip}"
assert_text I18n.l(time, format: :default)

# Create a new record in a different time zone.
Time.zone = "Tokyo"
Expand Down
9 changes: 4 additions & 5 deletions test/system/super_scaffolding_partial_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,9 @@ def setup
find("#partial_test_multiple_buttons_test_two+button", visible: :all).click
find("#partial_test_multiple_buttons_test_three+button", visible: :all).click
# Date partial
find("#partial_test_date_test").click
find(".daterangepicker").click_on("Apply") # Chooses today's date.
page.execute_script('document.getElementById("partial_test_date_test").value = "2021-02-17"')
# DateTime partial
find("#partial_test_date_time_test").click
find(".daterangepicker").click_on("Apply")
page.execute_script('document.getElementById("partial_test_date_time_test").value = "2023-06-14T13:45:00+09:00"')
# File partial
attach_file("test/support/foo.txt", make_visible: true)
# Single Option partial
Expand Down Expand Up @@ -155,10 +153,11 @@ def setup
refute_nil partial_test.multiple_buttons_test
assert_equal partial_test.multiple_buttons_test, ["two", "three"]
# Date
assert_equal partial_test.date_test, Date.today
assert_equal partial_test.date_test, Date.new(2021, 2, 17)
# DateTime
refute_nil partial_test.date_time_test
assert_equal partial_test.date_time_test.class, ActiveSupport::TimeWithZone
assert_equal partial_test.date_time_test, DateTime.parse("2023-06-14T13:45:00+09:00")
# File
refute_nil partial_test.file_test
assert_equal partial_test.file_test.class, ActiveStorage::Attached::One
Expand Down