Skip to content

Commit

Permalink
Updating Office365 url to avoid blank page redirect on event save (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
CobiOneCanobi authored Nov 8, 2024
1 parent 401e3ce commit f85bf30
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 37 deletions.
4 changes: 2 additions & 2 deletions lib/add_to_calendar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def hey_url
end

def office365_url
# Eg. https://outlook.live.com/calendar/0/deeplink/compose?path=/calendar/action/compose&rru=addevent&subject=Holly%27s%208th%20Birthday%21&startdt=2020-05-12T12:30:00Z&enddt=2020-05-12T16:00:00Z&body=Come%20join%20us%20for%20lots%20of%20fun%20%26%20cake%21%0A%0Ahttps%3A%2F%2Fwww.example.com%2Fevent-details&location=Flat%204%2C%20The%20Edge%2C%2038%20Smith-Dorrien%20St%2C%20London%2C%20N1%207GU
# Eg. https://outlook.office.com/calendar/0/action/compose?rru=addevent&subject=Holly%27s%208th%20Birthday%21&startdt=2020-05-12T12:30:00Z&enddt=2020-05-12T16:00:00Z&body=Come%20join%20us%20for%20lots%20of%20fun%20%26%20cake%21%0A%0Ahttps%3A%2F%2Fwww.example.com%2Fevent-details&location=Flat%204%2C%20The%20Edge%2C%2038%20Smith-Dorrien%20St%2C%20London%2C%20N1%207GU
microsoft("office365")
end

Expand Down Expand Up @@ -254,7 +254,7 @@ def microsoft(service)
if service == "outlook.com"
calendar_url = "https://outlook.live.com/calendar/0/deeplink/compose?path=/calendar/action/compose&rru=addevent"
elsif service == "office365"
calendar_url = "https://outlook.office.com/calendar/0/deeplink/compose?path=/calendar/action/compose&rru=addevent"
calendar_url = "https://outlook.office.com/calendar/0/action/compose?rru=addevent"
else
raise MicrosoftServiceError, ":service must be 'outlook.com' or 'office365'. '#{service}' given"
end
Expand Down
70 changes: 35 additions & 35 deletions test/urls/office365_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ def setup
@location = "Flat 4, The Edge, 38 Smith-Dorrien St, London, N1 7GU"
@description = "Come join us for lots of fun & cake!"

@url_with_defaults_required = "https://outlook.office.com/calendar/0/deeplink/compose?path=/calendar/action/compose&rru=addevent" +
"&subject=Holly%27s%208th%20Birthday%21" +
"&startdt=#{@next_month_year}-#{@next_month_month}-#{@next_month_day}T#{@hour}:30:00Z" +
@url_with_defaults_required = "https://outlook.office.com/calendar/0/action/compose?rru=addevent" +
"&subject=Holly%27s%208th%20Birthday%21" +
"&startdt=#{@next_month_year}-#{@next_month_month}-#{@next_month_day}T#{@hour}:30:00Z" +
"&enddt=#{@next_month_year}-#{@next_month_month}-#{@next_month_day}T#{@hour+1}:30:00Z"

end
Expand All @@ -50,9 +50,9 @@ def test_with_only_required_attributes
def test_without_end_datetime
# should set duration as 1 hour
cal = AddToCalendar::URLs.new(start_datetime: Time.new(@next_month_year,@next_month_month,@next_month_day,@hour,30,00,0), title: @title, timezone: @timezone)
assert cal.office365_url == "https://outlook.office.com/calendar/0/deeplink/compose?path=/calendar/action/compose&rru=addevent" +
"&subject=Holly%27s%208th%20Birthday%21" +
"&startdt=#{@next_month_year}-#{@next_month_month}-#{@next_month_day}T#{@hour}:30:00Z" +
assert cal.office365_url == "https://outlook.office.com/calendar/0/action/compose?rru=addevent" +
"&subject=Holly%27s%208th%20Birthday%21" +
"&startdt=#{@next_month_year}-#{@next_month_month}-#{@next_month_day}T#{@hour}:30:00Z" +
"&enddt=#{@next_month_year}-#{@next_month_month}-#{@next_month_day}T#{@hour+1}:30:00Z"
end

Expand All @@ -63,9 +63,9 @@ def test_with_end_datetime
title: @title,
timezone: @timezone
)
assert cal.office365_url == "https://outlook.office.com/calendar/0/deeplink/compose?path=/calendar/action/compose&rru=addevent" +
"&subject=Holly%27s%208th%20Birthday%21" +
"&startdt=#{@next_month_year}-#{@next_month_month}-#{@next_month_day}T#{@hour}:30:00Z" +
assert cal.office365_url == "https://outlook.office.com/calendar/0/action/compose?rru=addevent" +
"&subject=Holly%27s%208th%20Birthday%21" +
"&startdt=#{@next_month_year}-#{@next_month_month}-#{@next_month_day}T#{@hour}:30:00Z" +
"&enddt=#{@next_month_year}-#{@next_month_month}-#{@next_month_day}T#{@hour+4}:00:00Z"
end

Expand All @@ -76,9 +76,9 @@ def test_with_end_datetime_crossing_over_midnight
title: @title,
timezone: @timezone
)
assert cal.office365_url == "https://outlook.office.com/calendar/0/deeplink/compose?path=/calendar/action/compose&rru=addevent" +
"&subject=Holly%27s%208th%20Birthday%21" +
"&startdt=#{@next_month_year}-#{@next_month_month}-#{@next_month_day}T#{@hour}:30:00Z" +
assert cal.office365_url == "https://outlook.office.com/calendar/0/action/compose?rru=addevent" +
"&subject=Holly%27s%208th%20Birthday%21" +
"&startdt=#{@next_month_year}-#{@next_month_month}-#{@next_month_day}T#{@hour}:30:00Z" +
"&enddt=#{@next_month_year_plus_one_day}-#{@next_month_month_plus_one_day}-#{@next_month_day_plus_one_day}T#{@hour+4}:00:00Z"
end

Expand Down Expand Up @@ -147,11 +147,11 @@ def test_with_all_attributes
location: @location,
description: @description,
)
assert cal.office365_url == "https://outlook.office.com/calendar/0/deeplink/compose?path=/calendar/action/compose&rru=addevent" +
"&subject=Holly%27s%208th%20Birthday%21" +
"&startdt=#{@next_month_year}-#{@next_month_month}-#{@next_month_day}T#{@hour}:30:00Z" +
"&enddt=#{@next_month_year}-#{@next_month_month}-#{@next_month_day}T#{@hour+4}:00:00Z" +
"&body=Come%20join%20us%20for%20lots%20of%20fun%20%26%20cake%21%3Cbr%3E%3Cbr%3Ehttps%3A%2F%2Fwww.example.com%2Fevent-details" +
assert cal.office365_url == "https://outlook.office.com/calendar/0/action/compose?rru=addevent" +
"&subject=Holly%27s%208th%20Birthday%21" +
"&startdt=#{@next_month_year}-#{@next_month_month}-#{@next_month_day}T#{@hour}:30:00Z" +
"&enddt=#{@next_month_year}-#{@next_month_month}-#{@next_month_day}T#{@hour+4}:00:00Z" +
"&body=Come%20join%20us%20for%20lots%20of%20fun%20%26%20cake%21%3Cbr%3E%3Cbr%3Ehttps%3A%2F%2Fwww.example.com%2Fevent-details" +
"&location=Flat%204%2C%20The%20Edge%2C%2038%20Smith-Dorrien%20St%2C%20London%2C%20N1%207GU"
end

Expand All @@ -168,9 +168,9 @@ def test_subject_converts_ampersand_to_and
timezone: @timezone
)

assert cal.office365_url == "https://outlook.office.com/calendar/0/deeplink/compose?path=/calendar/action/compose&rru=addevent" +
assert cal.office365_url == "https://outlook.office.com/calendar/0/action/compose?rru=addevent" +
"&subject=Birthday%20and%20Sleepover" +
"&startdt=#{@next_month_year}-#{@next_month_month}-#{@next_month_day}T#{@hour}:30:00Z" +
"&startdt=#{@next_month_year}-#{@next_month_month}-#{@next_month_day}T#{@hour}:30:00Z" +
"&enddt=#{@next_month_year}-#{@next_month_month}-#{@next_month_day}T#{@hour+1}:30:00Z"
end

Expand All @@ -182,12 +182,12 @@ def test_all_day_spans_single_day
title: @title,
timezone: @timezone
)
yahoo_url = "https://outlook.office.com/calendar/0/deeplink/compose?path=/calendar/action/compose&rru=addevent" +
"&subject=Holly%27s%208th%20Birthday%21" +
"&startdt=#{@next_month_year}-#{@next_month_month}-#{@next_month_day}" +
office365_url = "https://outlook.office.com/calendar/0/action/compose?rru=addevent" +
"&subject=Holly%27s%208th%20Birthday%21" +
"&startdt=#{@next_month_year}-#{@next_month_month}-#{@next_month_day}" +
"&enddt=#{@next_month_year_plus_one_day}-#{@next_month_month_plus_one_day}-#{@next_month_day_plus_one_day}" +
"&allday=true"
assert cal.office365_url == yahoo_url
assert cal.office365_url == office365_url
end

def test_all_day_spans_multiple_days
Expand All @@ -198,12 +198,12 @@ def test_all_day_spans_multiple_days
title: @title,
timezone: @timezone
)
yahoo_url = "https://outlook.office.com/calendar/0/deeplink/compose?path=/calendar/action/compose&rru=addevent" +
"&subject=Holly%27s%208th%20Birthday%21" +
"&startdt=#{@next_month_year}-#{@next_month_month}-#{@next_month_day}" +
office365_url = "https://outlook.office.com/calendar/0/action/compose?rru=addevent" +
"&subject=Holly%27s%208th%20Birthday%21" +
"&startdt=#{@next_month_year}-#{@next_month_month}-#{@next_month_day}" +
"&enddt=#{@next_month_year_plus_eight_days}-#{@next_month_month_plus_eight_days}-#{@next_month_day_plus_eight_days}" +
"&allday=true"
assert cal.office365_url == yahoo_url
assert cal.office365_url == office365_url
end

def test_all_day_without_end_date_is_single_day
Expand All @@ -213,12 +213,12 @@ def test_all_day_without_end_date_is_single_day
title: @title,
timezone: @timezone
)
yahoo_url = "https://outlook.office.com/calendar/0/deeplink/compose?path=/calendar/action/compose&rru=addevent" +
"&subject=Holly%27s%208th%20Birthday%21" +
"&startdt=#{@next_month_year}-#{@next_month_month}-#{@next_month_day}" +
office365_url = "https://outlook.office.com/calendar/0/action/compose?rru=addevent" +
"&subject=Holly%27s%208th%20Birthday%21" +
"&startdt=#{@next_month_year}-#{@next_month_month}-#{@next_month_day}" +
"&enddt=#{@next_month_year_plus_one_day}-#{@next_month_month_plus_one_day}-#{@next_month_day_plus_one_day}" +
"&allday=true"
assert cal.office365_url == yahoo_url
assert cal.office365_url == office365_url
end

def test_all_day_end_date_is_plus_one_from_end_date
Expand All @@ -229,12 +229,12 @@ def test_all_day_end_date_is_plus_one_from_end_date
title: @title,
timezone: @timezone
)
yahoo_url = "https://outlook.office.com/calendar/0/deeplink/compose?path=/calendar/action/compose&rru=addevent" +
"&subject=Holly%27s%208th%20Birthday%21" +
"&startdt=#{@next_month_year}-#{@next_month_month}-#{@next_month_day}" +
office365_url = "https://outlook.office.com/calendar/0/action/compose?rru=addevent" +
"&subject=Holly%27s%208th%20Birthday%21" +
"&startdt=#{@next_month_year}-#{@next_month_month}-#{@next_month_day}" +
"&enddt=#{@next_month_year_plus_one_day}-#{@next_month_month_plus_one_day}-#{@next_month_day_plus_one_day}" +
"&allday=true"
assert cal.office365_url == yahoo_url
assert cal.office365_url == office365_url
end

end

0 comments on commit f85bf30

Please sign in to comment.