Commit 75a161a9571af9e5282e6a621262b84a0bfff135
1 parent
03d1378f
Exists in
master
and in
1 other branch
added in tests, couple updates to make fields more clear
Showing
5 changed files
with
33 additions
and
7 deletions
Show diff stats
app/assets/images/campfire_goto.png
app/models/issue_tracker.rb
@@ -14,7 +14,7 @@ class IssueTracker | @@ -14,7 +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 :room_id, :type => String | 17 | + field :subdomain, :type => String |
18 | 18 | ||
19 | validate :check_params | 19 | validate :check_params |
20 | 20 |
app/models/issue_trackers/campfire_tracker.rb
1 | class IssueTrackers::CampfireTracker < IssueTracker | 1 | class IssueTrackers::CampfireTracker < IssueTracker |
2 | Label = "campfire" | 2 | Label = "campfire" |
3 | Fields = [ | 3 | Fields = [ |
4 | - [:account, { | 4 | + [:subdomain, { |
5 | :placeholder => "Campfire Subdomain" | 5 | :placeholder => "Campfire Subdomain" |
6 | }], | 6 | }], |
7 | [:api_token, { | 7 | [:api_token, { |
@@ -9,22 +9,22 @@ class IssueTrackers::CampfireTracker < IssueTracker | @@ -9,22 +9,22 @@ class IssueTrackers::CampfireTracker < IssueTracker | ||
9 | }], | 9 | }], |
10 | [:project_id, { | 10 | [:project_id, { |
11 | :placeholder => "Room ID", | 11 | :placeholder => "Room ID", |
12 | - :label => "Room ID", | 12 | + :label => "Room ID" |
13 | }], | 13 | }], |
14 | ] | 14 | ] |
15 | 15 | ||
16 | def check_params | 16 | def check_params |
17 | if Fields.detect {|f| self[f[0]].blank? } | 17 | if Fields.detect {|f| self[f[0]].blank? } |
18 | - errors.add :base, 'You must specify your Campfire subdomain, API token and Room ID' | 18 | + errors.add :base, 'You must specify your Campfire Subdomain, API token and Room ID' |
19 | end | 19 | end |
20 | end | 20 | end |
21 | 21 | ||
22 | def create_issue(problem, reported_by = nil) | 22 | def create_issue(problem, reported_by = nil) |
23 | # build the campfire client | 23 | # build the campfire client |
24 | - campy = Campy::Room.new(:account => account, :token => api_token, :room_id => project_id) | 24 | + campy = Campy::Room.new(:account => subdomain, :token => api_token, :room_id => project_id) |
25 | 25 | ||
26 | # post the issue to the campfire room | 26 | # post the issue to the campfire room |
27 | - campy.paste issue_title problem | 27 | + campy.paste "[errbit] http://#{Errbit::Config.host}/apps/#{problem.app.id.to_s} #{issue_title problem}" |
28 | 28 | ||
29 | # update the problem to say where it was sent | 29 | # update the problem to say where it was sent |
30 | problem.update_attributes( | 30 | problem.update_attributes( |
@@ -34,6 +34,6 @@ class IssueTrackers::CampfireTracker < IssueTracker | @@ -34,6 +34,6 @@ class IssueTrackers::CampfireTracker < IssueTracker | ||
34 | end | 34 | end |
35 | 35 | ||
36 | def url | 36 | def url |
37 | - "http://#{account}.campfirenow.com" | 37 | + "http://#{subdomain}.campfirenow.com" |
38 | end | 38 | end |
39 | end | 39 | end |
40 | \ 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,20 @@ | @@ -0,0 +1,20 @@ | ||
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::Room.stub(:new).and_return(tracker) | ||
11 | + tracker.stub(:paste) { true } | ||
12 | + | ||
13 | + # make sure campy received a message to send to campfire | ||
14 | + tracker.should_receive(:paste) | ||
15 | + | ||
16 | + # create the issue | ||
17 | + tracker.create_issue(notice.problem) | ||
18 | + end | ||
19 | +end | ||
20 | + |