From cda23ec8ae7e71a60f01ce8e398dcc9092e499cc Mon Sep 17 00:00:00 2001 From: Nick Recobra Date: Sat, 2 Apr 2011 13:28:20 +0400 Subject: [PATCH] Failing specs for redmine issues tracker. --- spec/controllers/errs_controller_spec.rb | 32 ++++++++++++++++++++++++++++++++ spec/factories/issue_tracker_factories.rb | 5 +++++ 2 files changed, 37 insertions(+), 0 deletions(-) diff --git a/spec/controllers/errs_controller_spec.rb b/spec/controllers/errs_controller_spec.rb index 4163bd3..333e3e7 100644 --- a/spec/controllers/errs_controller_spec.rb +++ b/spec/controllers/errs_controller_spec.rb @@ -253,6 +253,38 @@ describe ErrsController do err.issue_link.should == @issue_link.sub(/\.xml$/, '') end end + + context "redmine tracker" do + let(:notice) { Factory :notice } + let(:tracker) { Factory :redmine_tracker, :app => notice.err.app } + let(:err) { notice.err } + + before(:each) do + number = 5 + @issue_link = "#{tracker.account}/projects/#{tracker.project_id}/issues/#{number}.xml" + body = "" + stub_request(:post, "#{tracker.account}/projects/#{tracker.project_id}/issues.xml").to_return(:status => 201, :headers => {'Location' => @issue_link}, :body => body ) + + post :create_issue, :app_id => err.app.id, :id => err.id + err.reload + end + + it "should make request to Lighthouseapp with err params" do + requested = have_requested(:post, "http://#{tracker.account}.lighthouseapp.com/projects/#{tracker.project_id}/tickets.xml") + WebMock.should requested.with(:headers => {'X-Lighthousetoken' => tracker.api_token}) + WebMock.should requested.with(:body => /errbit<\/tag>/) + WebMock.should requested.with(:body => /\[#{ err.environment }\]\[#{err.where}\] #{err.message.to_s.truncate(100)}<\/title>/) + WebMock.should requested.with(:body => /<body>.+<\/body>/m) + end + + it "should redirect to err page" do + response.should redirect_to( app_err_path(err.app, err) ) + end + + it "should create issue link for err" do + err.issue_link.should == @issue_link.sub(/\.xml$/, '') + end + end end context "absent issue tracker" do diff --git a/spec/factories/issue_tracker_factories.rb b/spec/factories/issue_tracker_factories.rb index b31eaae..a1bb160 100644 --- a/spec/factories/issue_tracker_factories.rb +++ b/spec/factories/issue_tracker_factories.rb @@ -4,4 +4,9 @@ Factory.define :lighthouseapp_tracker, :class => IssueTracker do |e| e.api_token { Factory.next :word } e.project_id { Factory.next :word } e.association :app, :factory => :app +end + +Factory.define :redmine_tracker, :parent => :lighthouseapp_tracker do |e| + e.issue_tracker_type 'redmine' + e.account { "http://#{Factory.next(:word)}.com" } end \ No newline at end of file -- libgit2 0.21.2