Commit d9b711849c747a79289f66b2f4a179451858dcdf
Exists in
master
and in
1 other branch
Merge pull request #2 from RyanonRails/master
Added campfire functionality to errbit
Showing
10 changed files
with
74 additions
and
0 deletions
Show diff stats
Gemfile
@@ -33,6 +33,7 @@ gem 'kaminari' | @@ -33,6 +33,7 @@ gem 'kaminari' | ||
33 | gem 'rack-ssl-enforcer' | 33 | gem 'rack-ssl-enforcer' |
34 | gem 'fabrication', "~> 1.3.0" # Both for tests, and loading demo data | 34 | gem 'fabrication', "~> 1.3.0" # Both for tests, and loading demo data |
35 | gem 'rails_autolink', '~> 1.0.9' | 35 | gem 'rails_autolink', '~> 1.0.9' |
36 | +gem 'campy' | ||
36 | 37 | ||
37 | platform :ruby do | 38 | platform :ruby do |
38 | gem 'mongo', '= 1.3.1' | 39 | gem 'mongo', '= 1.3.1' |
Gemfile.lock
@@ -40,6 +40,8 @@ GEM | @@ -40,6 +40,8 @@ GEM | ||
40 | bson (1.3.1) | 40 | bson (1.3.1) |
41 | bson_ext (1.3.1) | 41 | bson_ext (1.3.1) |
42 | builder (3.0.0) | 42 | builder (3.0.0) |
43 | + campy (0.1.3) | ||
44 | + multi_json (~> 1.0) | ||
43 | capybara (1.1.2) | 45 | capybara (1.1.2) |
44 | mime-types (>= 1.16) | 46 | mime-types (>= 1.16) |
45 | nokogiri (>= 1.3.3) | 47 | nokogiri (>= 1.3.3) |
@@ -275,6 +277,7 @@ DEPENDENCIES | @@ -275,6 +277,7 @@ DEPENDENCIES | ||
275 | actionmailer_inline_css (~> 1.3.0) | 277 | actionmailer_inline_css (~> 1.3.0) |
276 | bson (= 1.3.1) | 278 | bson (= 1.3.1) |
277 | bson_ext (= 1.3.1) | 279 | bson_ext (= 1.3.1) |
280 | + campy | ||
278 | capybara | 281 | capybara |
279 | database_cleaner (~> 0.6.0) | 282 | database_cleaner (~> 0.6.0) |
280 | devise (~> 1.5.3) | 283 | devise (~> 1.5.3) |
3.19 KB
3.19 KB
2.8 KB
app/assets/stylesheets/issue_tracker_icons.css.erb
1 | /* Issue Tracker inactive, select, create and goto icons */ | 1 | /* Issue Tracker inactive, select, create and goto icons */ |
2 | <% trackers = IssueTracker.subclasses.map{|t| t.label } << 'none' %> | 2 | <% trackers = IssueTracker.subclasses.map{|t| t.label } << 'none' %> |
3 | + | ||
3 | <% trackers.each do |tracker| %> | 4 | <% trackers.each do |tracker| %> |
4 | div.issue_tracker.nested label.<%= tracker %> { | 5 | div.issue_tracker.nested label.<%= tracker %> { |
5 | background: url(/assets/<%= tracker %>_inactive.png) no-repeat; | 6 | background: url(/assets/<%= tracker %>_inactive.png) no-repeat; |
app/models/issue_tracker.rb
@@ -14,6 +14,7 @@ class IssueTracker | @@ -14,6 +14,7 @@ class IssueTracker | ||
14 | field :username, :type => String | 14 | field :username, :type => String |
15 | field :password, :type => String | 15 | field :password, :type => String |
16 | field :ticket_properties, :type => String | 16 | field :ticket_properties, :type => String |
17 | + field :subdomain, :type => String | ||
17 | 18 | ||
18 | validate :check_params | 19 | validate :check_params |
19 | 20 |
@@ -0,0 +1,39 @@ | @@ -0,0 +1,39 @@ | ||
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.paste "[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 => "Sent to Campfire", | ||
32 | + :issue_type => Label | ||
33 | + ) | ||
34 | + end | ||
35 | + | ||
36 | + def url | ||
37 | + "http://#{subdomain}.campfirenow.com" | ||
38 | + end | ||
39 | +end | ||
0 | \ No newline at end of file | 40 | \ No newline at end of file |
spec/fabricators/issue_tracker_fabricator.rb
@@ -25,3 +25,9 @@ Fabricator :github_issues_tracker, :from => :issue_tracker, :class_name => "Issu | @@ -25,3 +25,9 @@ Fabricator :github_issues_tracker, :from => :issue_tracker, :class_name => "Issu | ||
25 | username 'test_username' | 25 | username 'test_username' |
26 | end | 26 | end |
27 | 27 | ||
28 | +Fabricator :campfire_tracker, :from => :issue_tracker, :class_name => "IssueTrackers::CampfireTracker" do | ||
29 | + subdomain 'camproomname' | ||
30 | + api_token 1234567890 | ||
31 | + project_id 888555 | ||
32 | +end | ||
33 | + |
@@ -0,0 +1,23 @@ | @@ -0,0 +1,23 @@ | ||
1 | +require 'spec_helper' | ||
2 | + | ||
3 | +describe IssueTrackers::CampfireTracker do | ||
4 | + it "should post the error to campfire and display the error" do | ||
5 | + # setup fabrications | ||
6 | + notice = Fabricate :notice | ||
7 | + tracker = Fabricate :campfire_tracker | ||
8 | + | ||
9 | + # stub out campy methods | ||
10 | + campy = mock('CampfireTracker') | ||
11 | + Campy::Room.stub(:new).and_return(campy) | ||
12 | + campy.stub(:paste) { true } | ||
13 | + | ||
14 | + # expectations | ||
15 | + campy.should_receive(:paste).once.with(/errbit|production|foo#bar/).and_return(true) | ||
16 | + | ||
17 | + # create the issue | ||
18 | + tracker.create_issue(notice.problem) | ||
19 | + end | ||
20 | + | ||
21 | + | ||
22 | +end | ||
23 | + |