Commit f1b5c18449bb5fb321b5fedde006906ff6517f37
1 parent
21a0f86e
Exists in
master
and in
1 other branch
Completed specs for Pivotal Tracker.
Showing
1 changed file
with
16 additions
and
11 deletions
Show diff stats
spec/controllers/errs_controller_spec.rb
| ... | ... | @@ -326,25 +326,30 @@ describe ErrsController do |
| 326 | 326 | |
| 327 | 327 | context "pivotal tracker" do |
| 328 | 328 | let(:notice) { Factory :notice } |
| 329 | - let(:tracker) { Factory :pivotal_tracker, :app => notice.err.app } | |
| 329 | + let(:tracker) { Factory :pivotal_tracker, :app => notice.err.app, :project_id => 10 } | |
| 330 | 330 | let(:err) { notice.err } |
| 331 | 331 | |
| 332 | 332 | before(:each) do |
| 333 | - pending | |
| 334 | - number = 5 | |
| 335 | - @issue_link = "#{tracker.account}/issues/#{number}.xml?project_id=#{tracker.project_id}" | |
| 336 | - body = "<issue><subject>my subject</subject><id>#{number}</id></issue>" | |
| 337 | - stub_request(:post, "#{tracker.account}/issues.xml").to_return(:status => 201, :headers => {'Location' => @issue_link}, :body => body ) | |
| 333 | + story_id = 5 | |
| 334 | + @issue_link = "https://www.pivotaltracker.com/story/show/#{story_id}" | |
| 335 | + | |
| 336 | + project_body = "<project><id>#{tracker.project_id}</id><name>TestProject</name></project>" | |
| 337 | + stub_request(:get, "https://www.pivotaltracker.com/services/v3/projects/#{tracker.project_id}"). | |
| 338 | + to_return(:status => 200, :headers => {'Location' => @issue_link}, :body => project_body ) | |
| 339 | + | |
| 340 | + story_body = "<story><name>Test Story</name><id>#{story_id}</id></story>" | |
| 341 | + stub_request(:post, "https://www.pivotaltracker.com/services/v3/projects/#{tracker.project_id}/stories"). | |
| 342 | + to_return(:status => 201, :headers => {'Location' => @issue_link}, :body => story_body ) | |
| 338 | 343 | |
| 339 | 344 | post :create_issue, :app_id => err.app.id, :id => err.id |
| 340 | 345 | err.reload |
| 341 | 346 | end |
| 342 | 347 | |
| 343 | 348 | it "should make request to Pivotal Tracker with err params" do |
| 344 | - requested = have_requested(:post, "#{tracker.account}/issues.xml") | |
| 345 | - WebMock.should requested.with(:headers => {'X-Redmine-API-Key' => tracker.api_token}) | |
| 346 | - WebMock.should requested.with(:body => /<project-id>#{tracker.project_id}<\/project-id>/) | |
| 347 | - WebMock.should requested.with(:body => /<subject>\[#{ err.environment }\]\[#{err.where}\] #{err.message.to_s.truncate(100)}<\/subject>/) | |
| 349 | + requested = have_requested(:post, "https://www.pivotaltracker.com/services/v3/projects/#{tracker.project_id}/stories") | |
| 350 | + WebMock.should requested.with(:headers => {'X-Trackertoken' => tracker.api_token}) | |
| 351 | + WebMock.should requested.with(:body => /See this exception on Errbit/) | |
| 352 | + WebMock.should requested.with(:body => /<name>\[#{ err.environment }\]\[#{err.where}\] #{err.message.to_s.truncate(100)}<\/name>/) | |
| 348 | 353 | WebMock.should requested.with(:body => /<description>.+<\/description>/m) |
| 349 | 354 | end |
| 350 | 355 | |
| ... | ... | @@ -353,7 +358,7 @@ describe ErrsController do |
| 353 | 358 | end |
| 354 | 359 | |
| 355 | 360 | it "should create issue link for err" do |
| 356 | - err.issue_link.should == @issue_link.sub(/\.xml/, '') | |
| 361 | + err.issue_link.should == @issue_link | |
| 357 | 362 | end |
| 358 | 363 | end |
| 359 | 364 | ... | ... |