Skip to content

Commit

Permalink
Merge pull request #453 from alphagov/fix-422-errors-on-ios
Browse files Browse the repository at this point in the history
Fix 422 errors on iOS
  • Loading branch information
h-lame committed Apr 12, 2016
2 parents 28681e1 + fe9db94 commit a335379
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/helpers/date_time_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def waiting_for_in_words(date, now = Time.current)
return unless date.present?

scope = :"petitions.waiting_for_in_words"
days = ((now.end_of_day - date.end_of_day) / 86400.0).floor
days = ((now.end_of_day - date.end_of_day) / 86400.0).round
key = WAITING_FOR_KEYS[days]

t(key, scope: scope, formatted_count: number_with_delimiter(days))
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/session_store.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Be sure to restart your server when you modify this file.

Rails.application.config.session_store :cookie_store, key: '_epets_session'
Rails.application.config.session_store :cookie_store, key: '_epets_session', expire_after: 2.weeks
26 changes: 26 additions & 0 deletions spec/helpers/date_time_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,32 @@
end
end

context "when the time span crosses the spring DST boundary" do
let(:now) { Time.utc(2016, 4, 11, 11, 0, 0).in_time_zone }
let(:date) { 30.days.ago(now) }

around do |example|
travel_to(now) { example.run }
end

it "returns 'Waiting for 30 days'" do
expect(helper.waiting_for_in_words(date)).to eq("Waiting for 30 days")
end
end

context "when the time span crosses the autumn DST boundary" do
let(:now) { Time.utc(2016, 11, 11, 12, 0, 0).in_time_zone }
let(:date) { 30.days.ago(now) }

around do |example|
travel_to(now) { example.run }
end

it "returns 'Waiting for 30 days'" do
expect(helper.waiting_for_in_words(date)).to eq("Waiting for 30 days")
end
end

context "when the response threshold was reached 3 years ago" do
let(:date) { 1095.days.ago(now) }

Expand Down

0 comments on commit a335379

Please sign in to comment.