Skip to content

Commit

Permalink
Fix ical generation
Browse files Browse the repository at this point in the history
The ical generation failed in some case like report on #343. Now the
ical generation work.

fix #343
  • Loading branch information
shingara committed May 30, 2013
1 parent e25d8eb commit f2da6ac
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/helpers/application_helper.rb
Expand Up @@ -8,11 +8,11 @@ def generate_problem_ical(notices)
notices.each_with_index do |notice,idx|
cal.event do |event|
event.summary = "#{idx+1} #{notice.message.to_s}"
event.description = notice.request['url']
event.description = notice.url if notice.url
event.dtstart = notice.created_at.utc
event.dtend = notice.created_at.utc + 60.minutes
event.organizer = notice.server_environment && notice.server_environment["hostname"]
event.location = notice.server_environment && notice.server_environment["project-root"]
event.location = notice.project_root
event.url = app_problem_url(:app_id => notice.problem.app.id, :id => notice.problem)
end
end
Expand Down
10 changes: 10 additions & 0 deletions app/models/notice.rb
Expand Up @@ -114,6 +114,15 @@ def should_notify?
app.notification_service.notify_at_notices.include?(0) || app.notification_service.notify_at_notices.include?(similar_count)
end

##
# TODO: Move on decorator maybe
#
def project_root
if server_environment
server_environment['project-root'] || ''
end
end

protected

def decrease_counter_cache
Expand All @@ -138,6 +147,7 @@ def sanitize
end
end


def sanitize_hash(h)
h.recurse do
|h| h.inject({}) do |h,(k,v)|
Expand Down
9 changes: 9 additions & 0 deletions spec/helpers/application_helper_spec.rb
Expand Up @@ -10,3 +10,12 @@
# end
# end
# end

describe ApplicationHelper do
let(:notice) { Fabricate(:notice) }
describe "#generate_problem_ical" do
it 'return the ical format' do
helper.generate_problem_ical([notice])
end
end
end

0 comments on commit f2da6ac

Please sign in to comment.