@@ -114,7 +114,8 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||||
114 | :children => {:count => 1}, |
|
114 | :children => {:count => 1}, | |
115 | :child => { |
|
115 | :child => { | |
116 | :tag => 'relation', |
|
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 | assert_tag 'relations', |
|
120 | assert_tag 'relations', | |
120 | :parent => {:tag => 'issue', :child => {:tag => 'id', :content => '1'}}, |
|
121 | :parent => {:tag => 'issue', :child => {:tag => 'id', :content => '1'}}, | |
@@ -134,12 +135,12 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||||
134 |
|
135 | |||
135 | context "with custom field filter" do |
|
136 | context "with custom field filter" do | |
136 | should "show only issues with the custom field value" do |
|
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 | get '/issues.xml', | |
138 |
|
139 | {:set_filter => 1, :f => ['cf_1'], :op => {:cf_1 => '='}, | ||
|
140 | :v => {:cf_1 => ['MySQL']}} | |||
139 | expected_ids = Issue.visible.all( |
|
141 | expected_ids = Issue.visible.all( | |
140 | :include => :custom_values, |
|
142 | :include => :custom_values, | |
141 | :conditions => {:custom_values => {:custom_field_id => 1, :value => 'MySQL'}}).map(&:id) |
|
143 | :conditions => {:custom_values => {:custom_field_id => 1, :value => 'MySQL'}}).map(&:id) | |
142 |
|
||||
143 | assert_select 'issues > issue > id', :count => expected_ids.count do |ids| |
|
144 | assert_select 'issues > issue > id', :count => expected_ids.count do |ids| | |
144 | ids.each { |id| assert expected_ids.delete(id.children.first.content.to_i) } |
|
145 | ids.each { |id| assert expected_ids.delete(id.children.first.content.to_i) } | |
145 | end |
|
146 | end | |
@@ -388,9 +389,21 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||||
388 |
|
389 | |||
389 | context "with subtasks" do |
|
390 | context "with subtasks" do | |
390 | setup do |
|
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 | @c1 = Issue.create!( | |
392 | @c2 = Issue.create!(:status_id => 1, :subject => "child c2", :tracker_id => 1, :project_id => 1, :author_id => 1, :parent_issue_id => 1) |
|
393 | :status_id => 1, :subject => "child c1", | |
393 |
|
|
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 | end |
|
407 | end | |
395 |
|
408 | |||
396 | context ".xml" do |
|
409 | context ".xml" do | |
@@ -428,7 +441,8 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||||
428 | assert_equal([ |
|
441 | assert_equal([ | |
429 | { |
|
442 | { | |
430 | 'id' => @c1.id, 'subject' => 'child c1', 'tracker' => {'id' => 1, 'name' => 'Bug'}, |
|
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 | { 'id' => @c2.id, 'subject' => 'child c2', 'tracker' => {'id' => 1, 'name' => 'Bug'} } |
|
447 | { 'id' => @c2.id, 'subject' => 'child c2', 'tracker' => {'id' => 1, 'name' => 'Bug'} } | |
434 | ], |
|
448 | ], | |
@@ -440,16 +454,18 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||||
440 | end |
|
454 | end | |
441 |
|
455 | |||
442 | context "POST /issues.xml" do |
|
456 | context "POST /issues.xml" do | |
443 |
should_allow_api_authentication( |
|
457 | should_allow_api_authentication( | |
444 | '/issues.xml', |
|
458 | :post, | |
445 | {:issue => {:project_id => 1, :subject => 'API test', :tracker_id => 2, :status_id => 3}}, |
|
459 | '/issues.xml', | |
446 | {:success_code => :created}) |
|
460 | {:issue => {:project_id => 1, :subject => 'API test', :tracker_id => 2, :status_id => 3}}, | |
447 |
|
461 | {:success_code => :created} | ||
|
462 | ) | |||
448 | should "create an issue with the attributes" do |
|
463 | should "create an issue with the attributes" do | |
449 | assert_difference('Issue.count') do |
|
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 | end |
|
468 | end | |
452 |
|
||||
453 | issue = Issue.first(:order => 'id DESC') |
|
469 | issue = Issue.first(:order => 'id DESC') | |
454 | assert_equal 1, issue.project_id |
|
470 | assert_equal 1, issue.project_id | |
455 | assert_equal 2, issue.tracker_id |
|
471 | assert_equal 2, issue.tracker_id | |
@@ -475,12 +491,16 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||||
475 | context "POST /issues.json" do |
|
491 | context "POST /issues.json" do | |
476 | should_allow_api_authentication(:post, |
|
492 | should_allow_api_authentication(:post, | |
477 | '/issues.json', |
|
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 | {:success_code => :created}) |
|
496 | {:success_code => :created}) | |
480 |
|
497 | |||
481 | should "create an issue with the attributes" do |
|
498 | should "create an issue with the attributes" do | |
482 | assert_difference('Issue.count') do |
|
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 | end |
|
504 | end | |
485 |
|
505 | |||
486 | issue = Issue.first(:order => 'id DESC') |
|
506 | issue = Issue.first(:order => 'id DESC') | |
@@ -544,7 +564,10 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||||
544 |
|
564 | |||
545 | context "PUT /issues/3.xml with custom fields" do |
|
565 | context "PUT /issues/3.xml with custom fields" do | |
546 | setup do |
|
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 | end |
|
571 | end | |
549 |
|
572 | |||
550 | should "update custom fields" do |
|
573 | should "update custom fields" do | |
@@ -562,7 +585,10 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||||
562 | setup do |
|
585 | setup do | |
563 | field = CustomField.find(1) |
|
586 | field = CustomField.find(1) | |
564 | field.update_attribute :multiple, true |
|
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 | end |
|
592 | end | |
567 |
|
593 | |||
568 | should "update custom fields" do |
|
594 | should "update custom fields" do | |
@@ -696,10 +722,10 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||||
696 |
|
722 | |||
697 | def test_create_issue_with_uploaded_file |
|
723 | def test_create_issue_with_uploaded_file | |
698 | set_tmp_attachments_directory |
|
724 | set_tmp_attachments_directory | |
699 |
|
||||
700 | # upload the file |
|
725 | # upload the file | |
701 | assert_difference 'Attachment.count' do |
|
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 | assert_response :created |
|
729 | assert_response :created | |
704 | end |
|
730 | end | |
705 | xml = Hash.from_xml(response.body) |
|
731 | xml = Hash.from_xml(response.body) | |
@@ -709,8 +735,10 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||||
709 | # create the issue with the upload's token |
|
735 | # create the issue with the upload's token | |
710 | assert_difference 'Issue.count' do |
|
736 | assert_difference 'Issue.count' do | |
711 | post '/issues.xml', |
|
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', | |
713 | credentials('jsmith') |
|
739 | :uploads => [{:token => token, :filename => 'test.txt', | |
|
740 | :content_type => 'text/plain'}]}}, | |||
|
741 | credentials('jsmith') | |||
714 | assert_response :created |
|
742 | assert_response :created | |
715 | end |
|
743 | end | |
716 | issue = Issue.first(:order => 'id DESC') |
|
744 | issue = Issue.first(:order => 'id DESC') | |
@@ -740,10 +768,10 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||||
740 |
|
768 | |||
741 | def test_update_issue_with_uploaded_file |
|
769 | def test_update_issue_with_uploaded_file | |
742 | set_tmp_attachments_directory |
|
770 | set_tmp_attachments_directory | |
743 |
|
||||
744 | # upload the file |
|
771 | # upload the file | |
745 | assert_difference 'Attachment.count' do |
|
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 | assert_response :created |
|
775 | assert_response :created | |
748 | end |
|
776 | end | |
749 | xml = Hash.from_xml(response.body) |
|
777 | xml = Hash.from_xml(response.body) | |
@@ -753,8 +781,10 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||||
753 | # update the issue with the upload's token |
|
781 | # update the issue with the upload's token | |
754 | assert_difference 'Journal.count' do |
|
782 | assert_difference 'Journal.count' do | |
755 | put '/issues/1.xml', |
|
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', | |
757 | credentials('jsmith') |
|
785 | :uploads => [{:token => token, :filename => 'test.txt', | |
|
786 | :content_type => 'text/plain'}]}}, | |||
|
787 | credentials('jsmith') | |||
758 | assert_response :ok |
|
788 | assert_response :ok | |
759 | assert_equal '', @response.body |
|
789 | assert_equal '', @response.body | |
760 | end |
|
790 | end |
General Comments 0
You need to be logged in to leave comments.
Login now