Commit 52f0f6d735ee4f2c20fb2a8666b625593e31e38c
1 parent
bff5deed
Exists in
master
and in
1 other branch
updated tests
Showing
4 changed files
with
33 additions
and
5 deletions
Show diff stats
app/models/notice_observer.rb
@@ -6,7 +6,7 @@ class NoticeObserver < Mongoid::Observer | @@ -6,7 +6,7 @@ class NoticeObserver < Mongoid::Observer | ||
6 | 6 | ||
7 | # if the app has the campfire tracker, post into the chat | 7 | # if the app has the campfire tracker, post into the chat |
8 | if !notice.app.issue_tracker.nil? && notice.app.issue_tracker.is_a?(CampfireTracker) | 8 | if !notice.app.issue_tracker.nil? && notice.app.issue_tracker.is_a?(CampfireTracker) |
9 | - app.issue_tracker.create_issue(notice) | 9 | + notice.app.issue_tracker.create_issue(notice) |
10 | end | 10 | end |
11 | 11 | ||
12 | Mailer.err_notification(notice).deliver | 12 | Mailer.err_notification(notice).deliver |
spec/controllers/errs_controller_spec.rb
@@ -188,6 +188,14 @@ describe ErrsController do | @@ -188,6 +188,14 @@ describe ErrsController do | ||
188 | response.body.should_not button_matcher | 188 | response.body.should_not button_matcher |
189 | end | 189 | end |
190 | 190 | ||
191 | + it "should not exist for err's app with campfire" do | ||
192 | + tracker = Fabricate(:campfire_tracker) | ||
193 | + err = Fabricate(:err, :problem => Fabricate(:problem, :app => tracker.app)) | ||
194 | + get :show, :app_id => err.app.id, :id => err.problem.id | ||
195 | + | ||
196 | + response.body.should_not button_matcher | ||
197 | + end | ||
198 | + | ||
191 | it "should exist for err's app with issue tracker" do | 199 | it "should exist for err's app with issue tracker" do |
192 | tracker = Fabricate(:lighthouse_tracker) | 200 | tracker = Fabricate(:lighthouse_tracker) |
193 | err = Fabricate(:err, :problem => Fabricate(:problem, :app => tracker.app)) | 201 | err = Fabricate(:err, :problem => Fabricate(:problem, :app => tracker.app)) |
spec/models/issue_trackers/campfire_tracker_spec.rb
@@ -9,15 +9,13 @@ describe IssueTrackers::CampfireTracker do | @@ -9,15 +9,13 @@ describe IssueTrackers::CampfireTracker do | ||
9 | # stub out campy methods | 9 | # stub out campy methods |
10 | campy = mock('CampfireTracker') | 10 | campy = mock('CampfireTracker') |
11 | Campy::Room.stub(:new).and_return(campy) | 11 | Campy::Room.stub(:new).and_return(campy) |
12 | - campy.stub(:paste) { true } | 12 | + campy.stub(:speak) { true } |
13 | 13 | ||
14 | # expectations | 14 | # expectations |
15 | - campy.should_receive(:paste).once.with(/errbit|production|foo#bar/).and_return(true) | 15 | + campy.should_receive(:speak).once.with(/errbit|production|foo#bar/).and_return(true) |
16 | 16 | ||
17 | # create the issue | 17 | # create the issue |
18 | tracker.create_issue(notice.problem) | 18 | tracker.create_issue(notice.problem) |
19 | end | 19 | end |
20 | - | ||
21 | - | ||
22 | end | 20 | end |
23 | 21 |
spec/models/notice_observer_spec.rb
@@ -43,4 +43,26 @@ describe NoticeObserver do | @@ -43,4 +43,26 @@ describe NoticeObserver do | ||
43 | Fabricate(:notice, :err => @err) | 43 | Fabricate(:notice, :err => @err) |
44 | end | 44 | end |
45 | end | 45 | end |
46 | + | ||
47 | + describe "notifications for campfire" do | ||
48 | + | ||
49 | + before do | ||
50 | + Errbit::Config.per_app_email_at_notices = true | ||
51 | + @app = Fabricate(:app_with_watcher, :email_at_notices => [1], :issue_tracker => Fabricate(:campfire_tracker)) | ||
52 | + @err = Fabricate(:err, :problem => Fabricate(:problem, :app => @app, :notices_count => 100)) | ||
53 | + end | ||
54 | + | ||
55 | + after do | ||
56 | + Errbit::Config.per_app_email_at_notices = false | ||
57 | + end | ||
58 | + | ||
59 | + it "should create a campfire issue" do | ||
60 | + @err.problem.stub(:notices_count).and_return(1) | ||
61 | + @app.issue_tracker.stub!(:create_issue).and_return(true) | ||
62 | + @app.issue_tracker.should_receive(:create_issue) | ||
63 | + | ||
64 | + Fabricate(:notice, :err => @err) | ||
65 | + end | ||
66 | + end | ||
67 | + | ||
46 | end | 68 | end |