2015-08-23 14:29:09 +00:00
|
|
|
require "spec_helper"
|
|
|
|
|
|
|
|
feature "Google Calendar widget", js: :true do
|
|
|
|
let(:timezone_name) { Time.zone.name }
|
|
|
|
let(:events_data_file) { Rails.root.join("spec/fixtures/google_calendar.json") }
|
|
|
|
let(:events_list_data) { JSON.parse(File.read(events_data_file)) }
|
2014-04-01 23:07:21 +00:00
|
|
|
|
|
|
|
before do
|
2017-04-03 00:10:38 +00:00
|
|
|
skip # disabling calendar tests for now as they dont fit the new implementation anymore
|
2014-04-01 23:07:21 +00:00
|
|
|
visit root_path
|
|
|
|
end
|
|
|
|
|
2015-08-23 14:29:09 +00:00
|
|
|
scenario "the most recent upcoming event should appear correctly" do
|
2014-04-04 22:56:22 +00:00
|
|
|
time = Time.zone.local(2014, 4, 1, 12, 0, 0)
|
|
|
|
|
|
|
|
Timecop.travel(time) do
|
|
|
|
visit root_path
|
|
|
|
|
|
|
|
expect(first_event).to have_content("Div 2B: el'pheer vs. RadicaL")
|
|
|
|
end
|
2014-04-01 23:07:21 +00:00
|
|
|
end
|
|
|
|
|
2015-08-23 14:29:09 +00:00
|
|
|
feature "Timezones offsets" do
|
|
|
|
scenario "when a user is logged out, CEST is default" do
|
2014-04-04 22:56:22 +00:00
|
|
|
time = Time.zone.local(2014, 4, 1, 12, 0, 0)
|
|
|
|
|
|
|
|
Timecop.travel(time) do
|
|
|
|
visit root_path
|
|
|
|
|
|
|
|
expect(first_event).to have_content("20:30 CEST")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-08-23 14:29:09 +00:00
|
|
|
scenario "when time has passed under 2 hours after the start date" do
|
2014-04-04 22:56:22 +00:00
|
|
|
time = Time.zone.local(2014, 4, 4, 23, 59, 0)
|
|
|
|
|
|
|
|
Timecop.travel(time) do
|
|
|
|
visit root_path
|
|
|
|
|
|
|
|
expect(first_event).to have_content("Div 3B: Mister vs. HBZ")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-08-23 14:29:09 +00:00
|
|
|
scenario "when time has passed over 2 hours after the start date" do
|
2014-04-04 22:56:22 +00:00
|
|
|
time = Time.zone.local(2014, 4, 5, 0, 1, 0)
|
|
|
|
|
|
|
|
Timecop.travel(time) do
|
|
|
|
visit root_path
|
|
|
|
|
|
|
|
expect(first_event).not_to have_content("Div 3B: Mister vs. HBZ")
|
|
|
|
expect(first_event).to have_content("Div 3B: OMNOM vs. Mister")
|
|
|
|
end
|
2014-04-01 23:07:21 +00:00
|
|
|
end
|
|
|
|
|
2015-08-23 14:29:09 +00:00
|
|
|
context "when a user is logged in" do
|
|
|
|
let(:timezone_name) { "Eastern Time (US & Canada)" }
|
2014-10-12 09:58:52 +00:00
|
|
|
|
2015-08-23 14:29:09 +00:00
|
|
|
before do
|
|
|
|
user = create(:user)
|
2014-04-04 22:56:22 +00:00
|
|
|
|
2015-08-23 14:29:09 +00:00
|
|
|
sign_in_as(user)
|
|
|
|
change_timezone_for(user, timezone_name)
|
|
|
|
end
|
2014-04-01 23:07:21 +00:00
|
|
|
|
2015-08-23 14:29:09 +00:00
|
|
|
scenario "their local timezone is used" do
|
|
|
|
time = Time.zone.local(2014, 4, 1, 12, 0, 0)
|
|
|
|
|
|
|
|
Timecop.travel(time) do
|
|
|
|
visit root_path
|
2014-04-01 23:07:21 +00:00
|
|
|
|
2015-08-23 14:29:09 +00:00
|
|
|
expect(first_event).to have_content(timezone_adjusted)
|
|
|
|
end
|
2014-04-04 22:56:22 +00:00
|
|
|
end
|
2014-04-01 23:07:21 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def first_event
|
2014-04-17 07:55:19 +00:00
|
|
|
first ".widget.calendar .entry"
|
2014-04-01 23:07:21 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def timezone_adjusted
|
2015-04-25 21:35:01 +00:00
|
|
|
if Time.zone.now.dst?
|
2014-04-01 23:07:21 +00:00
|
|
|
"14:30 EDT"
|
|
|
|
else
|
|
|
|
"15:30 EST"
|
|
|
|
end
|
|
|
|
end
|
2015-08-23 14:29:09 +00:00
|
|
|
end
|