Commit 17709394a1e512f9cdddfd279ea7616594065853
Exists in
master
and in
1 other branch
Merge pull request #379 from luxflux/better-hubot-notification
Better hubot notification
Showing
3 changed files
with
7 additions
and
3 deletions
Show diff stats
app/models/notification_service.rb
@@ -8,7 +8,7 @@ class NotificationService | @@ -8,7 +8,7 @@ class NotificationService | ||
8 | field :api_token, :type => String | 8 | field :api_token, :type => String |
9 | field :subdomain, :type => String | 9 | field :subdomain, :type => String |
10 | field :sender_name, :type => String | 10 | field :sender_name, :type => String |
11 | - | 11 | + |
12 | embedded_in :app, :inverse_of => :notification_service | 12 | embedded_in :app, :inverse_of => :notification_service |
13 | 13 | ||
14 | validate :check_params | 14 | validate :check_params |
@@ -34,4 +34,8 @@ class NotificationService | @@ -34,4 +34,8 @@ class NotificationService | ||
34 | def configured? | 34 | def configured? |
35 | api_token.present? | 35 | api_token.present? |
36 | end | 36 | end |
37 | + | ||
38 | + def problem_url(problem) | ||
39 | + "http://#{Errbit::Config.host}/apps/#{problem.app.id}/problems/#{problem.id}" | ||
40 | + end | ||
37 | end | 41 | end |
app/models/notification_services/hubot_service.rb
@@ -22,7 +22,7 @@ class NotificationServices::HubotService < NotificationService | @@ -22,7 +22,7 @@ class NotificationServices::HubotService < NotificationService | ||
22 | end | 22 | end |
23 | 23 | ||
24 | def message_for_hubot(problem) | 24 | def message_for_hubot(problem) |
25 | - notification_description(problem) | 25 | + "#{notification_description(problem)} #{problem_url(problem)}" |
26 | end | 26 | end |
27 | 27 | ||
28 | def create_notification(problem) | 28 | def create_notification(problem) |
spec/models/notification_service/hubot_service_spec.rb
@@ -8,7 +8,7 @@ describe NotificationService::HubotService do | @@ -8,7 +8,7 @@ describe NotificationService::HubotService do | ||
8 | problem = notice.problem | 8 | problem = notice.problem |
9 | 9 | ||
10 | # faraday stubbing | 10 | # faraday stubbing |
11 | - HTTParty.should_receive(:post).with(notification_service.api_token, :body => {:message => '[production][foo#bar] FooError: Too Much Bar', :room => notification_service.room_id}).and_return(true) | 11 | + HTTParty.should_receive(:post).with(notification_service.api_token, :body => {:message => an_instance_of(String), :room => notification_service.room_id}).and_return(true) |
12 | 12 | ||
13 | notification_service.create_notification(problem) | 13 | notification_service.create_notification(problem) |
14 | end | 14 | end |