Commit 5d9e0d99e97f44818d3f7247f080cdbcfadae508

Authored by darkodosenovic
2 parents d9b71184 52f0f6d7
Exists in master and in 1 other branch production

Merge pull request #3 from amaabca/display_tweaks

More campfire integration
@@ -34,6 +34,7 @@ gem 'rack-ssl-enforcer' @@ -34,6 +34,7 @@ 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 gem 'campy'
  37 +gem 'heroku'
37 38
38 platform :ruby do 39 platform :ruby do
39 gem 'mongo', '= 1.3.1' 40 gem 'mongo', '= 1.3.1'
@@ -68,6 +68,7 @@ GEM @@ -68,6 +68,7 @@ GEM
68 rspec (~> 2.0) 68 rspec (~> 2.0)
69 erubis (2.7.0) 69 erubis (2.7.0)
70 eventmachine (0.12.10) 70 eventmachine (0.12.10)
  71 + excon (0.15.5)
71 execjs (1.4.0) 72 execjs (1.4.0)
72 multi_json (~> 1.0) 73 multi_json (~> 1.0)
73 fabrication (1.3.2) 74 fabrication (1.3.2)
@@ -81,6 +82,14 @@ GEM @@ -81,6 +82,14 @@ GEM
81 libxml-ruby (~> 2.0) 82 libxml-ruby (~> 2.0)
82 has_scope (0.5.1) 83 has_scope (0.5.1)
83 hashie (1.2.0) 84 hashie (1.2.0)
  85 + heroku (2.30.1)
  86 + heroku-api (~> 0.3.1)
  87 + launchy (>= 0.3.2)
  88 + netrc (~> 0.7.5)
  89 + rest-client (~> 1.6.1)
  90 + rubyzip
  91 + heroku-api (0.3.2)
  92 + excon (~> 0.15.5)
84 hike (1.2.1) 93 hike (1.2.1)
85 hoptoad_notifier (2.4.11) 94 hoptoad_notifier (2.4.11)
86 activesupport 95 activesupport
@@ -128,6 +137,7 @@ GEM @@ -128,6 +137,7 @@ GEM
128 railties (>= 3.0.0) 137 railties (>= 3.0.0)
129 multi_json (1.3.6) 138 multi_json (1.3.6)
130 multipart-post (1.1.5) 139 multipart-post (1.1.5)
  140 + netrc (0.7.5)
131 nokogiri (1.5.0) 141 nokogiri (1.5.0)
132 oa-core (0.3.2) 142 oa-core (0.3.2)
133 oauth2 (0.5.2) 143 oauth2 (0.5.2)
@@ -285,6 +295,7 @@ DEPENDENCIES @@ -285,6 +295,7 @@ DEPENDENCIES
285 execjs 295 execjs
286 fabrication (~> 1.3.0) 296 fabrication (~> 1.3.0)
287 haml 297 haml
  298 + heroku
288 hoptoad_notifier (~> 2.4) 299 hoptoad_notifier (~> 2.4)
289 htmlentities (~> 4.3.0) 300 htmlentities (~> 4.3.0)
290 inherited_resources 301 inherited_resources
app/models/issue_trackers/campfire_tracker.rb
@@ -24,11 +24,11 @@ class IssueTrackers::CampfireTracker < IssueTracker @@ -24,11 +24,11 @@ class IssueTrackers::CampfireTracker < IssueTracker
24 campy = Campy::Room.new(:account => subdomain, :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 "[errbit] http://#{Errbit::Config.host}/apps/#{problem.app.id.to_s} #{issue_title problem}" 27 + campy.speak "[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(
31 - :issue_link => "Sent to Campfire", 31 + :issue_link => url,
32 :issue_type => Label 32 :issue_type => Label
33 ) 33 )
34 end 34 end
app/models/notice_observer.rb
@@ -4,6 +4,11 @@ class NoticeObserver < Mongoid::Observer @@ -4,6 +4,11 @@ class NoticeObserver < Mongoid::Observer
4 def after_create notice 4 def after_create notice
5 return unless should_notify? notice 5 return unless should_notify? notice
6 6
  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)
  9 + notice.app.issue_tracker.create_issue(notice)
  10 + end
  11 +
7 Mailer.err_notification(notice).deliver 12 Mailer.err_notification(notice).deliver
8 end 13 end
9 14
@@ -15,5 +20,4 @@ class NoticeObserver < Mongoid::Observer @@ -15,5 +20,4 @@ class NoticeObserver < Mongoid::Observer
15 (Errbit::Config.per_app_email_at_notices && app.email_at_notices || Errbit::Config.email_at_notices).include?(notice.problem.notices_count) && 20 (Errbit::Config.per_app_email_at_notices && app.email_at_notices || Errbit::Config.email_at_notices).include?(notice.problem.notices_count) &&
16 app.notification_recipients.any? 21 app.notification_recipients.any?
17 end 22 end
18 -  
19 end 23 end
app/views/errs/_issue_tracker_links.html.haml
1 -- if @app.issue_tracker_configured? || current_user.github_account?  
2 - - if @problem.issue_link.present?  
3 - %span= link_to 'go to issue', @problem.issue_link, :class => "#{@problem.issue_type}_goto goto-issue"  
4 - = link_to 'unlink issue', unlink_issue_app_err_path(@app, @problem), :method => :delete, :data => { :confirm => "Unlink err issues?" }, :class => "unlink-issue"  
5 - - elsif @problem.issue_link == "pending"  
6 - %span.disabled= link_to 'creating...', '#', :class => "#{@problem.issue_type}_inactive create-issue"  
7 - = link_to 'retry', create_issue_app_err_path(@app, @problem), :method => :post  
8 - - else  
9 - - if @app.github_repo?  
10 - - if current_user.can_create_github_issues?  
11 - %span= link_to 'create issue', create_issue_app_err_path(@app, @problem, :tracker => 'user_github'), :method => :post, :class => "github_create create-issue"  
12 - - elsif @app.issue_tracker_configured? && @app.issue_tracker.is_a?(GithubIssuesTracker)  
13 - %span= link_to 'create issue', create_issue_app_err_path(@app, @problem), :method => :post, :class => "github_create create-issue"  
14 - - if @app.issue_tracker_configured? && !@app.issue_tracker.is_a?(GithubIssuesTracker)  
15 - %span= link_to 'create issue', create_issue_app_err_path(@app, @problem), :method => :post, :class => "#{@app.issue_tracker.label}_create create-issue" 1 +- unless @app.issue_tracker_configured? && @app.issue_tracker.is_a?(CampfireTracker)
  2 + - if @app.issue_tracker_configured? || current_user.github_account?
  3 + - if @problem.issue_link.present?
  4 + %span= link_to 'go to issue', @problem.issue_link, :class => "#{@problem.issue_type}_goto goto-issue"
  5 + = link_to 'unlink issue', unlink_issue_app_err_path(@app, @problem), :method => :delete, :data => { :confirm => "Unlink err issues?" }, :class => "unlink-issue"
  6 + - elsif @problem.issue_link == "pending"
  7 + %span.disabled= link_to 'creating...', '#', :class => "#{@problem.issue_type}_inactive create-issue"
  8 + = link_to 'retry', create_issue_app_err_path(@app, @problem), :method => :post
  9 + - else
  10 + - if @app.github_repo?
  11 + - if current_user.can_create_github_issues?
  12 + %span= link_to 'create issue', create_issue_app_err_path(@app, @problem, :tracker => 'user_github'), :method => :post, :class => "github_create create-issue"
  13 + - elsif @app.issue_tracker_configured? && @app.issue_tracker.is_a?(GithubIssuesTracker)
  14 + %span= link_to 'create issue', create_issue_app_err_path(@app, @problem), :method => :post, :class => "github_create create-issue"
  15 + - if @app.issue_tracker_configured? && !@app.issue_tracker.is_a?(GithubIssuesTracker)
  16 + %span= link_to 'create issue', create_issue_app_err_path(@app, @problem), :method => :post, :class => "#{@app.issue_tracker.label}_create create-issue"
lib/tasks/errbit/demo.rake
@@ -41,7 +41,7 @@ namespace :errbit do @@ -41,7 +41,7 @@ namespace :errbit do
41 end 41 end
42 42
43 errors.each do |error_template| 43 errors.each do |error_template|
44 - rand(34).times do 44 + rand(1).times do
45 45
46 error_report = error_template.reverse_merge({ 46 error_report = error_template.reverse_merge({
47 :error_class => "StandardError", 47 :error_class => "StandardError",
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