diff --git a/spec/models/issue_trackers/gitlab_issues_tracker_spec.rb b/spec/models/issue_trackers/gitlab_issues_tracker_spec.rb index 16fd688..7aad185 100644 --- a/spec/models/issue_trackers/gitlab_issues_tracker_spec.rb +++ b/spec/models/issue_trackers/gitlab_issues_tracker_spec.rb @@ -6,25 +6,27 @@ describe IssueTrackers::GitlabTracker do tracker = Fabricate :gitlab_tracker, :app => notice.app problem = notice.problem - number = 5 - @issue_link = "#{tracker.account}/api/v3/projects/#{tracker.project_id}/issues/#{number}/?private_token=#{tracker.api_token}" - body = < issue_id, :title => "[production][foo#bar] FooError: Too Much Bar", :description => "[See this exception on Errbit]"}.to_json + note_body = {:id => note_id, :body => "Example note body"}.to_json - stub_request(:post, "#{tracker.account}/api/v3/projects/#{tracker.project_id}/issues/?private_token=#{tracker.api_token}"). - to_return(:status => 201, :headers => {'Location' => @issue_link}, :body => body ) + stub_request(:post, "#{tracker.account}/api/v3/projects/#{tracker.project_id}/issues?private_token=#{tracker.api_token}"). + with(:body => /.+/, :headers => {'Accept'=>'application/json'}). + to_return(:status => 200, :body => issue_body, :headers => {'Accept'=>'application/json'}) + + stub_request(:post, "#{tracker.account}/api/v3/projects/#{tracker.project_id}/issues/#{issue_id}/notes?private_token=#{tracker.api_token}"). + with(:body => /.+/, :headers => {'Accept'=>'application/json'}). + to_return(:status => 200, :body => note_body, :headers => {'Accept'=>'application/json'}) problem.app.issue_tracker.create_issue(problem) problem.reload - requested = have_requested(:post, "#{tracker.account}/api/v3/projects/#{tracker.project_id}/issues/?private_token=#{tracker.api_token}") - WebMock.should requested.with(:body => /[production][foo#bar] FooError: Too Much Bar/) - WebMock.should requested.with(:body => /See this exception on Errbit/) + requested_issue = have_requested(:post, "#{tracker.account}/api/v3/projects/#{tracker.project_id}/issues?private_token=#{tracker.api_token}").with(:body => /.+/, :headers => {'Accept'=>'application/json'}) + requested_note = have_requested(:post, "#{tracker.account}/api/v3/projects/#{tracker.project_id}/issues/#{issue_id}/notes?private_token=#{tracker.api_token}") + WebMock.should requested_issue.with(:body => /%5Bproduction%5D%5Bfoo%23bar%5D%20FooError%3A%20Too%20Much%20Bar/) + WebMock.should requested_issue.with(:body => /See%20this%20exception%20on%20Errbit/) - problem.issue_link.should == @issue_link end end -- libgit2 0.21.2