Make factories and tests timezone-friendly

This commit is contained in:
Michael Klimenko 2018-03-23 17:13:57 +05:00 committed by James Mason
parent 4bc783b42c
commit 297447d802
6 changed files with 9 additions and 9 deletions

View file

@ -41,7 +41,7 @@ describe Admin::ConferencesController do
mailer = double mailer = double
allow(mailer).to receive(:deliver) allow(mailer).to receive(:deliver)
conference.email_settings = create(:email_settings) conference.email_settings = create(:email_settings)
patch :update, id: conference.short_title, conference: attributes_for(:conference, start_date: Date.today + 2.days, end_date: Date.today + 4.days) patch :update, id: conference.short_title, conference: attributes_for(:conference, start_date: Time.zone.today + 2.days, end_date: Time.zone.today + 4.days)
conference.reload conference.reload
allow(Mailbot).to receive(:conference_date_update_mail).and_return(mailer) allow(Mailbot).to receive(:conference_date_update_mail).and_return(mailer)
end end

View file

@ -5,7 +5,7 @@ FactoryGirl.define do
title { Faker::Book.title } title { Faker::Book.title }
short_title { SecureRandom.urlsafe_base64(4) } short_title { SecureRandom.urlsafe_base64(4) }
timezone { Faker::Address.time_zone } timezone { Faker::Address.time_zone }
start_date { Date.current } start_date { Time.zone.today }
end_date { 6.days.from_now } end_date { 6.days.from_now }
start_hour 9 start_hour 9
end_hour 20 end_hour 20

View file

@ -12,8 +12,8 @@ FactoryGirl.define do
association :submitter, factory: :user association :submitter, factory: :user
state 'new' state 'new'
cfp_active false cfp_active false
start_date { Date.today } start_date { Time.zone.today }
end_date { Date.today } end_date { Time.zone.today }
room room
relevance { Faker::Hipster.paragraph(2) } relevance { Faker::Hipster.paragraph(2) }
end end

View file

@ -1,6 +1,6 @@
FactoryGirl.define do FactoryGirl.define do
factory :vday do factory :vday do
day { Date.today } day { Time.zone.today }
description 'Lorem Ipsum dolsum' description 'Lorem Ipsum dolsum'
conference conference
end end

View file

@ -16,7 +16,7 @@ feature Conference do
select('(GMT+01:00) Berlin', from: 'conference[timezone]') select('(GMT+01:00) Berlin', from: 'conference[timezone]')
today = Date.today - 1 today = Time.zone.today - 1
page page
.execute_script("$('#conference-start-datepicker').val('" + .execute_script("$('#conference-start-datepicker').val('" +
"#{today.strftime('%d/%m/%Y')}')") "#{today.strftime('%d/%m/%Y')}')")
@ -53,7 +53,7 @@ feature Conference do
fill_in 'conference_title', with: 'New Con' fill_in 'conference_title', with: 'New Con'
fill_in 'conference_short_title', with: 'NewCon' fill_in 'conference_short_title', with: 'NewCon'
day = Date.today + 10 day = Time.zone.today + 10
page page
.execute_script("$('#conference-start-datepicker').val('" + .execute_script("$('#conference-start-datepicker').val('" +
"#{day.strftime('%d/%m/%Y')}')") "#{day.strftime('%d/%m/%Y')}')")

View file

@ -34,7 +34,7 @@ feature 'Version' do
scenario 'display changes in cfp', feature: true, versioning: true, js: true do scenario 'display changes in cfp', feature: true, versioning: true, js: true do
cfp = create(:cfp, program: conference.program) cfp = create(:cfp, program: conference.program)
cfp.update_attributes(start_date: (Date.today + 1).strftime('%d/%m/%Y'), end_date: (Date.today + 3).strftime('%d/%m/%Y')) cfp.update_attributes(start_date: (Time.zone.today + 1).strftime('%d/%m/%Y'), end_date: (Time.zone.today + 3).strftime('%d/%m/%Y'))
cfp_id = cfp.id cfp_id = cfp.id
cfp.destroy cfp.destroy
@ -46,7 +46,7 @@ feature 'Version' do
scenario 'display changes in registration_period', feature: true, versioning: true, js: true do scenario 'display changes in registration_period', feature: true, versioning: true, js: true do
registration_period = create(:registration_period, conference: conference) registration_period = create(:registration_period, conference: conference)
registration_period.update_attributes(start_date: (Date.today + 1).strftime('%d/%m/%Y'), end_date: (Date.today + 3).strftime('%d/%m/%Y')) registration_period.update_attributes(start_date: (Time.zone.today + 1).strftime('%d/%m/%Y'), end_date: (Time.zone.today + 3).strftime('%d/%m/%Y'))
registration_period_id = registration_period.id registration_period_id = registration_period.id
registration_period.destroy registration_period.destroy