Skip to content

Instantly share code, notes, and snippets.

@voodoorai2000
Last active March 5, 2018 19:01
Show Gist options
  • Save voodoorai2000/5b8e1416c46c69c655f534e0c6b082ff to your computer and use it in GitHub Desktop.
Save voodoorai2000/5b8e1416c46c69c655f534e0c6b082ff to your computer and use it in GitHub Desktop.
Make stats_controller_spec.rb aware of timezones
context 'events present' do
let(:time_1) { DateTime.parse("2015-01-01").in_time_zone }
let(:time_2) { DateTime.parse("2015-01-02").in_time_zone }
let(:time_3) { DateTime.parse("2015-01-03").in_time_zone }
before do
create :ahoy_event, name: 'foo', time: time_1
create :ahoy_event, name: 'foo', time: time_1
create :ahoy_event, name: 'foo', time: time_2
create :ahoy_event, name: 'bar', time: time_1
create :ahoy_event, name: 'bar', time: time_3
create :ahoy_event, name: 'bar', time: time_3
end
it 'returns single events formated for working with c3.js' do
sign_in user
get :show, event: 'foo'
expect(response).to be_ok
data = JSON.parse(response.body)
date_1 = I18n.l(time_1.to_date)
date_2 = I18n.l(time_2.to_date)
expect(data).to eq "x" => [date_1, date_2], "Foo" => [2, 1]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment