Skip to content

Commit

Permalink
Do not raise an error if the browser-specified timezone is not recogn…
Browse files Browse the repository at this point in the history
…ized
  • Loading branch information
Tony Novak committed Jul 20, 2016
1 parent 28a2e3f commit 857a897
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/browser-timezone-rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def self.included(base)

def set_time_zone(&action)
# Use existing methods to simplify filter
Time.use_zone(browser_timezone.presence || Time.zone, &action)
Time.use_zone(Time.find_zone(browser_timezone.presence) || Time.zone, &action)
end

def browser_timezone
Expand Down
14 changes: 12 additions & 2 deletions spec/request/set_timezone_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require 'spec_helper'


describe 'sets the timezone' do
describe 'sets the timezone', type: :request do

before do
#Rails server timezone is UTC...
Expand All @@ -27,6 +26,17 @@
end
end

context 'invalid timezone' do
before do
page.driver.browser.set_cookie "browser.timezone=Something/Invalid"
visit '/timezone'
end

it 'does not raise an error' do
page.should have_content "UTC"
end
end

context 'on the first request ever, there will be no cookie, and nothing happens' do

before do
Expand Down

0 comments on commit 857a897

Please sign in to comment.