Commit 75a161a9571af9e5282e6a621262b84a0bfff135

Authored by Ryan Jones
1 parent 03d1378f
Exists in master and in 1 other branch production

added in tests, couple updates to make fields more clear

app/assets/images/campfire_goto.png

1.61 KB | W: | H:

3.19 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
app/models/issue_tracker.rb
... ... @@ -14,7 +14,7 @@ class IssueTracker
14 14 field :username, :type => String
15 15 field :password, :type => String
16 16 field :ticket_properties, :type => String
17   - field :room_id, :type => String
  17 + field :subdomain, :type => String
18 18  
19 19 validate :check_params
20 20  
... ...
app/models/issue_trackers/campfire_tracker.rb
1 1 class IssueTrackers::CampfireTracker < IssueTracker
2 2 Label = "campfire"
3 3 Fields = [
4   - [:account, {
  4 + [:subdomain, {
5 5 :placeholder => "Campfire Subdomain"
6 6 }],
7 7 [:api_token, {
... ... @@ -9,22 +9,22 @@ class IssueTrackers::CampfireTracker &lt; IssueTracker
9 9 }],
10 10 [:project_id, {
11 11 :placeholder => "Room ID",
12   - :label => "Room ID",
  12 + :label => "Room ID"
13 13 }],
14 14 ]
15 15  
16 16 def check_params
17 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 19 end
20 20 end
21 21  
22 22 def create_issue(problem, reported_by = nil)
23 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 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 29 # update the problem to say where it was sent
30 30 problem.update_attributes(
... ... @@ -34,6 +34,6 @@ class IssueTrackers::CampfireTracker &lt; IssueTracker
34 34 end
35 35  
36 36 def url
37   - "http://#{account}.campfirenow.com"
  37 + "http://#{subdomain}.campfirenow.com"
38 38 end
39 39 end
40 40 \ No newline at end of file
... ...
spec/fabricators/issue_tracker_fabricator.rb
... ... @@ -25,3 +25,9 @@ Fabricator :github_issues_tracker, :from =&gt; :issue_tracker, :class_name =&gt; &quot;Issu
25 25 username 'test_username'
26 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 +
... ...
spec/models/issue_trackers/campfire_tracker_spec.rb 0 → 100644
... ... @@ -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 +
... ...