Commit 500ddf4456c38cda38838d2c7db1eac64bdd49b4
1 parent
bcc32284
Exists in
master
Refs #918 respect ERRBIT_PORT in notifiers
Showing
6 changed files
with
4 additions
and
24 deletions
Show diff stats
app/models/notification_service.rb
@@ -66,8 +66,4 @@ class NotificationService | @@ -66,8 +66,4 @@ class NotificationService | ||
66 | def configured? | 66 | def configured? |
67 | api_token.present? | 67 | api_token.present? |
68 | end | 68 | end |
69 | - | ||
70 | - def problem_url(problem) | ||
71 | - "#{Errbit::Config.protocol}://#{Errbit::Config.host}/apps/#{problem.app.id}/problems/#{problem.id}" | ||
72 | - end | ||
73 | end | 69 | 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 | - "[#{problem.app.name}][#{problem.environment}][#{problem.where}]: #{problem.error_class} #{problem_url(problem)}" | 25 | + "[#{problem.app.name}][#{problem.environment}][#{problem.where}]: #{problem.error_class} #{problem.url}" |
26 | end | 26 | end |
27 | 27 | ||
28 | def create_notification(problem) | 28 | def create_notification(problem) |
app/models/notification_services/slack_service.rb
@@ -22,7 +22,7 @@ class NotificationServices::SlackService < NotificationService | @@ -22,7 +22,7 @@ class NotificationServices::SlackService < NotificationService | ||
22 | attachments: [ | 22 | attachments: [ |
23 | { | 23 | { |
24 | fallback: message_for_slack(problem), | 24 | fallback: message_for_slack(problem), |
25 | - pretext: "<#{problem_url(problem)}|Errbit - #{problem.app.name}: #{problem.error_class}>", | 25 | + pretext: "<#{problem.url}|Errbit - #{problem.app.name}: #{problem.error_class}>", |
26 | color: "#D00000", | 26 | color: "#D00000", |
27 | fields: [ | 27 | fields: [ |
28 | { | 28 | { |
app/models/notification_services/webhook_service.rb
@@ -15,9 +15,7 @@ class NotificationServices::WebhookService < NotificationService | @@ -15,9 +15,7 @@ class NotificationServices::WebhookService < NotificationService | ||
15 | 15 | ||
16 | def message_for_webhook(problem) | 16 | def message_for_webhook(problem) |
17 | { | 17 | { |
18 | - problem: { | ||
19 | - url: problem_url(problem) | ||
20 | - }.merge(problem.as_json).to_json | 18 | + problem: { url: problem.url }.merge(problem.as_json).to_json |
21 | } | 19 | } |
22 | end | 20 | end |
23 | 21 |
spec/models/notification_service/notification_service_spec.rb
@@ -1,14 +0,0 @@ | @@ -1,14 +0,0 @@ | ||
1 | -describe NotificationServices, type: 'model' do | ||
2 | - let(:notice) { Fabricate :notice } | ||
3 | - let(:notification_service) { Fabricate :notification_service, app: notice.app } | ||
4 | - let(:problem) { notice.problem } | ||
5 | - | ||
6 | - it "it should use http by default in #problem_url" do | ||
7 | - expect(notification_service.problem_url(problem)).to start_with 'http://' | ||
8 | - end | ||
9 | - | ||
10 | - it "it should use the protocol value specified in the config in #problem_url" do | ||
11 | - allow(Errbit::Config).to receive(:protocol).and_return('https') | ||
12 | - expect(notification_service.problem_url(problem)).to start_with 'https://' | ||
13 | - end | ||
14 | -end |
spec/models/notification_service/slack_service_spec.rb
@@ -10,7 +10,7 @@ describe NotificationServices::SlackService, type: 'model' do | @@ -10,7 +10,7 @@ describe NotificationServices::SlackService, type: 'model' do | ||
10 | attachments: [ | 10 | attachments: [ |
11 | { | 11 | { |
12 | fallback: notification_service.message_for_slack(problem), | 12 | fallback: notification_service.message_for_slack(problem), |
13 | - pretext: "<#{notification_service.problem_url(problem)}|Errbit - #{problem.app.name}: #{problem.error_class}>", | 13 | + pretext: "<#{problem.url}|Errbit - #{problem.app.name}: #{problem.error_class}>", |
14 | color: "#D00000", | 14 | color: "#D00000", |
15 | fields: [ | 15 | fields: [ |
16 | { | 16 | { |