Skip to content

Commit

Permalink
Merge pull request #5609 from ryoung-sf/update_date_format
Browse files Browse the repository at this point in the history
fix: format date to US format MM/DD/YYYY
  • Loading branch information
compwron authored Apr 25, 2024
2 parents 82f3425 + 729c400 commit 309f016
Show file tree
Hide file tree
Showing 27 changed files with 67 additions and 75 deletions.
4 changes: 1 addition & 3 deletions app/views/casa_cases/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@
<%= cdf.label :date, "Next Court Date" %>
<br>
<div class="input-style-1">
<%= cdf.text_field :date,
data: {provide: "datepicker", date_format: "yyyy/mm/dd"},
class: "form-control" %>
<%= cdf.date_field :date, class: "form-control" %>
</div>
</div>
<% end %>
Expand Down
6 changes: 2 additions & 4 deletions app/views/case_contacts/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,11 @@
</div>
<div class="col-sm-6 input-style-1">
<%= f.label "Starting from", for: "filterrific_occurred_starting_at" %>
<%= f.text_field(:occurred_starting_at, data: {provide: "datepicker", date_format: "yyyy/mm/dd"},
class: "") %>
<%= f.date_field(:occurred_starting_at, class: "") %>
</div>
<div class="col-sm-6 input-style-1">
<%= f.label "Ending at", for: "filterrific_occurred_ending_at" %>
<%= f.text_field(:occurred_ending_at, data: {provide: "datepicker", date_format: "yyyy/mm/dd"},
class: "") %>
<%= f.date_field(:occurred_ending_at, class: "") %>
</div>
</div>
<div class="row mb-4">
Expand Down
6 changes: 2 additions & 4 deletions app/views/court_dates/_fields.html.erb
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<div class="input-style-1">
<%= form.label :date, "Add Court Date" %>
<%= form.text_field :date,
<%= form.date_field :date,
value: court_date.date&.to_date || Time.zone.now,
data: {provide: "datepicker", date_format: "yyyy/mm/dd"},
class: "form-control" %>
</div>
<div class="input-style-1">
<%= form.label :court_report_due_date, "Add Court Report Due Date" %>
<%= form.text_field :court_report_due_date,
<%= form.date_field :court_report_due_date,
value: court_date.court_report_due_date&.to_date,
data: {provide: "datepicker", date_format: "yyyy/mm/dd"},
class: "form-control" %>
</div>
<div class="select-style-1">
Expand Down
2 changes: 1 addition & 1 deletion app/views/court_dates/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<dt>
<h6>Court Report Due Date:</h6>
</dt>
<dd class="mb-3"><%= @court_date.court_report_due_date&.to_date || "None" %></dd>
<dd class="mb-3"><%= I18n.l(@court_date.court_report_due_date, format: :full, default: "None") %></dd>
<dt>
<h6>Judge:</h6>
</dt>
Expand Down
4 changes: 2 additions & 2 deletions app/views/layouts/components/_ranged_date_picker.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%= form.text_field model_field,
<%= form.date_field model_field,
value: initial_value,
data: {date_format: "yyyy/mm/dd", provide: "datepicker", max_date: local_assigns.has_key?(:max_date) ? max_date : nil, min_date: local_assigns.has_key?(:min_date) ? min_date : nil},
data: { max_date: local_assigns.has_key?(:max_date) ? max_date : nil, min_date: local_assigns.has_key?(:min_date) ? min_date : nil },
class: "card-style-1 component-date-picker-range",
"component-name": component_name %>
3 changes: 1 addition & 2 deletions app/views/learning_hours/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@
<h5 class="mb-3"><%= form.label :occurred_at, "Occurred On" %>:</h5>
<% occurred_at = learning_hour.occurred_at || Date.today %>
<div class="input-style-1">
<%= form.text_field :occurred_at,
<%= form.date_field :occurred_at,
value: occurred_at.to_date,
data: {provide: "datepicker", date_format: "yyyy/mm/dd"},
class: "form-control label-font-weight" %>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/learning_hours/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<tr>
<td><%= @learning_hour.name %></td>
<td><%= @learning_hour.learning_hour_type.name %></td>
<td><%= @learning_hour.occurred_at.strftime("%B %d, %Y") %></td>
<td><%= I18n.l(@learning_hour.occurred_at, format: :full) %></td>
<td>
<% if (@learning_hour.duration_hours > 0) %>
<%= @learning_hour.duration_hours %> hr
Expand Down
7 changes: 3 additions & 4 deletions app/views/mileage_rates/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@
</div>
<div class="input-style-1">
<%= form.label :effective_date, 'Effective date' %>
<%= form.text_field :effective_date, value: effective_date_parser(mileage_rate.effective_date),
data: { provide: "datepicker",
date_format: ::DateHelper::JQUERY_MONTH_DAY_YEAR_FORMAT },
class: "form-control" %>
<%= form.date_field :effective_date,
value: mileage_rate.effective_date,
class: "form-control" %>
</div>
<div class="input-style-1">
<%= form.label :amount, 'Amount' %>
Expand Down
4 changes: 1 addition & 3 deletions app/views/other_duties/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
<div class="input-style-1">
<%= form.label :occurred_at, "Occurred On" %>
<% occurred_at = @other_duty.occurred_at || Time.zone.now %>
<%= form.text_field :occurred_at,
value: occurred_at.to_date,
data: {provide: "datepicker", date_format: "yyyy/mm/dd"} %>
<%= form.date_field :occurred_at, value: occurred_at.to_date %>
</div>

<div class="row input-style-1">
Expand Down
4 changes: 1 addition & 3 deletions app/views/reimbursements/_occurred_at_filter_input.html.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<div>
<%= label %>
<%= text_field(
<%= date_field(
nil,
name,
data: {
provide: "datepicker",
date_format: "yyyy/mm/dd",
date_end_date: Time.now,
date_start_date: @occurred_at_filter_start_date
},
Expand Down
10 changes: 4 additions & 6 deletions app/views/reports/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,15 @@

<div class="field form-group mb-20">
<label class="form-label"><h6>Starting From</h6></label>
<%= f.text_field :start_date, value: 6.months.ago.strftime(::DateHelper::RUBY_MONTH_DAY_YEAR_FORMAT),
data: { provide: "datepicker",
date_format: ::DateHelper::JQUERY_MONTH_DAY_YEAR_FORMAT },
<%= f.date_field :start_date,
value: 6.months.ago,
class: "form-control" %>
</div>

<div class="field form-group mb-20">
<label class="form-label"><h6>Ending At</h6></label>
<%= f.text_field :end_date, value: Date.today.strftime(::DateHelper::RUBY_MONTH_DAY_YEAR_FORMAT),
data: { provide: "datepicker",
date_format: ::DateHelper::JQUERY_MONTH_DAY_YEAR_FORMAT },
<%= f.date_field :end_date,
value: Date.today,
class: "form-control" %>
</div>

Expand Down
5 changes: 2 additions & 3 deletions app/views/shared/_edit_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@
<div class="input-style-1">
<%= f.label :date_of_birth, "Date of birth" %>
<% if policy(resource).update_user_setting? %>
<%= f.text_field :date_of_birth,
value: resource.decorate.formatted_date_of_birth,
data: {provide: "datepicker", date_format: "yyyy/mm/dd"},
<%= f.date_field :date_of_birth,
value: resource.date_of_birth,
class: "form-control label-font-weight" %>
<% else %>
<input type="text" placeholder="<%= resource.decorate.formatted_date_of_birth %>" autocomplete="off" readonly>
Expand Down
5 changes: 2 additions & 3 deletions app/views/users/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@

<div class="input-style-1">
<%= form.label :date_of_birth, "Date of birth" %>
<%= form.text_field :date_of_birth,
value: @user.decorate.formatted_date_of_birth,
data: {provide: "datepicker", date_format: "yyyy/mm/dd"},
<%= form.date_field :date_of_birth,
value: @user.date_of_birth,
class: "form-control label-font-weight" %>
</div>

Expand Down
5 changes: 2 additions & 3 deletions app/views/volunteers/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@

<div class="input-style-1">
<%= form.label :date_of_birth, "Date of birth" %>
<%= form.text_field :date_of_birth,
value: @volunteer.date_of_birth&.strftime("%Y/%m/%d"),
data: {provide: "datepicker", date_format: "yyyy/mm/dd"},
<%= form.date_field :date_of_birth,
value: @volunteer.date_of_birth,
class: "form-control label-font-weight" %>
</div>

Expand Down
2 changes: 1 addition & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
en:
time:
formats:
day_and_date: "%A, %d-%b-%Y"
day_and_date: "%A, %b %d, %Y"
standard: "%m-%d-%Y"
contact_occurred_at: "%Y%m%d%H%M%s"
full: "%B %-d, %Y"
Expand Down
1 change: 0 additions & 1 deletion spec/support/fill_in_case_contact_fields.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ def complete_details_page(contact_made:, medium: nil, occurred_on: nil, hours: n
end
choose medium if medium
fill_in "case_contact_occurred_at", with: occurred_on if occurred_on

fill_in "case_contact_duration_hours", with: hours if hours
fill_in "case_contact_duration_minutes", with: minutes if minutes

Expand Down
6 changes: 3 additions & 3 deletions spec/system/casa_cases/new_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
fourteen_years = (Date.today.year - 14).to_s
fill_in "Case number", with: case_number

fill_in "Court Date", with: court_date.strftime("%Y/%m/%d")
fill_in "Court Date", with: court_date

select "March", from: "casa_case_birth_month_year_youth_2i"
select fourteen_years, from: "casa_case_birth_month_year_youth_1i"
Expand Down Expand Up @@ -56,7 +56,7 @@
visit new_casa_case_path

fill_in "Case number", with: case_number
fill_in "Next Court Date", with: DateTime.now.next_month.strftime("%Y/%m/%d")
fill_in "Next Court Date", with: DateTime.now.next_month
five_years = (Date.today.year - 5).to_s
select "March", from: "casa_case_birth_month_year_youth_2i"
select five_years, from: "casa_case_birth_month_year_youth_1i"
Expand All @@ -67,7 +67,7 @@

expect(page).to have_content(case_number)
expect(page).to have_content("CASA case was successfully created.")
expect(page).to have_content("Next Court Date:")
expect(page).to have_content("Next Court Date: ")
expect(page).not_to have_content("Court Report Due Date:")
expect(page).to have_content("Transition Aged Youth: No")
end
Expand Down
8 changes: 4 additions & 4 deletions spec/system/case_contacts/index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
visit case_contacts_path
click_button "Show / Hide"

fill_in "filterrific_occurred_starting_at", with: Time.zone.yesterday.to_s
fill_in "filterrific_occurred_ending_at", with: Time.zone.tomorrow.to_s
fill_in "filterrific_occurred_starting_at", with: Time.zone.yesterday
fill_in "filterrific_occurred_ending_at", with: Time.zone.tomorrow

click_button "Filter"

Expand Down Expand Up @@ -150,8 +150,8 @@

# filtering to only show case 2
click_button "Show / Hide"
fill_in "filterrific_occurred_starting_at", with: Time.zone.yesterday.to_s
fill_in "filterrific_occurred_ending_at", with: Time.zone.tomorrow.to_s
fill_in "filterrific_occurred_starting_at", with: Time.zone.yesterday
fill_in "filterrific_occurred_ending_at", with: Time.zone.tomorrow
click_button "Filter"
expect(page).to have_text("Case 2 Notes")
expect(page).to_not have_text("Case 1 Notes")
Expand Down
7 changes: 3 additions & 4 deletions spec/system/case_contacts/new_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@
expect(page).to_not have_text("Hidden")

click_on "New Case Contact"
complete_details_page(case_numbers: [], contact_types: %w[School Therapist], contact_made: true, medium: "Video", occurred_on: "04/04/2020", hours: 1, minutes: 45)
complete_details_page(case_numbers: [], contact_types: %w[School Therapist], contact_made: true, medium: "Video", occurred_on: Date.new(2020, 4, 5), hours: 1, minutes: 45)
complete_notes_page
fill_in_expenses_page

expect {
click_on "Submit"
}.to change(CaseContact.where(status: "active"), :count).by(1)

expect(CaseContact.first.casa_case_id).to eq casa_case.id
expect(CaseContact.first.contact_types).to match_array([school, therapist])
expect(CaseContact.first.duration_minutes).to eq 105
Expand All @@ -55,7 +54,7 @@
visit casa_case_path(casa_case.id)
click_on "New Case Contact"

complete_details_page(case_numbers: [], contact_types: %w[School Therapist], contact_made: true, medium: "Video", occurred_on: "04/04/2020", hours: 1, minutes: 45)
complete_details_page(case_numbers: [], contact_types: %w[School Therapist], contact_made: true, medium: "Video", occurred_on: "04/05/2020", hours: 1, minutes: 45)
short_notes = "Hello world!"
complete_notes_page(notes: short_notes)
fill_in_expenses_page
Expand Down Expand Up @@ -176,7 +175,7 @@ def index_of(text)

visit new_case_contact_path(volunteer_casa_case_one.id)

complete_details_page(case_numbers: [volunteer_casa_case_one.case_number], contact_types: %w[School Therapist], contact_made: true, medium: "In Person", occurred_on: "04/04/2020", hours: 1, minutes: 45)
complete_details_page(case_numbers: [volunteer_casa_case_one.case_number], contact_types: %w[School Therapist], contact_made: true, medium: "In Person", occurred_on: Date.new(2020, 0o4, 0o6), hours: 1, minutes: 45)
complete_notes_page(notes: "Hello world")
fill_in_expenses_page

Expand Down
8 changes: 4 additions & 4 deletions spec/system/court_dates/new_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require "rails_helper"

RSpec.describe "court_dates/new", type: :system do
let(:now) { Date.new(2021, 1, 1) }
let(:now) { Date.new(2021, 1, 2) }
let(:casa_org) { create(:casa_org) }
let(:admin) { create(:casa_admin, casa_org: casa_org) }
let!(:casa_case) { create(:casa_case, casa_org: casa_org) }
Expand All @@ -23,8 +23,8 @@
it "is successful", js: true do
expect(page).to have_content(casa_case.case_number)

fill_in "court_date_date", with: :now
fill_in "court_date_court_report_due_date", with: :now
fill_in "court_date_date", with: now
fill_in "court_date_court_report_due_date", with: now
select judge.name, from: "Judge"
select hearing_type.name, from: "Hearing type"

Expand All @@ -39,7 +39,7 @@

expect(page).to have_content("Court date was successfully created.")
expect(page).to have_content(casa_case.case_number)
expect(page).to have_content("Court Report Due Date:")
expect(page).to have_content("Court Report Due Date:\nJanuary 2, 2021")
expect(page).to have_content(judge.name)
expect(page).to have_content(hearing_type.name)
expect(page).to have_content(text)
Expand Down
11 changes: 11 additions & 0 deletions spec/system/learning_hours/new_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,15 @@

expect(page).to have_text("Duration minutes and hours (total duration) must be greater than 0")
end

it "errors if occured on date set in the future" do
fill_in "Learning Hours Title", with: "Test title"
select "Book", from: "Type of Learning"
fill_in "Hour(s)", with: "2"
fill_in "Minute(s)", with: "30"
fill_in "Occurred On", with: Date.tomorrow
click_on "Create New Learning Hours Entry"

expect(page).to have_text("Date cannot be in the future")
end
end
4 changes: 2 additions & 2 deletions spec/system/learning_hours/volunteers/show_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@

it "displays the volunteer's first learning hours", js: true do
expect(page).to have_content(learning_hours.first.name)
expect(page).to have_content(learning_hours.first.occurred_at.strftime("%B %d, %Y"))
expect(page).to have_content(learning_hours.first.occurred_at.strftime("%B %-d, %Y"))
end

it "displays the volunteer's last learning hours", js: true do
expect(page).to have_content(learning_hours.last.name)
expect(page).to have_content(learning_hours.last.occurred_at.strftime("%B %d, %Y"))
expect(page).to have_content(learning_hours.last.occurred_at.strftime("%B %-d, %Y"))
end
end
end
4 changes: 2 additions & 2 deletions spec/system/mileage_rates/mileage_rates_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
it "add new mileage rate" do
click_on "New Mileage Rate"
expect(page).to have_text("New Mileage Rate")
fill_in "Effective date", with: "01-01-2020"
fill_in "Effective date", with: "02/01/2020"
fill_in "Amount", with: 1.35
uncheck "Currently active?"
click_on "Save Mileage Rate"

expect(page).to have_text("Mileage Rates")
expect(page).to have_text("Effective date")
expect(page).to have_text("January 1, 2020")
expect(page).to have_text("February 1, 2020")
expect(page).to have_text("Amount")
expect(page).to have_text("$1.35")
expect(page).to have_text("Active?")
Expand Down
8 changes: 4 additions & 4 deletions spec/system/reports/export_data_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
excluded_by_contact_type = create(:case_contact, occurred_at: 20.days.ago, contact_types: [school], notes: "Excluded by Contact Type")

visit reports_path
start_date = 30.days.ago.strftime(::DateHelper::RUBY_MONTH_DAY_YEAR_FORMAT)
end_date = 10.days.ago.strftime(::DateHelper::RUBY_MONTH_DAY_YEAR_FORMAT)
page.execute_script("document.getElementById('report_start_date').setAttribute('value', '#{start_date}')")
page.execute_script("document.getElementById('report_end_date').setAttribute('value', '#{end_date}')")
start_date = 30.days.ago
end_date = 10.days.ago
fill_in "report_start_date", with: start_date
fill_in "report_end_date", with: end_date
select court.name, from: "multiple-select-field3"
click_button "Download Report"
wait_for_download
Expand Down
8 changes: 4 additions & 4 deletions spec/system/reports/index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
visit reports_path

expect(page).to have_text "Case Contacts Report"
expect(page).to have_text I18n.l(6.months.ago.to_date, format: :day_and_date, default: "")
expect(page).to have_text I18n.l(Date.today.to_date, format: :day_and_date, default: "")
expect(page).to have_field("report_start_date", with: 6.months.ago.strftime("%Y-%m-%d"))
expect(page).to have_field("report_end_date", with: Date.today)
expect(page).to have_text "Assigned To"
expect(page).to have_text "Volunteers"
expect(page).to have_text "Contact Type"
Expand Down Expand Up @@ -54,8 +54,8 @@
visit reports_path

expect(page).to have_text "Case Contacts Report"
expect(page).to have_text I18n.l(6.months.ago.to_date, format: :day_and_date, default: "")
expect(page).to have_text I18n.l(Date.today.to_date, format: :day_and_date, default: "")
expect(page).to have_field("report_start_date", with: 6.months.ago.strftime("%Y-%m-%d"))
expect(page).to have_field("report_end_date", with: Date.today)
expect(page).to have_text "Assigned To"
expect(page).to have_text "Volunteers"
expect(page).to have_text "Contact Type"
Expand Down
Loading

0 comments on commit 309f016

Please sign in to comment.