@@ -17,28 +17,28 @@ def setup
1717 @description = "Come join us for lots of fun & cake!"
1818
1919 @url_with_defaults_required = "data:text/calendar;charset=utf8,BEGIN:VCALENDAR%0AVERSION:2.0%0ABEGIN:VEVENT" +
20- "%0ADTSTART= #{ @next_month_year } #{ @next_month_month } #{ @next_month_day } T123000Z" +
21- "%0ADTEND= #{ @next_month_year } #{ @next_month_month } #{ @next_month_day } T133000Z" +
22- "%0ASUMMARY= Holly%27s%208th%20Birthday%21"
20+ "%0ADTSTART: #{ @next_month_year } #{ @next_month_month } #{ @next_month_day } T123000Z" +
21+ "%0ADTEND: #{ @next_month_year } #{ @next_month_month } #{ @next_month_day } T133000Z" +
22+ "%0ASUMMARY: Holly%27s%208th%20Birthday%21"
2323 @url_end = "%0AEND:VEVENT%0AEND:VCALENDAR"
2424
25- # "%0AUID= -20200610T123000Z-Holly%27s%208th%20Birthday%21%0AEND:VEVENT%0AEND:VCALENDAR"
25+ # "%0AUID: -20200610T123000Z-Holly%27s%208th%20Birthday%21%0AEND:VEVENT%0AEND:VCALENDAR"
2626 end
2727
2828 def test_with_only_required_attributes
2929 cal = AddToCalendar ::URLs . new ( start_datetime : Time . new ( @next_month_year , @next_month_month , @next_month_day , 13 , 30 , 00 , 0 ) , title : @title , timezone : @timezone )
30- uid = "%0AUID= -#{ cal . send ( :utc_datetime , cal . start_datetime ) } -#{ url_encode ( cal . title ) } "
30+ uid = "%0AUID: -#{ cal . send ( :utc_datetime , cal . start_datetime ) } -#{ url_encode ( cal . title ) } "
3131 assert cal . ical_url == @url_with_defaults_required + uid + @url_end
3232 end
3333
3434 def test_without_end_datetime
3535 # should set end as start + 1 hour
3636 cal = AddToCalendar ::URLs . new ( start_datetime : Time . new ( @next_month_year , @next_month_month , @next_month_day , 13 , 30 , 00 , 0 ) , title : @title , timezone : @timezone )
37- uid = "%0AUID= -#{ cal . send ( :utc_datetime , cal . start_datetime ) } -#{ url_encode ( cal . title ) } "
37+ uid = "%0AUID: -#{ cal . send ( :utc_datetime , cal . start_datetime ) } -#{ url_encode ( cal . title ) } "
3838 assert cal . ical_url == "data:text/calendar;charset=utf8,BEGIN:VCALENDAR%0AVERSION:2.0%0ABEGIN:VEVENT" +
39- "%0ADTSTART= #{ @next_month_year } #{ @next_month_month } #{ @next_month_day } T123000Z" +
40- "%0ADTEND= #{ @next_month_year } #{ @next_month_month } #{ @next_month_day } T133000Z" +
41- "%0ASUMMARY= Holly%27s%208th%20Birthday%21" +
39+ "%0ADTSTART: #{ @next_month_year } #{ @next_month_month } #{ @next_month_day } T123000Z" +
40+ "%0ADTEND: #{ @next_month_year } #{ @next_month_month } #{ @next_month_day } T133000Z" +
41+ "%0ASUMMARY: Holly%27s%208th%20Birthday%21" +
4242 uid +
4343 @url_end
4444 end
@@ -50,11 +50,11 @@ def test_with_end_datetime
5050 title : @title ,
5151 timezone : @timezone
5252 )
53- uid = "%0AUID= -#{ cal . send ( :utc_datetime , cal . start_datetime ) } -#{ url_encode ( cal . title ) } "
53+ uid = "%0AUID: -#{ cal . send ( :utc_datetime , cal . start_datetime ) } -#{ url_encode ( cal . title ) } "
5454 assert cal . ical_url == "data:text/calendar;charset=utf8,BEGIN:VCALENDAR%0AVERSION:2.0%0ABEGIN:VEVENT" +
55- "%0ADTSTART= #{ @next_month_year } #{ @next_month_month } #{ @next_month_day } T123000Z" +
56- "%0ADTEND= #{ @next_month_year } #{ @next_month_month } #{ @next_month_day } T160000Z" +
57- "%0ASUMMARY= Holly%27s%208th%20Birthday%21" +
55+ "%0ADTSTART: #{ @next_month_year } #{ @next_month_month } #{ @next_month_day } T123000Z" +
56+ "%0ADTEND: #{ @next_month_year } #{ @next_month_month } #{ @next_month_day } T160000Z" +
57+ "%0ASUMMARY: Holly%27s%208th%20Birthday%21" +
5858 uid +
5959 @url_end
6060 end
@@ -66,31 +66,39 @@ def test_with_end_datetime_after_midnight
6666 title : @title ,
6767 timezone : @timezone
6868 )
69- uid = "%0AUID= -#{ cal . send ( :utc_datetime , cal . start_datetime ) } -#{ url_encode ( cal . title ) } "
69+ uid = "%0AUID: -#{ cal . send ( :utc_datetime , cal . start_datetime ) } -#{ url_encode ( cal . title ) } "
7070 assert cal . ical_url == "data:text/calendar;charset=utf8,BEGIN:VCALENDAR%0AVERSION:2.0%0ABEGIN:VEVENT" +
71- "%0ADTSTART= #{ @next_month_year } #{ @next_month_month } #{ @next_month_day } T123000Z" +
72- "%0ADTEND= #{ @next_month_year } #{ @next_month_month } #{ @next_month_day . to_i +1 } T160000Z" +
73- "%0ASUMMARY= Holly%27s%208th%20Birthday%21" +
71+ "%0ADTSTART: #{ @next_month_year } #{ @next_month_month } #{ @next_month_day } T123000Z" +
72+ "%0ADTEND: #{ @next_month_year } #{ @next_month_month } #{ @next_month_day . to_i +1 } T160000Z" +
73+ "%0ASUMMARY: Holly%27s%208th%20Birthday%21" +
7474 uid +
7575 @url_end
7676 end
7777
7878 def test_with_location
7979 cal = AddToCalendar ::URLs . new ( start_datetime : Time . new ( @next_month_year , @next_month_month , @next_month_day , 13 , 30 , 00 , 0 ) , title : @title , timezone : @timezone , location : @location )
80- uid = "%0AUID= -#{ cal . send ( :utc_datetime , cal . start_datetime ) } -#{ url_encode ( cal . title ) } "
81- assert cal . ical_url == @url_with_defaults_required + "%0ALOCATION= Flat%204%2C%20The%20Edge%2C%2038%20Smith-Dorrien%20St%2C%20London%2C%20N1%207GU" + uid + @url_end
80+ uid = "%0AUID: -#{ cal . send ( :utc_datetime , cal . start_datetime ) } -#{ url_encode ( cal . title ) } "
81+ assert cal . ical_url == @url_with_defaults_required + "%0ALOCATION: Flat%204%2C%20The%20Edge%2C%2038%20Smith-Dorrien%20St%2C%20London%2C%20N1%207GU" + uid + @url_end
8282 end
8383
8484 def test_with_url_without_description
8585 cal = AddToCalendar ::URLs . new ( start_datetime : Time . new ( @next_month_year , @next_month_month , @next_month_day , 13 , 30 , 00 , 0 ) , title : @title , timezone : @timezone , url : @url )
86- uid = "%0AUID= -#{ url_encode ( cal . url ) } "
87- assert cal . ical_url == @url_with_defaults_required + "%0AURL= https%3A%2F%2Fwww.example.com%2Fevent-details%0ADESCRIPTION= https%3A%2F%2Fwww.example.com%2Fevent-details" + uid + @url_end
86+ uid = "%0AUID: -#{ url_encode ( cal . url ) } "
87+ assert cal . ical_url == @url_with_defaults_required + "%0AURL: https%3A%2F%2Fwww.example.com%2Fevent-details%0ADESCRIPTION: https%3A%2F%2Fwww.example.com%2Fevent-details" + uid + @url_end
8888 end
8989
9090 def test_with_url_and_description
9191 cal = AddToCalendar ::URLs . new ( start_datetime : Time . new ( @next_month_year , @next_month_month , @next_month_day , 13 , 30 , 00 , 0 ) , title : @title , timezone : @timezone , url : @url , description : @description )
92- uid = "%0AUID=-#{ url_encode ( cal . url ) } "
93- assert cal . ical_url == @url_with_defaults_required + "%0AURL=https%3A%2F%2Fwww.example.com%2Fevent-details%0ADESCRIPTION=Come%20join%20us%20for%20lots%20of%20fun%20%26%20cake%21\n \n https%3A%2F%2Fwww.example.com%2Fevent-details" + uid + @url_end
92+ uid = "%0AUID:-#{ url_encode ( cal . url ) } "
93+ assert cal . ical_url == @url_with_defaults_required + "%0AURL:https%3A%2F%2Fwww.example.com%2Fevent-details%0ADESCRIPTION:Come%20join%20us%20for%20lots%20of%20fun%20%26%20cake%21\\ n\\ nhttps%3A%2F%2Fwww.example.com%2Fevent-details" + uid + @url_end
94+ end
95+
96+ def test_description_with_newlines
97+ # final *.ics file must include `\n`
98+ # which means the string output must be `\\n`
99+ cal = AddToCalendar ::URLs . new ( start_datetime : Time . new ( @next_month_year , @next_month_month , @next_month_day , 13 , 30 , 00 , 0 ) , title : @title , timezone : @timezone , description : "Come join us for lots of fun & cake!\n \n Bring a towel!" )
100+ uid = "%0AUID:-#{ cal . send ( :utc_datetime , cal . start_datetime ) } -#{ url_encode ( cal . title ) } "
101+ assert cal . ical_url == @url_with_defaults_required + "%0ADESCRIPTION:Come%20join%20us%20for%20lots%20of%20fun%20%26%20cake%21\\ n\\ nBring%20a%20towel%21" + uid + @url_end
94102 end
95103
96104 def test_add_url_to_description_false_without_url
@@ -100,7 +108,7 @@ def test_add_url_to_description_false_without_url
100108 timezone : @timezone ,
101109 add_url_to_description : false ,
102110 )
103- uid = "%0AUID= -#{ cal . send ( :utc_datetime , cal . start_datetime ) } -#{ url_encode ( cal . title ) } "
111+ uid = "%0AUID: -#{ cal . send ( :utc_datetime , cal . start_datetime ) } -#{ url_encode ( cal . title ) } "
104112 assert cal . ical_url == @url_with_defaults_required + uid + @url_end
105113 end
106114
@@ -112,8 +120,8 @@ def test_add_url_to_description_false_with_url
112120 add_url_to_description : false ,
113121 url : @url ,
114122 )
115- uid = "%0AUID= -#{ url_encode ( cal . url ) } "
116- assert cal . ical_url == @url_with_defaults_required + "%0AURL= https%3A%2F%2Fwww.example.com%2Fevent-details" + uid + @url_end
123+ uid = "%0AUID: -#{ url_encode ( cal . url ) } "
124+ assert cal . ical_url == @url_with_defaults_required + "%0AURL: https%3A%2F%2Fwww.example.com%2Fevent-details" + uid + @url_end
117125 end
118126
119127 def test_with_all_attributes
@@ -126,13 +134,14 @@ def test_with_all_attributes
126134 location : @location ,
127135 description : @description ,
128136 )
129- uid = "%0AUID= -#{ url_encode ( cal . url ) } "
137+ uid = "%0AUID: -#{ url_encode ( cal . url ) } "
130138 assert cal . ical_url == "data:text/calendar;charset=utf8,BEGIN:VCALENDAR%0AVERSION:2.0%0ABEGIN:VEVENT" +
131- "%0ADTSTART=#{ @next_month_year } #{ @next_month_month } #{ @next_month_day } T123000Z" +
132- "%0ADTEND=#{ @next_month_year } #{ @next_month_month } #{ @next_month_day } T160000Z" +
133- "%0ASUMMARY=Holly%27s%208th%20Birthday%21" +
134- "%0AURL=https%3A%2F%2Fwww.example.com%2Fevent-details%0ADESCRIPTION=Come%20join%20us%20for%20lots%20of%20fun%20%26%20cake%21\n \n https%3A%2F%2Fwww.example.com%2Fevent-details" +
135- "%0ALOCATION=Flat%204%2C%20The%20Edge%2C%2038%20Smith-Dorrien%20St%2C%20London%2C%20N1%207GU" +
139+ "%0ADTSTART:#{ @next_month_year } #{ @next_month_month } #{ @next_month_day } T123000Z" +
140+ "%0ADTEND:#{ @next_month_year } #{ @next_month_month } #{ @next_month_day } T160000Z" +
141+ "%0ASUMMARY:Holly%27s%208th%20Birthday%21" +
142+ "%0AURL:https%3A%2F%2Fwww.example.com%2Fevent-details" +
143+ "%0ADESCRIPTION:Come%20join%20us%20for%20lots%20of%20fun%20%26%20cake%21\\ n\\ nhttps%3A%2F%2Fwww.example.com%2Fevent-details" +
144+ "%0ALOCATION:Flat%204%2C%20The%20Edge%2C%2038%20Smith-Dorrien%20St%2C%20London%2C%20N1%207GU" +
136145 uid +
137146 @url_end
138147 end
0 commit comments