Commit 5e0ed1f2e0bbaf080f477c710a697c281cdb27ef
1 parent
e51f7975
Exists in
master
and in
1 other branch
Minimal test for request to lighthouseapp.
Showing
8 changed files
with
46 additions
and
1 deletions
Show diff stats
Gemfile
Gemfile.lock
@@ -28,11 +28,13 @@ GEM | @@ -28,11 +28,13 @@ GEM | ||
28 | activemodel (= 3.0.5) | 28 | activemodel (= 3.0.5) |
29 | activesupport (= 3.0.5) | 29 | activesupport (= 3.0.5) |
30 | activesupport (3.0.5) | 30 | activesupport (3.0.5) |
31 | + addressable (2.2.4) | ||
31 | arel (2.0.9) | 32 | arel (2.0.9) |
32 | bcrypt-ruby (2.1.4) | 33 | bcrypt-ruby (2.1.4) |
33 | bson (1.2.4) | 34 | bson (1.2.4) |
34 | bson_ext (1.2.4) | 35 | bson_ext (1.2.4) |
35 | builder (2.1.2) | 36 | builder (2.1.2) |
37 | + crack (0.1.8) | ||
36 | database_cleaner (0.6.5) | 38 | database_cleaner (0.6.5) |
37 | devise (1.1.8) | 39 | devise (1.1.8) |
38 | bcrypt-ruby (~> 2.1.2) | 40 | bcrypt-ruby (~> 2.1.2) |
@@ -102,6 +104,9 @@ GEM | @@ -102,6 +104,9 @@ GEM | ||
102 | tzinfo (0.3.25) | 104 | tzinfo (0.3.25) |
103 | warden (1.0.3) | 105 | warden (1.0.3) |
104 | rack (>= 1.0.0) | 106 | rack (>= 1.0.0) |
107 | + webmock (1.6.2) | ||
108 | + addressable (>= 2.2.2) | ||
109 | + crack (>= 0.1.7) | ||
105 | will_paginate (3.0.pre2) | 110 | will_paginate (3.0.pre2) |
106 | 111 | ||
107 | PLATFORMS | 112 | PLATFORMS |
@@ -119,4 +124,5 @@ DEPENDENCIES | @@ -119,4 +124,5 @@ DEPENDENCIES | ||
119 | rails (= 3.0.5) | 124 | rails (= 3.0.5) |
120 | rspec (~> 2.5) | 125 | rspec (~> 2.5) |
121 | rspec-rails (~> 2.5) | 126 | rspec-rails (~> 2.5) |
127 | + webmock | ||
122 | will_paginate | 128 | will_paginate |
app/models/issue_tracker.rb
@@ -11,6 +11,17 @@ class IssueTracker | @@ -11,6 +11,17 @@ class IssueTracker | ||
11 | field :project_id, :type => String | 11 | field :project_id, :type => String |
12 | field :issue_tracker_type, :type => String, :default => 'lighthouseapp' | 12 | field :issue_tracker_type, :type => String, :default => 'lighthouseapp' |
13 | 13 | ||
14 | + def create_issue err | ||
15 | + Lighthouse.account = account | ||
16 | + Lighthouse.token = api_token | ||
17 | + | ||
18 | + ticket = Lighthouse::Ticket.new(:project_id => project_id) | ||
19 | + ticket.title = "[#{ err.where }] #{err.message.to_s.truncate(27)}" | ||
20 | + #ticket.body = err.backtrace.join("\n") | ||
21 | + ticket.tags << "errbit" | ||
22 | + ticket.save | ||
23 | + end | ||
24 | + | ||
14 | protected | 25 | protected |
15 | def check_lighthouseapp_params | 26 | def check_lighthouseapp_params |
16 | blank_flags = %w( api_token project_id account ).map {|m| self[m].blank? } | 27 | blank_flags = %w( api_token project_id account ).map {|m| self[m].blank? } |
spec/factories.rb
1 | Factory.sequence(:name) {|n| "John #{n} Doe"} | 1 | Factory.sequence(:name) {|n| "John #{n} Doe"} |
2 | +Factory.sequence(:word) {|n| "word#{n}"} | ||
2 | Factory.sequence(:app_name) {|n| "App ##{n}"} | 3 | Factory.sequence(:app_name) {|n| "App ##{n}"} |
3 | Factory.sequence(:email) {|n| "email#{n}@example.com"} | 4 | Factory.sequence(:email) {|n| "email#{n}@example.com"} |
4 | Factory.sequence(:user_email) {|n| "user.#{n}@example.com"} | 5 | Factory.sequence(:user_email) {|n| "user.#{n}@example.com"} |
spec/factories/app_factories.rb
@@ -25,4 +25,4 @@ Factory.define(:deploy) do |d| | @@ -25,4 +25,4 @@ Factory.define(:deploy) do |d| | ||
25 | d.repository 'git@github.com/jdpace/errbit.git' | 25 | d.repository 'git@github.com/jdpace/errbit.git' |
26 | d.environment 'production' | 26 | d.environment 'production' |
27 | d.revision ActiveSupport::SecureRandom.hex(10) | 27 | d.revision ActiveSupport::SecureRandom.hex(10) |
28 | -end | ||
29 | \ No newline at end of file | 28 | \ No newline at end of file |
29 | +end |
@@ -0,0 +1,7 @@ | @@ -0,0 +1,7 @@ | ||
1 | +Factory.define :lighthouseapp_tracker, :class => IssueTracker do |e| | ||
2 | + e.issue_tracker_type 'lighthouseapp' | ||
3 | + e.account { Factory.next :word } | ||
4 | + e.api_token { Factory.next :word } | ||
5 | + e.project_id { Factory.next :word } | ||
6 | + e.association :app, :factory => :app | ||
7 | +end | ||
0 | \ No newline at end of file | 8 | \ No newline at end of file |
@@ -0,0 +1,17 @@ | @@ -0,0 +1,17 @@ | ||
1 | +# encoding: utf-8 | ||
2 | +require 'spec_helper' | ||
3 | + | ||
4 | +describe IssueTracker do | ||
5 | + describe "#create_issue" do | ||
6 | + context "lighthouseapp tracker" do | ||
7 | + let(:tracker) { Factory :lighthouseapp_tracker } | ||
8 | + let(:err) { Factory :err } | ||
9 | + | ||
10 | + it "should make request to Lighthouseapp with err params" do | ||
11 | + stub_request(:post, "http://#{tracker.account}.lighthouseapp.com/projects/#{tracker.project_id}/tickets.xml") | ||
12 | + tracker.create_issue err | ||
13 | + WebMock.should have_requested(:post, "http://#{tracker.account}.lighthouseapp.com/projects/#{tracker.project_id}/tickets.xml") | ||
14 | + end | ||
15 | + end | ||
16 | + end | ||
17 | +end |
spec/spec_helper.rb
@@ -4,6 +4,7 @@ ENV["RAILS_ENV"] ||= 'test' | @@ -4,6 +4,7 @@ ENV["RAILS_ENV"] ||= 'test' | ||
4 | require File.expand_path("../../config/environment", __FILE__) | 4 | require File.expand_path("../../config/environment", __FILE__) |
5 | require 'rspec/rails' | 5 | require 'rspec/rails' |
6 | require 'database_cleaner' | 6 | require 'database_cleaner' |
7 | +require 'webmock/rspec' | ||
7 | 8 | ||
8 | # Requires supporting files with custom matchers and macros, etc, | 9 | # Requires supporting files with custom matchers and macros, etc, |
9 | # in ./support/ and its subdirectories. | 10 | # in ./support/ and its subdirectories. |
@@ -21,4 +22,5 @@ RSpec.configure do |config| | @@ -21,4 +22,5 @@ RSpec.configure do |config| | ||
21 | DatabaseCleaner[:mongoid].strategy = :truncation | 22 | DatabaseCleaner[:mongoid].strategy = :truncation |
22 | DatabaseCleaner.clean | 23 | DatabaseCleaner.clean |
23 | end | 24 | end |
25 | + config.include WebMock::API | ||
24 | end | 26 | end |
25 | \ No newline at end of file | 27 | \ No newline at end of file |