Commit 22f034838248dd171a9b084dbda8c51efdd0829b
Exists in
master
and in
1 other branch
Merge pull request #340 from jozefvaclavik/master
Gitlab Integration - Spec test
Showing
1 changed file
with
15 additions
and
13 deletions
Show diff stats
spec/models/issue_trackers/gitlab_issues_tracker_spec.rb
... | ... | @@ -6,25 +6,27 @@ describe IssueTrackers::GitlabTracker do |
6 | 6 | tracker = Fabricate :gitlab_tracker, :app => notice.app |
7 | 7 | problem = notice.problem |
8 | 8 | |
9 | - number = 5 | |
10 | - @issue_link = "#{tracker.account}/api/v3/projects/#{tracker.project_id}/issues/#{number}/?private_token=#{tracker.api_token}" | |
11 | - body = <<EOF | |
12 | -{ | |
13 | - "title": "Title" | |
14 | -} | |
15 | -EOF | |
9 | + issue_id = 5 | |
10 | + note_id = 10 | |
11 | + issue_body = {:id => issue_id, :title => "[production][foo#bar] FooError: Too Much Bar", :description => "[See this exception on Errbit]"}.to_json | |
12 | + note_body = {:id => note_id, :body => "Example note body"}.to_json | |
16 | 13 | |
17 | - stub_request(:post, "#{tracker.account}/api/v3/projects/#{tracker.project_id}/issues/?private_token=#{tracker.api_token}"). | |
18 | - to_return(:status => 201, :headers => {'Location' => @issue_link}, :body => body ) | |
14 | + stub_request(:post, "#{tracker.account}/api/v3/projects/#{tracker.project_id}/issues?private_token=#{tracker.api_token}"). | |
15 | + with(:body => /.+/, :headers => {'Accept'=>'application/json'}). | |
16 | + to_return(:status => 200, :body => issue_body, :headers => {'Accept'=>'application/json'}) | |
17 | + | |
18 | + stub_request(:post, "#{tracker.account}/api/v3/projects/#{tracker.project_id}/issues/#{issue_id}/notes?private_token=#{tracker.api_token}"). | |
19 | + with(:body => /.+/, :headers => {'Accept'=>'application/json'}). | |
20 | + to_return(:status => 200, :body => note_body, :headers => {'Accept'=>'application/json'}) | |
19 | 21 | |
20 | 22 | problem.app.issue_tracker.create_issue(problem) |
21 | 23 | problem.reload |
22 | 24 | |
23 | - requested = have_requested(:post, "#{tracker.account}/api/v3/projects/#{tracker.project_id}/issues/?private_token=#{tracker.api_token}") | |
24 | - WebMock.should requested.with(:body => /[production][foo#bar] FooError: Too Much Bar/) | |
25 | - WebMock.should requested.with(:body => /See this exception on Errbit/) | |
25 | + 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'}) | |
26 | + requested_note = have_requested(:post, "#{tracker.account}/api/v3/projects/#{tracker.project_id}/issues/#{issue_id}/notes?private_token=#{tracker.api_token}") | |
27 | + WebMock.should requested_issue.with(:body => /%5Bproduction%5D%5Bfoo%23bar%5D%20FooError%3A%20Too%20Much%20Bar/) | |
28 | + WebMock.should requested_issue.with(:body => /See%20this%20exception%20on%20Errbit/) | |
26 | 29 | |
27 | - problem.issue_link.should == @issue_link | |
28 | 30 | end |
29 | 31 | end |
30 | 32 | ... | ... |