Commit f2da6ac6f656fbb559840538f02ae74957aeef3d
1 parent
e25d8eb4
Exists in
master
and in
1 other branch
Fix ical generation
The ical generation failed in some case like report on #343. Now the ical generation work. fix #343
Showing
3 changed files
with
21 additions
and
2 deletions
Show diff stats
app/helpers/application_helper.rb
... | ... | @@ -8,11 +8,11 @@ module ApplicationHelper |
8 | 8 | notices.each_with_index do |notice,idx| |
9 | 9 | cal.event do |event| |
10 | 10 | event.summary = "#{idx+1} #{notice.message.to_s}" |
11 | - event.description = notice.request['url'] | |
11 | + event.description = notice.url if notice.url | |
12 | 12 | event.dtstart = notice.created_at.utc |
13 | 13 | event.dtend = notice.created_at.utc + 60.minutes |
14 | 14 | event.organizer = notice.server_environment && notice.server_environment["hostname"] |
15 | - event.location = notice.server_environment && notice.server_environment["project-root"] | |
15 | + event.location = notice.project_root | |
16 | 16 | event.url = app_problem_url(:app_id => notice.problem.app.id, :id => notice.problem) |
17 | 17 | end |
18 | 18 | end | ... | ... |
app/models/notice.rb
... | ... | @@ -114,6 +114,15 @@ class Notice |
114 | 114 | app.notification_service.notify_at_notices.include?(0) || app.notification_service.notify_at_notices.include?(similar_count) |
115 | 115 | end |
116 | 116 | |
117 | + ## | |
118 | + # TODO: Move on decorator maybe | |
119 | + # | |
120 | + def project_root | |
121 | + if server_environment | |
122 | + server_environment['project-root'] || '' | |
123 | + end | |
124 | + end | |
125 | + | |
117 | 126 | protected |
118 | 127 | |
119 | 128 | def decrease_counter_cache |
... | ... | @@ -138,6 +147,7 @@ class Notice |
138 | 147 | end |
139 | 148 | end |
140 | 149 | |
150 | + | |
141 | 151 | def sanitize_hash(h) |
142 | 152 | h.recurse do |
143 | 153 | |h| h.inject({}) do |h,(k,v)| | ... | ... |
spec/helpers/application_helper_spec.rb
... | ... | @@ -10,3 +10,12 @@ require 'spec_helper' |
10 | 10 | # end |
11 | 11 | # end |
12 | 12 | # end |
13 | + | |
14 | +describe ApplicationHelper do | |
15 | + let(:notice) { Fabricate(:notice) } | |
16 | + describe "#generate_problem_ical" do | |
17 | + it 'return the ical format' do | |
18 | + helper.generate_problem_ical([notice]) | |
19 | + end | |
20 | + end | |
21 | +end | ... | ... |