Commit d9de22106629da8041332494ccc7e72a9a1546db

Authored by Ryan Jones
1 parent 7852aad2
Exists in master and in 1 other branch production

removed camp tracker, added notifications

app/models/app.rb
... ... @@ -17,6 +17,8 @@ class App
17 17 embeds_many :watchers
18 18 embeds_many :deploys
19 19 embeds_one :issue_tracker
  20 + embeds_one :notification_service
  21 +
20 22 has_many :problems, :inverse_of => :app, :dependent => :destroy
21 23  
22 24 before_validation :generate_api_key, :on => :create
... ...
app/models/issue_trackers/campfire_tracker.rb
... ... @@ -1,39 +0,0 @@
1   -class IssueTrackers::CampfireTracker < IssueTracker
2   - Label = "campfire"
3   - Fields = [
4   - [:subdomain, {
5   - :placeholder => "Campfire Subdomain"
6   - }],
7   - [:api_token, {
8   - :placeholder => "API Token"
9   - }],
10   - [:project_id, {
11   - :placeholder => "Room ID",
12   - :label => "Room ID"
13   - }],
14   - ]
15   -
16   - def check_params
17   - if Fields.detect {|f| self[f[0]].blank? }
18   - errors.add :base, 'You must specify your Campfire Subdomain, API token and Room ID'
19   - end
20   - end
21   -
22   - def create_issue(problem, reported_by = nil)
23   - # build the campfire client
24   - campy = Campy::Room.new(:account => subdomain, :token => api_token, :room_id => project_id)
25   -
26   - # post the issue to the campfire room
27   - campy.speak "[errbit] http://#{Errbit::Config.host}/apps/#{problem.app.id.to_s} #{issue_title problem}"
28   -
29   - # update the problem to say where it was sent
30   - problem.update_attributes(
31   - :issue_link => url,
32   - :issue_type => Label
33   - )
34   - end
35   -
36   - def url
37   - "http://#{subdomain}.campfirenow.com"
38   - end
39   -end
40 0 \ No newline at end of file
app/models/notification_services/campfire_service.rb 0 → 100644
... ... @@ -0,0 +1,29 @@
  1 +class NotificationService::CampfireService < IssueTracker
  2 + Label = "campfire"
  3 + Fields = [
  4 + [:subdomain, {
  5 + :placeholder => "Campfire Subdomain"
  6 + }],
  7 + [:api_token, {
  8 + :placeholder => "API Token"
  9 + }],
  10 + [:room_id, {
  11 + :placeholder => "Room ID",
  12 + :label => "Room ID"
  13 + }],
  14 + ]
  15 +
  16 + def check_params
  17 + if Fields.detect {|f| self[f[0]].blank? }
  18 + errors.add :base, 'You must specify your Campfire Subdomain, API token and Room ID'
  19 + end
  20 + end
  21 +
  22 + def create_notification(problem)
  23 + # build the campfire client
  24 + campy = Campy::Room.new(:account => subdomain, :token => api_token, :room_id => room_id)
  25 +
  26 + # post the issue to the campfire room
  27 + campy.speak "[errbit] http://#{Errbit::Config.host}/apps/#{problem.app.id.to_s} #{notification_description problem}"
  28 + end
  29 +end
0 30 \ No newline at end of file
... ...