@@ -114,7 +114,8 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||
|
114 | 114 | :children => {:count => 1}, |
|
115 | 115 | :child => { |
|
116 | 116 | :tag => 'relation', |
|
117 |
:attributes => {:id => '2', :issue_id => '2', :issue_to_id => '3', |
|
|
117 | :attributes => {:id => '2', :issue_id => '2', :issue_to_id => '3', | |
|
118 | :relation_type => 'relates'} | |
|
118 | 119 | } |
|
119 | 120 | assert_tag 'relations', |
|
120 | 121 | :parent => {:tag => 'issue', :child => {:tag => 'id', :content => '1'}}, |
@@ -134,12 +135,12 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||
|
134 | 135 | |
|
135 | 136 | context "with custom field filter" do |
|
136 | 137 | should "show only issues with the custom field value" do |
|
137 | get '/issues.xml', { :set_filter => 1, :f => ['cf_1'], :op => {:cf_1 => '='}, :v => {:cf_1 => ['MySQL']}} | |
|
138 | ||
|
138 | get '/issues.xml', | |
|
139 | {:set_filter => 1, :f => ['cf_1'], :op => {:cf_1 => '='}, | |
|
140 | :v => {:cf_1 => ['MySQL']}} | |
|
139 | 141 | expected_ids = Issue.visible.all( |
|
140 | 142 | :include => :custom_values, |
|
141 | 143 | :conditions => {:custom_values => {:custom_field_id => 1, :value => 'MySQL'}}).map(&:id) |
|
142 | ||
|
143 | 144 | assert_select 'issues > issue > id', :count => expected_ids.count do |ids| |
|
144 | 145 | ids.each { |id| assert expected_ids.delete(id.children.first.content.to_i) } |
|
145 | 146 | end |
@@ -388,9 +389,21 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||
|
388 | 389 | |
|
389 | 390 | context "with subtasks" do |
|
390 | 391 | setup do |
|
391 | @c1 = Issue.create!(:status_id => 1, :subject => "child c1", :tracker_id => 1, :project_id => 1, :author_id => 1, :parent_issue_id => 1) | |
|
392 | @c2 = Issue.create!(:status_id => 1, :subject => "child c2", :tracker_id => 1, :project_id => 1, :author_id => 1, :parent_issue_id => 1) | |
|
393 |
|
|
|
392 | @c1 = Issue.create!( | |
|
393 | :status_id => 1, :subject => "child c1", | |
|
394 | :tracker_id => 1, :project_id => 1, :author_id => 1, | |
|
395 | :parent_issue_id => 1 | |
|
396 | ) | |
|
397 | @c2 = Issue.create!( | |
|
398 | :status_id => 1, :subject => "child c2", | |
|
399 | :tracker_id => 1, :project_id => 1, :author_id => 1, | |
|
400 | :parent_issue_id => 1 | |
|
401 | ) | |
|
402 | @c3 = Issue.create!( | |
|
403 | :status_id => 1, :subject => "child c3", | |
|
404 | :tracker_id => 1, :project_id => 1, :author_id => 1, | |
|
405 | :parent_issue_id => @c1.id | |
|
406 | ) | |
|
394 | 407 | end |
|
395 | 408 | |
|
396 | 409 | context ".xml" do |
@@ -428,7 +441,8 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||
|
428 | 441 | assert_equal([ |
|
429 | 442 | { |
|
430 | 443 | 'id' => @c1.id, 'subject' => 'child c1', 'tracker' => {'id' => 1, 'name' => 'Bug'}, |
|
431 |
'children' => [{ |
|
|
444 | 'children' => [{'id' => @c3.id, 'subject' => 'child c3', | |
|
445 | 'tracker' => {'id' => 1, 'name' => 'Bug'} }] | |
|
432 | 446 | }, |
|
433 | 447 | { 'id' => @c2.id, 'subject' => 'child c2', 'tracker' => {'id' => 1, 'name' => 'Bug'} } |
|
434 | 448 | ], |
@@ -440,16 +454,18 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||
|
440 | 454 | end |
|
441 | 455 | |
|
442 | 456 | context "POST /issues.xml" do |
|
443 |
should_allow_api_authentication( |
|
|
457 | should_allow_api_authentication( | |
|
458 | :post, | |
|
444 | 459 | '/issues.xml', |
|
445 | 460 |
|
|
446 |
|
|
|
447 | ||
|
461 | {:success_code => :created} | |
|
462 | ) | |
|
448 | 463 | should "create an issue with the attributes" do |
|
449 | 464 | assert_difference('Issue.count') do |
|
450 | post '/issues.xml', {:issue => {:project_id => 1, :subject => 'API test', :tracker_id => 2, :status_id => 3}}, credentials('jsmith') | |
|
465 | post '/issues.xml', | |
|
466 | {:issue => {:project_id => 1, :subject => 'API test', | |
|
467 | :tracker_id => 2, :status_id => 3}}, credentials('jsmith') | |
|
451 | 468 | end |
|
452 | ||
|
453 | 469 | issue = Issue.first(:order => 'id DESC') |
|
454 | 470 | assert_equal 1, issue.project_id |
|
455 | 471 | assert_equal 2, issue.tracker_id |
@@ -475,12 +491,16 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||
|
475 | 491 | context "POST /issues.json" do |
|
476 | 492 | should_allow_api_authentication(:post, |
|
477 | 493 | '/issues.json', |
|
478 |
{:issue => {:project_id => 1, :subject => 'API test', |
|
|
494 | {:issue => {:project_id => 1, :subject => 'API test', | |
|
495 | :tracker_id => 2, :status_id => 3}}, | |
|
479 | 496 | {:success_code => :created}) |
|
480 | 497 | |
|
481 | 498 | should "create an issue with the attributes" do |
|
482 | 499 | assert_difference('Issue.count') do |
|
483 | post '/issues.json', {:issue => {:project_id => 1, :subject => 'API test', :tracker_id => 2, :status_id => 3}}, credentials('jsmith') | |
|
500 | post '/issues.json', | |
|
501 | {:issue => {:project_id => 1, :subject => 'API test', | |
|
502 | :tracker_id => 2, :status_id => 3}}, | |
|
503 | credentials('jsmith') | |
|
484 | 504 | end |
|
485 | 505 | |
|
486 | 506 | issue = Issue.first(:order => 'id DESC') |
@@ -544,7 +564,10 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||
|
544 | 564 | |
|
545 | 565 | context "PUT /issues/3.xml with custom fields" do |
|
546 | 566 | setup do |
|
547 | @parameters = {:issue => {:custom_fields => [{'id' => '1', 'value' => 'PostgreSQL' }, {'id' => '2', 'value' => '150'}]}} | |
|
567 | @parameters = { | |
|
568 | :issue => {:custom_fields => [{'id' => '1', 'value' => 'PostgreSQL' }, | |
|
569 | {'id' => '2', 'value' => '150'}]} | |
|
570 | } | |
|
548 | 571 | end |
|
549 | 572 | |
|
550 | 573 | should "update custom fields" do |
@@ -562,7 +585,10 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||
|
562 | 585 | setup do |
|
563 | 586 | field = CustomField.find(1) |
|
564 | 587 | field.update_attribute :multiple, true |
|
565 | @parameters = {:issue => {:custom_fields => [{'id' => '1', 'value' => ['MySQL', 'PostgreSQL'] }, {'id' => '2', 'value' => '150'}]}} | |
|
588 | @parameters = { | |
|
589 | :issue => {:custom_fields => [{'id' => '1', 'value' => ['MySQL', 'PostgreSQL'] }, | |
|
590 | {'id' => '2', 'value' => '150'}]} | |
|
591 | } | |
|
566 | 592 | end |
|
567 | 593 | |
|
568 | 594 | should "update custom fields" do |
@@ -696,10 +722,10 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||
|
696 | 722 | |
|
697 | 723 | def test_create_issue_with_uploaded_file |
|
698 | 724 | set_tmp_attachments_directory |
|
699 | ||
|
700 | 725 | # upload the file |
|
701 | 726 | assert_difference 'Attachment.count' do |
|
702 | post '/uploads.xml', 'test_create_with_upload', {"CONTENT_TYPE" => 'application/octet-stream'}.merge(credentials('jsmith')) | |
|
727 | post '/uploads.xml', 'test_create_with_upload', | |
|
728 | {"CONTENT_TYPE" => 'application/octet-stream'}.merge(credentials('jsmith')) | |
|
703 | 729 | assert_response :created |
|
704 | 730 | end |
|
705 | 731 | xml = Hash.from_xml(response.body) |
@@ -709,7 +735,9 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||
|
709 | 735 | # create the issue with the upload's token |
|
710 | 736 | assert_difference 'Issue.count' do |
|
711 | 737 | post '/issues.xml', |
|
712 | {:issue => {:project_id => 1, :subject => 'Uploaded file', :uploads => [{:token => token, :filename => 'test.txt', :content_type => 'text/plain'}]}}, | |
|
738 | {:issue => {:project_id => 1, :subject => 'Uploaded file', | |
|
739 | :uploads => [{:token => token, :filename => 'test.txt', | |
|
740 | :content_type => 'text/plain'}]}}, | |
|
713 | 741 | credentials('jsmith') |
|
714 | 742 | assert_response :created |
|
715 | 743 | end |
@@ -740,10 +768,10 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||
|
740 | 768 | |
|
741 | 769 | def test_update_issue_with_uploaded_file |
|
742 | 770 | set_tmp_attachments_directory |
|
743 | ||
|
744 | 771 | # upload the file |
|
745 | 772 | assert_difference 'Attachment.count' do |
|
746 | post '/uploads.xml', 'test_upload_with_upload', {"CONTENT_TYPE" => 'application/octet-stream'}.merge(credentials('jsmith')) | |
|
773 | post '/uploads.xml', 'test_upload_with_upload', | |
|
774 | {"CONTENT_TYPE" => 'application/octet-stream'}.merge(credentials('jsmith')) | |
|
747 | 775 | assert_response :created |
|
748 | 776 | end |
|
749 | 777 | xml = Hash.from_xml(response.body) |
@@ -753,7 +781,9 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||
|
753 | 781 | # update the issue with the upload's token |
|
754 | 782 | assert_difference 'Journal.count' do |
|
755 | 783 | put '/issues/1.xml', |
|
756 | {:issue => {:notes => 'Attachment added', :uploads => [{:token => token, :filename => 'test.txt', :content_type => 'text/plain'}]}}, | |
|
784 | {:issue => {:notes => 'Attachment added', | |
|
785 | :uploads => [{:token => token, :filename => 'test.txt', | |
|
786 | :content_type => 'text/plain'}]}}, | |
|
757 | 787 | credentials('jsmith') |
|
758 | 788 | assert_response :ok |
|
759 | 789 | assert_equal '', @response.body |
General Comments 0
You need to be logged in to leave comments.
Login now