@@ -40,7 +40,7 class ApiTest::AttachmentsTest < ActionController::IntegrationTest | |||
|
40 | 40 | context "/attachments/:id" do |
|
41 | 41 | context "GET" do |
|
42 | 42 | should "return the attachment" do |
|
43 |
get '/attachments/7.xml', {}, |
|
|
43 | get '/attachments/7.xml', {}, credentials('jsmith') | |
|
44 | 44 | assert_response :success |
|
45 | 45 | assert_equal 'application/xml', @response.content_type |
|
46 | 46 | assert_tag :tag => 'attachment', |
@@ -69,8 +69,7 class ApiTest::AttachmentsTest < ActionController::IntegrationTest | |||
|
69 | 69 | context "/attachments/download/:id/:filename" do |
|
70 | 70 | context "GET" do |
|
71 | 71 | should "return the attachment content" do |
|
72 | get '/attachments/download/7/archive.zip', | |
|
73 | {}, :authorization => credentials('jsmith') | |
|
72 | get '/attachments/download/7/archive.zip', {}, credentials('jsmith') | |
|
74 | 73 | assert_response :success |
|
75 | 74 | assert_equal 'application/octet-stream', @response.content_type |
|
76 | 75 | set_tmp_attachments_directory |
@@ -41,7 +41,7 class ApiTest::DisabledRestApiTest < ActionController::IntegrationTest | |||
|
41 | 41 | context "with a valid HTTP authentication" do |
|
42 | 42 | setup do |
|
43 | 43 | @user = User.generate_with_protected!(:password => 'my_password', :password_confirmation => 'my_password') |
|
44 |
get "/news.xml", nil, |
|
|
44 | get "/news.xml", nil, credentials(@user.login, 'my_password') | |
|
45 | 45 | end |
|
46 | 46 | |
|
47 | 47 | should_respond_with :unauthorized |
@@ -55,7 +55,7 class ApiTest::DisabledRestApiTest < ActionController::IntegrationTest | |||
|
55 | 55 | setup do |
|
56 | 56 | @user = User.generate_with_protected! |
|
57 | 57 | @token = Token.generate!(:user => @user, :action => 'api') |
|
58 |
get "/news.xml", nil, |
|
|
58 | get "/news.xml", nil, credentials(@token.value, 'X') | |
|
59 | 59 | end |
|
60 | 60 | |
|
61 | 61 | should_respond_with :unauthorized |
@@ -84,7 +84,7 class ApiTest::DisabledRestApiTest < ActionController::IntegrationTest | |||
|
84 | 84 | context "with a valid HTTP authentication" do |
|
85 | 85 | setup do |
|
86 | 86 | @user = User.generate_with_protected!(:password => 'my_password', :password_confirmation => 'my_password') |
|
87 |
get "/news.json", nil, |
|
|
87 | get "/news.json", nil, credentials(@user.login, 'my_password') | |
|
88 | 88 | end |
|
89 | 89 | |
|
90 | 90 | should_respond_with :unauthorized |
@@ -98,7 +98,7 class ApiTest::DisabledRestApiTest < ActionController::IntegrationTest | |||
|
98 | 98 | setup do |
|
99 | 99 | @user = User.generate_with_protected! |
|
100 | 100 | @token = Token.generate!(:user => @user, :action => 'api') |
|
101 |
get "/news.json", nil, |
|
|
101 | get "/news.json", nil, credentials(@token.value, 'DoesNotMatter') | |
|
102 | 102 | end |
|
103 | 103 | |
|
104 | 104 | should_respond_with :unauthorized |
@@ -30,7 +30,7 class ApiTest::IssueCategoriesTest < ActionController::IntegrationTest | |||
|
30 | 30 | |
|
31 | 31 | context "GET /projects/:project_id/issue_categories.xml" do |
|
32 | 32 | should "return issue categories" do |
|
33 |
get '/projects/1/issue_categories.xml', {}, |
|
|
33 | get '/projects/1/issue_categories.xml', {}, credentials('jsmith') | |
|
34 | 34 | assert_response :success |
|
35 | 35 | assert_equal 'application/xml', @response.content_type |
|
36 | 36 | assert_tag :tag => 'issue_categories', |
@@ -40,7 +40,7 class ApiTest::IssueCategoriesTest < ActionController::IntegrationTest | |||
|
40 | 40 | |
|
41 | 41 | context "GET /issue_categories/2.xml" do |
|
42 | 42 | should "return requested issue category" do |
|
43 |
get '/issue_categories/2.xml', {}, |
|
|
43 | get '/issue_categories/2.xml', {}, credentials('jsmith') | |
|
44 | 44 | assert_response :success |
|
45 | 45 | assert_equal 'application/xml', @response.content_type |
|
46 | 46 | assert_tag :tag => 'issue_category', |
@@ -51,7 +51,7 class ApiTest::IssueCategoriesTest < ActionController::IntegrationTest | |||
|
51 | 51 | context "POST /projects/:project_id/issue_categories.xml" do |
|
52 | 52 | should "return create issue category" do |
|
53 | 53 | assert_difference 'IssueCategory.count' do |
|
54 |
post '/projects/1/issue_categories.xml', {:issue_category => {:name => 'API'}}, |
|
|
54 | post '/projects/1/issue_categories.xml', {:issue_category => {:name => 'API'}}, credentials('jsmith') | |
|
55 | 55 | end |
|
56 | 56 | assert_response :created |
|
57 | 57 | assert_equal 'application/xml', @response.content_type |
@@ -64,7 +64,7 class ApiTest::IssueCategoriesTest < ActionController::IntegrationTest | |||
|
64 | 64 | context "with invalid parameters" do |
|
65 | 65 | should "return errors" do |
|
66 | 66 | assert_no_difference 'IssueCategory.count' do |
|
67 |
post '/projects/1/issue_categories.xml', {:issue_category => {:name => ''}}, |
|
|
67 | post '/projects/1/issue_categories.xml', {:issue_category => {:name => ''}}, credentials('jsmith') | |
|
68 | 68 | end |
|
69 | 69 | assert_response :unprocessable_entity |
|
70 | 70 | assert_equal 'application/xml', @response.content_type |
@@ -78,7 +78,7 class ApiTest::IssueCategoriesTest < ActionController::IntegrationTest | |||
|
78 | 78 | context "with valid parameters" do |
|
79 | 79 | should "update issue category" do |
|
80 | 80 | assert_no_difference 'IssueCategory.count' do |
|
81 |
put '/issue_categories/2.xml', {:issue_category => {:name => 'API Update'}}, |
|
|
81 | put '/issue_categories/2.xml', {:issue_category => {:name => 'API Update'}}, credentials('jsmith') | |
|
82 | 82 | end |
|
83 | 83 | assert_response :ok |
|
84 | 84 | assert_equal 'API Update', IssueCategory.find(2).name |
@@ -88,7 +88,7 class ApiTest::IssueCategoriesTest < ActionController::IntegrationTest | |||
|
88 | 88 | context "with invalid parameters" do |
|
89 | 89 | should "return errors" do |
|
90 | 90 | assert_no_difference 'IssueCategory.count' do |
|
91 |
put '/issue_categories/2.xml', {:issue_category => {:name => ''}}, |
|
|
91 | put '/issue_categories/2.xml', {:issue_category => {:name => ''}}, credentials('jsmith') | |
|
92 | 92 | end |
|
93 | 93 | assert_response :unprocessable_entity |
|
94 | 94 | assert_equal 'application/xml', @response.content_type |
@@ -101,7 +101,7 class ApiTest::IssueCategoriesTest < ActionController::IntegrationTest | |||
|
101 | 101 | context "DELETE /issue_categories/1.xml" do |
|
102 | 102 | should "destroy issue categories" do |
|
103 | 103 | assert_difference 'IssueCategory.count', -1 do |
|
104 |
delete '/issue_categories/1.xml', {}, |
|
|
104 | delete '/issue_categories/1.xml', {}, credentials('jsmith') | |
|
105 | 105 | end |
|
106 | 106 | assert_response :ok |
|
107 | 107 | assert_nil IssueCategory.find_by_id(1) |
@@ -113,7 +113,7 class ApiTest::IssueCategoriesTest < ActionController::IntegrationTest | |||
|
113 | 113 | |
|
114 | 114 | assert_difference 'IssueCategory.count', -1 do |
|
115 | 115 | assert_difference 'Issue.count(:conditions => {:category_id => 2})', 3 do |
|
116 |
delete '/issue_categories/1.xml', {:reassign_to_id => 2}, |
|
|
116 | delete '/issue_categories/1.xml', {:reassign_to_id => 2}, credentials('jsmith') | |
|
117 | 117 | end |
|
118 | 118 | end |
|
119 | 119 | assert_response :ok |
@@ -35,7 +35,7 class ApiTest::IssueRelationsTest < ActionController::IntegrationTest | |||
|
35 | 35 | context "/issues/:issue_id/relations" do |
|
36 | 36 | context "GET" do |
|
37 | 37 | should "return issue relations" do |
|
38 |
get '/issues/9/relations.xml', {}, |
|
|
38 | get '/issues/9/relations.xml', {}, credentials('jsmith') | |
|
39 | 39 | |
|
40 | 40 | assert_response :success |
|
41 | 41 | assert_equal 'application/xml', @response.content_type |
@@ -55,7 +55,7 class ApiTest::IssueRelationsTest < ActionController::IntegrationTest | |||
|
55 | 55 | context "POST" do |
|
56 | 56 | should "create a relation" do |
|
57 | 57 | assert_difference('IssueRelation.count') do |
|
58 |
post '/issues/2/relations.xml', {:relation => {:issue_to_id => 7, :relation_type => 'relates'}}, |
|
|
58 | post '/issues/2/relations.xml', {:relation => {:issue_to_id => 7, :relation_type => 'relates'}}, credentials('jsmith') | |
|
59 | 59 | end |
|
60 | 60 | |
|
61 | 61 | relation = IssueRelation.first(:order => 'id DESC') |
@@ -71,7 +71,7 class ApiTest::IssueRelationsTest < ActionController::IntegrationTest | |||
|
71 | 71 | context "with failure" do |
|
72 | 72 | should "return the errors" do |
|
73 | 73 | assert_no_difference('IssueRelation.count') do |
|
74 |
post '/issues/2/relations.xml', {:relation => {:issue_to_id => 7, :relation_type => 'foo'}}, |
|
|
74 | post '/issues/2/relations.xml', {:relation => {:issue_to_id => 7, :relation_type => 'foo'}}, credentials('jsmith') | |
|
75 | 75 | end |
|
76 | 76 | |
|
77 | 77 | assert_response :unprocessable_entity |
@@ -84,7 +84,7 class ApiTest::IssueRelationsTest < ActionController::IntegrationTest | |||
|
84 | 84 | context "/relations/:id" do |
|
85 | 85 | context "GET" do |
|
86 | 86 | should "return the relation" do |
|
87 |
get '/relations/2.xml', {}, |
|
|
87 | get '/relations/2.xml', {}, credentials('jsmith') | |
|
88 | 88 | |
|
89 | 89 | assert_response :success |
|
90 | 90 | assert_equal 'application/xml', @response.content_type |
@@ -95,7 +95,7 class ApiTest::IssueRelationsTest < ActionController::IntegrationTest | |||
|
95 | 95 | context "DELETE" do |
|
96 | 96 | should "delete the relation" do |
|
97 | 97 | assert_difference('IssueRelation.count', -1) do |
|
98 |
delete '/relations/2.xml', {}, |
|
|
98 | delete '/relations/2.xml', {}, credentials('jsmith') | |
|
99 | 99 | end |
|
100 | 100 | |
|
101 | 101 | assert_response :ok |
@@ -344,7 +344,7 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||
|
344 | 344 | |
|
345 | 345 | should "create an issue with the attributes" do |
|
346 | 346 | assert_difference('Issue.count') do |
|
347 |
post '/issues.xml', {:issue => {:project_id => 1, :subject => 'API test', :tracker_id => 2, :status_id => 3}}, |
|
|
347 | post '/issues.xml', {:issue => {:project_id => 1, :subject => 'API test', :tracker_id => 2, :status_id => 3}}, credentials('jsmith') | |
|
348 | 348 | end |
|
349 | 349 | |
|
350 | 350 | issue = Issue.first(:order => 'id DESC') |
@@ -362,7 +362,7 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||
|
362 | 362 | context "POST /issues.xml with failure" do |
|
363 | 363 | should "have an errors tag" do |
|
364 | 364 | assert_no_difference('Issue.count') do |
|
365 |
post '/issues.xml', {:issue => {:project_id => 1}}, |
|
|
365 | post '/issues.xml', {:issue => {:project_id => 1}}, credentials('jsmith') | |
|
366 | 366 | end |
|
367 | 367 | |
|
368 | 368 | assert_tag :errors, :child => {:tag => 'error', :content => "Subject can't be blank"} |
@@ -377,7 +377,7 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||
|
377 | 377 | |
|
378 | 378 | should "create an issue with the attributes" do |
|
379 | 379 | assert_difference('Issue.count') do |
|
380 |
post '/issues.json', {:issue => {:project_id => 1, :subject => 'API test', :tracker_id => 2, :status_id => 3}}, |
|
|
380 | post '/issues.json', {:issue => {:project_id => 1, :subject => 'API test', :tracker_id => 2, :status_id => 3}}, credentials('jsmith') | |
|
381 | 381 | end |
|
382 | 382 | |
|
383 | 383 | issue = Issue.first(:order => 'id DESC') |
@@ -392,7 +392,7 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||
|
392 | 392 | context "POST /issues.json with failure" do |
|
393 | 393 | should "have an errors element" do |
|
394 | 394 | assert_no_difference('Issue.count') do |
|
395 |
post '/issues.json', {:issue => {:project_id => 1}}, |
|
|
395 | post '/issues.json', {:issue => {:project_id => 1}}, credentials('jsmith') | |
|
396 | 396 | end |
|
397 | 397 | |
|
398 | 398 | json = ActiveSupport::JSON.decode(response.body) |
@@ -404,7 +404,6 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||
|
404 | 404 | context "PUT /issues/6.xml" do |
|
405 | 405 | setup do |
|
406 | 406 | @parameters = {:issue => {:subject => 'API update', :notes => 'A new note'}} |
|
407 | @headers = { :authorization => credentials('jsmith') } | |
|
408 | 407 | end |
|
409 | 408 | |
|
410 | 409 | should_allow_api_authentication(:put, |
@@ -414,25 +413,25 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||
|
414 | 413 | |
|
415 | 414 | should "not create a new issue" do |
|
416 | 415 | assert_no_difference('Issue.count') do |
|
417 |
put '/issues/6.xml', @parameters, |
|
|
416 | put '/issues/6.xml', @parameters, credentials('jsmith') | |
|
418 | 417 | end |
|
419 | 418 | end |
|
420 | 419 | |
|
421 | 420 | should "create a new journal" do |
|
422 | 421 | assert_difference('Journal.count') do |
|
423 |
put '/issues/6.xml', @parameters, |
|
|
422 | put '/issues/6.xml', @parameters, credentials('jsmith') | |
|
424 | 423 | end |
|
425 | 424 | end |
|
426 | 425 | |
|
427 | 426 | should "add the note to the journal" do |
|
428 |
put '/issues/6.xml', @parameters, |
|
|
427 | put '/issues/6.xml', @parameters, credentials('jsmith') | |
|
429 | 428 | |
|
430 | 429 | journal = Journal.last |
|
431 | 430 | assert_equal "A new note", journal.notes |
|
432 | 431 | end |
|
433 | 432 | |
|
434 | 433 | should "update the issue" do |
|
435 |
put '/issues/6.xml', @parameters, |
|
|
434 | put '/issues/6.xml', @parameters, credentials('jsmith') | |
|
436 | 435 | |
|
437 | 436 | issue = Issue.find(6) |
|
438 | 437 | assert_equal "API update", issue.subject |
@@ -443,12 +442,11 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||
|
443 | 442 | context "PUT /issues/3.xml with custom fields" do |
|
444 | 443 | setup do |
|
445 | 444 | @parameters = {:issue => {:custom_fields => [{'id' => '1', 'value' => 'PostgreSQL' }, {'id' => '2', 'value' => '150'}]}} |
|
446 | @headers = { :authorization => credentials('jsmith') } | |
|
447 | 445 | end |
|
448 | 446 | |
|
449 | 447 | should "update custom fields" do |
|
450 | 448 | assert_no_difference('Issue.count') do |
|
451 |
put '/issues/3.xml', @parameters, |
|
|
449 | put '/issues/3.xml', @parameters, credentials('jsmith') | |
|
452 | 450 | end |
|
453 | 451 | |
|
454 | 452 | issue = Issue.find(3) |
@@ -460,23 +458,22 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||
|
460 | 458 | context "PUT /issues/6.xml with failed update" do |
|
461 | 459 | setup do |
|
462 | 460 | @parameters = {:issue => {:subject => ''}} |
|
463 | @headers = { :authorization => credentials('jsmith') } | |
|
464 | 461 | end |
|
465 | 462 | |
|
466 | 463 | should "not create a new issue" do |
|
467 | 464 | assert_no_difference('Issue.count') do |
|
468 |
put '/issues/6.xml', @parameters, |
|
|
465 | put '/issues/6.xml', @parameters, credentials('jsmith') | |
|
469 | 466 | end |
|
470 | 467 | end |
|
471 | 468 | |
|
472 | 469 | should "not create a new journal" do |
|
473 | 470 | assert_no_difference('Journal.count') do |
|
474 |
put '/issues/6.xml', @parameters, |
|
|
471 | put '/issues/6.xml', @parameters, credentials('jsmith') | |
|
475 | 472 | end |
|
476 | 473 | end |
|
477 | 474 | |
|
478 | 475 | should "have an errors tag" do |
|
479 |
put '/issues/6.xml', @parameters, |
|
|
476 | put '/issues/6.xml', @parameters, credentials('jsmith') | |
|
480 | 477 | |
|
481 | 478 | assert_tag :errors, :child => {:tag => 'error', :content => "Subject can't be blank"} |
|
482 | 479 | end |
@@ -485,7 +482,6 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||
|
485 | 482 | context "PUT /issues/6.json" do |
|
486 | 483 | setup do |
|
487 | 484 | @parameters = {:issue => {:subject => 'API update', :notes => 'A new note'}} |
|
488 | @headers = { :authorization => credentials('jsmith') } | |
|
489 | 485 | end |
|
490 | 486 | |
|
491 | 487 | should_allow_api_authentication(:put, |
@@ -495,25 +491,25 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||
|
495 | 491 | |
|
496 | 492 | should "not create a new issue" do |
|
497 | 493 | assert_no_difference('Issue.count') do |
|
498 |
put '/issues/6.json', @parameters, |
|
|
494 | put '/issues/6.json', @parameters, credentials('jsmith') | |
|
499 | 495 | end |
|
500 | 496 | end |
|
501 | 497 | |
|
502 | 498 | should "create a new journal" do |
|
503 | 499 | assert_difference('Journal.count') do |
|
504 |
put '/issues/6.json', @parameters, |
|
|
500 | put '/issues/6.json', @parameters, credentials('jsmith') | |
|
505 | 501 | end |
|
506 | 502 | end |
|
507 | 503 | |
|
508 | 504 | should "add the note to the journal" do |
|
509 |
put '/issues/6.json', @parameters, |
|
|
505 | put '/issues/6.json', @parameters, credentials('jsmith') | |
|
510 | 506 | |
|
511 | 507 | journal = Journal.last |
|
512 | 508 | assert_equal "A new note", journal.notes |
|
513 | 509 | end |
|
514 | 510 | |
|
515 | 511 | should "update the issue" do |
|
516 |
put '/issues/6.json', @parameters, |
|
|
512 | put '/issues/6.json', @parameters, credentials('jsmith') | |
|
517 | 513 | |
|
518 | 514 | issue = Issue.find(6) |
|
519 | 515 | assert_equal "API update", issue.subject |
@@ -524,23 +520,22 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||
|
524 | 520 | context "PUT /issues/6.json with failed update" do |
|
525 | 521 | setup do |
|
526 | 522 | @parameters = {:issue => {:subject => ''}} |
|
527 | @headers = { :authorization => credentials('jsmith') } | |
|
528 | 523 | end |
|
529 | 524 | |
|
530 | 525 | should "not create a new issue" do |
|
531 | 526 | assert_no_difference('Issue.count') do |
|
532 |
put '/issues/6.json', @parameters, |
|
|
527 | put '/issues/6.json', @parameters, credentials('jsmith') | |
|
533 | 528 | end |
|
534 | 529 | end |
|
535 | 530 | |
|
536 | 531 | should "not create a new journal" do |
|
537 | 532 | assert_no_difference('Journal.count') do |
|
538 |
put '/issues/6.json', @parameters, |
|
|
533 | put '/issues/6.json', @parameters, credentials('jsmith') | |
|
539 | 534 | end |
|
540 | 535 | end |
|
541 | 536 | |
|
542 | 537 | should "have an errors attribute" do |
|
543 |
put '/issues/6.json', @parameters, |
|
|
538 | put '/issues/6.json', @parameters, credentials('jsmith') | |
|
544 | 539 | |
|
545 | 540 | json = ActiveSupport::JSON.decode(response.body) |
|
546 | 541 | assert json['errors'].include?(['subject', "can't be blank"]) |
@@ -555,7 +550,7 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||
|
555 | 550 | |
|
556 | 551 | should "delete the issue" do |
|
557 | 552 | assert_difference('Issue.count',-1) do |
|
558 |
delete '/issues/6.xml', {}, |
|
|
553 | delete '/issues/6.xml', {}, credentials('jsmith') | |
|
559 | 554 | end |
|
560 | 555 | |
|
561 | 556 | assert_nil Issue.find_by_id(6) |
@@ -570,7 +565,7 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||
|
570 | 565 | |
|
571 | 566 | should "delete the issue" do |
|
572 | 567 | assert_difference('Issue.count',-1) do |
|
573 |
delete '/issues/6.json', {}, |
|
|
568 | delete '/issues/6.json', {}, credentials('jsmith') | |
|
574 | 569 | end |
|
575 | 570 | |
|
576 | 571 | assert_nil Issue.find_by_id(6) |
@@ -152,7 +152,7 class ApiTest::ProjectsTest < ActionController::IntegrationTest | |||
|
152 | 152 | |
|
153 | 153 | should "create a project with the attributes" do |
|
154 | 154 | assert_difference('Project.count') do |
|
155 |
post '/projects.xml', @parameters, |
|
|
155 | post '/projects.xml', @parameters, credentials('admin') | |
|
156 | 156 | end |
|
157 | 157 | |
|
158 | 158 | project = Project.first(:order => 'id DESC') |
@@ -170,7 +170,7 class ApiTest::ProjectsTest < ActionController::IntegrationTest | |||
|
170 | 170 | @parameters[:project].merge!({:enabled_module_names => ['issue_tracking', 'news', 'time_tracking']}) |
|
171 | 171 | |
|
172 | 172 | assert_difference('Project.count') do |
|
173 |
post '/projects.xml', @parameters, |
|
|
173 | post '/projects.xml', @parameters, credentials('admin') | |
|
174 | 174 | end |
|
175 | 175 | |
|
176 | 176 | project = Project.first(:order => 'id DESC') |
@@ -181,7 +181,7 class ApiTest::ProjectsTest < ActionController::IntegrationTest | |||
|
181 | 181 | @parameters[:project].merge!({:tracker_ids => [1, 3]}) |
|
182 | 182 | |
|
183 | 183 | assert_difference('Project.count') do |
|
184 |
post '/projects.xml', @parameters, |
|
|
184 | post '/projects.xml', @parameters, credentials('admin') | |
|
185 | 185 | end |
|
186 | 186 | |
|
187 | 187 | project = Project.first(:order => 'id DESC') |
@@ -198,7 +198,7 class ApiTest::ProjectsTest < ActionController::IntegrationTest | |||
|
198 | 198 | context ".xml" do |
|
199 | 199 | should "return errors" do |
|
200 | 200 | assert_no_difference('Project.count') do |
|
201 |
post '/projects.xml', @parameters, |
|
|
201 | post '/projects.xml', @parameters, credentials('admin') | |
|
202 | 202 | end |
|
203 | 203 | |
|
204 | 204 | assert_response :unprocessable_entity |
@@ -223,7 +223,7 class ApiTest::ProjectsTest < ActionController::IntegrationTest | |||
|
223 | 223 | |
|
224 | 224 | should "update the project" do |
|
225 | 225 | assert_no_difference 'Project.count' do |
|
226 |
put '/projects/2.xml', @parameters, |
|
|
226 | put '/projects/2.xml', @parameters, credentials('jsmith') | |
|
227 | 227 | end |
|
228 | 228 | assert_response :ok |
|
229 | 229 | assert_equal 'application/xml', @response.content_type |
@@ -235,7 +235,7 class ApiTest::ProjectsTest < ActionController::IntegrationTest | |||
|
235 | 235 | @parameters[:project].merge!({:enabled_module_names => ['issue_tracking', 'news', 'time_tracking']}) |
|
236 | 236 | |
|
237 | 237 | assert_no_difference 'Project.count' do |
|
238 |
put '/projects/2.xml', @parameters, |
|
|
238 | put '/projects/2.xml', @parameters, credentials('admin') | |
|
239 | 239 | end |
|
240 | 240 | assert_response :ok |
|
241 | 241 | project = Project.find(2) |
@@ -246,7 +246,7 class ApiTest::ProjectsTest < ActionController::IntegrationTest | |||
|
246 | 246 | @parameters[:project].merge!({:tracker_ids => [1, 3]}) |
|
247 | 247 | |
|
248 | 248 | assert_no_difference 'Project.count' do |
|
249 |
put '/projects/2.xml', @parameters, |
|
|
249 | put '/projects/2.xml', @parameters, credentials('admin') | |
|
250 | 250 | end |
|
251 | 251 | assert_response :ok |
|
252 | 252 | project = Project.find(2) |
@@ -263,7 +263,7 class ApiTest::ProjectsTest < ActionController::IntegrationTest | |||
|
263 | 263 | context ".xml" do |
|
264 | 264 | should "return errors" do |
|
265 | 265 | assert_no_difference('Project.count') do |
|
266 |
put '/projects/2.xml', @parameters, |
|
|
266 | put '/projects/2.xml', @parameters, credentials('admin') | |
|
267 | 267 | end |
|
268 | 268 | |
|
269 | 269 | assert_response :unprocessable_entity |
@@ -283,7 +283,7 class ApiTest::ProjectsTest < ActionController::IntegrationTest | |||
|
283 | 283 | |
|
284 | 284 | should "delete the project" do |
|
285 | 285 | assert_difference('Project.count',-1) do |
|
286 |
delete '/projects/2.xml', {}, |
|
|
286 | delete '/projects/2.xml', {}, credentials('admin') | |
|
287 | 287 | end |
|
288 | 288 | assert_response :ok |
|
289 | 289 | assert_nil Project.find_by_id(2) |
@@ -34,7 +34,7 class ApiTest::TimeEntriesTest < ActionController::IntegrationTest | |||
|
34 | 34 | |
|
35 | 35 | context "GET /time_entries.xml" do |
|
36 | 36 | should "return time entries" do |
|
37 |
get '/time_entries.xml', {}, |
|
|
37 | get '/time_entries.xml', {}, credentials('jsmith') | |
|
38 | 38 | assert_response :success |
|
39 | 39 | assert_equal 'application/xml', @response.content_type |
|
40 | 40 | assert_tag :tag => 'time_entries', |
@@ -43,7 +43,7 class ApiTest::TimeEntriesTest < ActionController::IntegrationTest | |||
|
43 | 43 | |
|
44 | 44 | context "with limit" do |
|
45 | 45 | should "return limited results" do |
|
46 |
get '/time_entries.xml?limit=2', {}, |
|
|
46 | get '/time_entries.xml?limit=2', {}, credentials('jsmith') | |
|
47 | 47 | assert_response :success |
|
48 | 48 | assert_equal 'application/xml', @response.content_type |
|
49 | 49 | assert_tag :tag => 'time_entries', |
@@ -54,7 +54,7 class ApiTest::TimeEntriesTest < ActionController::IntegrationTest | |||
|
54 | 54 | |
|
55 | 55 | context "GET /time_entries/2.xml" do |
|
56 | 56 | should "return requested time entry" do |
|
57 |
get '/time_entries/2.xml', {}, |
|
|
57 | get '/time_entries/2.xml', {}, credentials('jsmith') | |
|
58 | 58 | assert_response :success |
|
59 | 59 | assert_equal 'application/xml', @response.content_type |
|
60 | 60 | assert_tag :tag => 'time_entry', |
@@ -66,7 +66,7 class ApiTest::TimeEntriesTest < ActionController::IntegrationTest | |||
|
66 | 66 | context "with issue_id" do |
|
67 | 67 | should "return create time entry" do |
|
68 | 68 | assert_difference 'TimeEntry.count' do |
|
69 |
post '/time_entries.xml', {:time_entry => {:issue_id => '1', :spent_on => '2010-12-02', :hours => '3.5', :activity_id => '11'}}, |
|
|
69 | post '/time_entries.xml', {:time_entry => {:issue_id => '1', :spent_on => '2010-12-02', :hours => '3.5', :activity_id => '11'}}, credentials('jsmith') | |
|
70 | 70 | end |
|
71 | 71 | assert_response :created |
|
72 | 72 | assert_equal 'application/xml', @response.content_type |
@@ -84,7 +84,7 class ApiTest::TimeEntriesTest < ActionController::IntegrationTest | |||
|
84 | 84 | context "with project_id" do |
|
85 | 85 | should "return create time entry" do |
|
86 | 86 | assert_difference 'TimeEntry.count' do |
|
87 |
post '/time_entries.xml', {:time_entry => {:project_id => '1', :spent_on => '2010-12-02', :hours => '3.5', :activity_id => '11'}}, |
|
|
87 | post '/time_entries.xml', {:time_entry => {:project_id => '1', :spent_on => '2010-12-02', :hours => '3.5', :activity_id => '11'}}, credentials('jsmith') | |
|
88 | 88 | end |
|
89 | 89 | assert_response :created |
|
90 | 90 | assert_equal 'application/xml', @response.content_type |
@@ -102,7 +102,7 class ApiTest::TimeEntriesTest < ActionController::IntegrationTest | |||
|
102 | 102 | context "with invalid parameters" do |
|
103 | 103 | should "return errors" do |
|
104 | 104 | assert_no_difference 'TimeEntry.count' do |
|
105 |
post '/time_entries.xml', {:time_entry => {:project_id => '1', :spent_on => '2010-12-02', :activity_id => '11'}}, |
|
|
105 | post '/time_entries.xml', {:time_entry => {:project_id => '1', :spent_on => '2010-12-02', :activity_id => '11'}}, credentials('jsmith') | |
|
106 | 106 | end |
|
107 | 107 | assert_response :unprocessable_entity |
|
108 | 108 | assert_equal 'application/xml', @response.content_type |
@@ -116,7 +116,7 class ApiTest::TimeEntriesTest < ActionController::IntegrationTest | |||
|
116 | 116 | context "with valid parameters" do |
|
117 | 117 | should "update time entry" do |
|
118 | 118 | assert_no_difference 'TimeEntry.count' do |
|
119 |
put '/time_entries/2.xml', {:time_entry => {:comments => 'API Update'}}, |
|
|
119 | put '/time_entries/2.xml', {:time_entry => {:comments => 'API Update'}}, credentials('jsmith') | |
|
120 | 120 | end |
|
121 | 121 | assert_response :ok |
|
122 | 122 | assert_equal 'API Update', TimeEntry.find(2).comments |
@@ -126,7 +126,7 class ApiTest::TimeEntriesTest < ActionController::IntegrationTest | |||
|
126 | 126 | context "with invalid parameters" do |
|
127 | 127 | should "return errors" do |
|
128 | 128 | assert_no_difference 'TimeEntry.count' do |
|
129 |
put '/time_entries/2.xml', {:time_entry => {:hours => '', :comments => 'API Update'}}, |
|
|
129 | put '/time_entries/2.xml', {:time_entry => {:hours => '', :comments => 'API Update'}}, credentials('jsmith') | |
|
130 | 130 | end |
|
131 | 131 | assert_response :unprocessable_entity |
|
132 | 132 | assert_equal 'application/xml', @response.content_type |
@@ -139,7 +139,7 class ApiTest::TimeEntriesTest < ActionController::IntegrationTest | |||
|
139 | 139 | context "DELETE /time_entries/2.xml" do |
|
140 | 140 | should "destroy time entry" do |
|
141 | 141 | assert_difference 'TimeEntry.count', -1 do |
|
142 |
delete '/time_entries/2.xml', {}, |
|
|
142 | delete '/time_entries/2.xml', {}, credentials('jsmith') | |
|
143 | 143 | end |
|
144 | 144 | assert_response :ok |
|
145 | 145 | assert_nil TimeEntry.find_by_id(2) |
@@ -60,7 +60,7 class ApiTest::UsersTest < ActionController::IntegrationTest | |||
|
60 | 60 | end |
|
61 | 61 | |
|
62 | 62 | should "return current user" do |
|
63 |
get '/users/current.xml', {}, |
|
|
63 | get '/users/current.xml', {}, credentials('jsmith') | |
|
64 | 64 | |
|
65 | 65 | assert_tag :tag => 'user', |
|
66 | 66 | :child => {:tag => 'id', :content => '2'} |
@@ -91,7 +91,7 class ApiTest::UsersTest < ActionController::IntegrationTest | |||
|
91 | 91 | |
|
92 | 92 | should "create a user with the attributes" do |
|
93 | 93 | assert_difference('User.count') do |
|
94 |
post '/users.xml', @parameters, |
|
|
94 | post '/users.xml', @parameters, credentials('admin') | |
|
95 | 95 | end |
|
96 | 96 | |
|
97 | 97 | user = User.first(:order => 'id DESC') |
@@ -120,7 +120,7 class ApiTest::UsersTest < ActionController::IntegrationTest | |||
|
120 | 120 | |
|
121 | 121 | should "create a user with the attributes" do |
|
122 | 122 | assert_difference('User.count') do |
|
123 |
post '/users.json', @parameters, |
|
|
123 | post '/users.json', @parameters, credentials('admin') | |
|
124 | 124 | end |
|
125 | 125 | |
|
126 | 126 | user = User.first(:order => 'id DESC') |
@@ -148,7 +148,7 class ApiTest::UsersTest < ActionController::IntegrationTest | |||
|
148 | 148 | context ".xml" do |
|
149 | 149 | should "return errors" do |
|
150 | 150 | assert_no_difference('User.count') do |
|
151 |
post '/users.xml', @parameters, |
|
|
151 | post '/users.xml', @parameters, credentials('admin') | |
|
152 | 152 | end |
|
153 | 153 | |
|
154 | 154 | assert_response :unprocessable_entity |
@@ -163,7 +163,7 class ApiTest::UsersTest < ActionController::IntegrationTest | |||
|
163 | 163 | context ".json" do |
|
164 | 164 | should "return errors" do |
|
165 | 165 | assert_no_difference('User.count') do |
|
166 |
post '/users.json', @parameters, |
|
|
166 | post '/users.json', @parameters, credentials('admin') | |
|
167 | 167 | end |
|
168 | 168 | |
|
169 | 169 | assert_response :unprocessable_entity |
@@ -199,7 +199,7 class ApiTest::UsersTest < ActionController::IntegrationTest | |||
|
199 | 199 | |
|
200 | 200 | should "update user with the attributes" do |
|
201 | 201 | assert_no_difference('User.count') do |
|
202 |
put '/users/2.xml', @parameters, |
|
|
202 | put '/users/2.xml', @parameters, credentials('admin') | |
|
203 | 203 | end |
|
204 | 204 | |
|
205 | 205 | user = User.find(2) |
@@ -224,7 +224,7 class ApiTest::UsersTest < ActionController::IntegrationTest | |||
|
224 | 224 | |
|
225 | 225 | should "update user with the attributes" do |
|
226 | 226 | assert_no_difference('User.count') do |
|
227 |
put '/users/2.json', @parameters, |
|
|
227 | put '/users/2.json', @parameters, credentials('admin') | |
|
228 | 228 | end |
|
229 | 229 | |
|
230 | 230 | user = User.find(2) |
@@ -252,7 +252,7 class ApiTest::UsersTest < ActionController::IntegrationTest | |||
|
252 | 252 | context ".xml" do |
|
253 | 253 | should "return errors" do |
|
254 | 254 | assert_no_difference('User.count') do |
|
255 |
put '/users/2.xml', @parameters, |
|
|
255 | put '/users/2.xml', @parameters, credentials('admin') | |
|
256 | 256 | end |
|
257 | 257 | |
|
258 | 258 | assert_response :unprocessable_entity |
@@ -267,7 +267,7 class ApiTest::UsersTest < ActionController::IntegrationTest | |||
|
267 | 267 | context ".json" do |
|
268 | 268 | should "return errors" do |
|
269 | 269 | assert_no_difference('User.count') do |
|
270 |
put '/users/2.json', @parameters, |
|
|
270 | put '/users/2.json', @parameters, credentials('admin') | |
|
271 | 271 | end |
|
272 | 272 | |
|
273 | 273 | assert_response :unprocessable_entity |
@@ -290,7 +290,7 class ApiTest::UsersTest < ActionController::IntegrationTest | |||
|
290 | 290 | |
|
291 | 291 | should "delete user" do |
|
292 | 292 | assert_difference('User.count', -1) do |
|
293 |
delete '/users/2.xml', {}, |
|
|
293 | delete '/users/2.xml', {}, credentials('admin') | |
|
294 | 294 | end |
|
295 | 295 | |
|
296 | 296 | assert_response :ok |
@@ -305,7 +305,7 class ApiTest::UsersTest < ActionController::IntegrationTest | |||
|
305 | 305 | |
|
306 | 306 | should "delete user" do |
|
307 | 307 | assert_difference('User.count', -1) do |
|
308 |
delete '/users/2.json', {}, |
|
|
308 | delete '/users/2.json', {}, credentials('admin') | |
|
309 | 309 | end |
|
310 | 310 | |
|
311 | 311 | assert_response :ok |
@@ -58,7 +58,7 class ApiTest::VersionsTest < ActionController::IntegrationTest | |||
|
58 | 58 | context "POST" do |
|
59 | 59 | should "create the version" do |
|
60 | 60 | assert_difference 'Version.count' do |
|
61 |
post '/projects/1/versions.xml', {:version => {:name => 'API test'}}, |
|
|
61 | post '/projects/1/versions.xml', {:version => {:name => 'API test'}}, credentials('jsmith') | |
|
62 | 62 | end |
|
63 | 63 | |
|
64 | 64 | version = Version.first(:order => 'id DESC') |
@@ -72,7 +72,7 class ApiTest::VersionsTest < ActionController::IntegrationTest | |||
|
72 | 72 | context "with failure" do |
|
73 | 73 | should "return the errors" do |
|
74 | 74 | assert_no_difference('Version.count') do |
|
75 |
post '/projects/1/versions.xml', {:version => {:name => ''}}, |
|
|
75 | post '/projects/1/versions.xml', {:version => {:name => ''}}, credentials('jsmith') | |
|
76 | 76 | end |
|
77 | 77 | |
|
78 | 78 | assert_response :unprocessable_entity |
@@ -103,7 +103,7 class ApiTest::VersionsTest < ActionController::IntegrationTest | |||
|
103 | 103 | |
|
104 | 104 | context "PUT" do |
|
105 | 105 | should "update the version" do |
|
106 |
put '/versions/2.xml', {:version => {:name => 'API update'}}, |
|
|
106 | put '/versions/2.xml', {:version => {:name => 'API update'}}, credentials('jsmith') | |
|
107 | 107 | |
|
108 | 108 | assert_response :ok |
|
109 | 109 | assert_equal 'API update', Version.find(2).name |
@@ -113,7 +113,7 class ApiTest::VersionsTest < ActionController::IntegrationTest | |||
|
113 | 113 | context "DELETE" do |
|
114 | 114 | should "destroy the version" do |
|
115 | 115 | assert_difference 'Version.count', -1 do |
|
116 |
delete '/versions/3.xml', {}, |
|
|
116 | delete '/versions/3.xml', {}, credentials('jsmith') | |
|
117 | 117 | end |
|
118 | 118 | |
|
119 | 119 | assert_response :ok |
@@ -63,7 +63,7 class ActiveSupport::TestCase | |||
|
63 | 63 | end |
|
64 | 64 | |
|
65 | 65 | def credentials(user, password=nil) |
|
66 | ActionController::HttpAuthentication::Basic.encode_credentials(user, password || user) | |
|
66 | {:authorization => ActionController::HttpAuthentication::Basic.encode_credentials(user, password || user)} | |
|
67 | 67 | end |
|
68 | 68 | |
|
69 | 69 | # Mock out a file |
@@ -244,7 +244,7 class ActiveSupport::TestCase | |||
|
244 | 244 | context "with a valid HTTP authentication" do |
|
245 | 245 | setup do |
|
246 | 246 | @user = User.generate_with_protected!(:password => 'my_password', :password_confirmation => 'my_password', :admin => true) # Admin so they can access the project |
|
247 |
send(http_method, url, parameters, |
|
|
247 | send(http_method, url, parameters, credentials(@user.login, 'my_password')) | |
|
248 | 248 | end |
|
249 | 249 | |
|
250 | 250 | should_respond_with success_code |
@@ -257,7 +257,7 class ActiveSupport::TestCase | |||
|
257 | 257 | context "with an invalid HTTP authentication" do |
|
258 | 258 | setup do |
|
259 | 259 | @user = User.generate_with_protected! |
|
260 |
send(http_method, url, parameters, |
|
|
260 | send(http_method, url, parameters, credentials(@user.login, 'wrong_password')) | |
|
261 | 261 | end |
|
262 | 262 | |
|
263 | 263 | should_respond_with failure_code |
@@ -269,7 +269,7 class ActiveSupport::TestCase | |||
|
269 | 269 | |
|
270 | 270 | context "without credentials" do |
|
271 | 271 | setup do |
|
272 |
send(http_method, url, parameters |
|
|
272 | send(http_method, url, parameters) | |
|
273 | 273 | end |
|
274 | 274 | |
|
275 | 275 | should_respond_with failure_code |
@@ -299,7 +299,7 class ActiveSupport::TestCase | |||
|
299 | 299 | setup do |
|
300 | 300 | @user = User.generate_with_protected!(:admin => true) |
|
301 | 301 | @token = Token.generate!(:user => @user, :action => 'api') |
|
302 |
send(http_method, url, parameters, |
|
|
302 | send(http_method, url, parameters, credentials(@token.value, 'X')) | |
|
303 | 303 | end |
|
304 | 304 | |
|
305 | 305 | should_respond_with success_code |
@@ -314,7 +314,7 class ActiveSupport::TestCase | |||
|
314 | 314 | setup do |
|
315 | 315 | @user = User.generate_with_protected! |
|
316 | 316 | @token = Token.generate!(:user => @user, :action => 'feeds') |
|
317 |
send(http_method, url, parameters, |
|
|
317 | send(http_method, url, parameters, credentials(@token.value, 'X')) | |
|
318 | 318 | end |
|
319 | 319 | |
|
320 | 320 | should_respond_with failure_code |
General Comments 0
You need to be logged in to leave comments.
Login now