Mercurial > hg > soundsoftware-site
comparison test/integration/api_test/issues_test.rb @ 1295:622f24f53b42 redmine-2.3
Update to Redmine SVN revision 11972 on 2.3-stable branch
author | Chris Cannam |
---|---|
date | Fri, 14 Jun 2013 09:02:21 +0100 |
parents | 433d4f72a19b |
children |
comparison
equal
deleted
inserted
replaced
1294:3e4c3460b6ca | 1295:622f24f53b42 |
---|---|
1 # Redmine - project management software | 1 # Redmine - project management software |
2 # Copyright (C) 2006-2012 Jean-Philippe Lang | 2 # Copyright (C) 2006-2013 Jean-Philippe Lang |
3 # | 3 # |
4 # This program is free software; you can redistribute it and/or | 4 # This program is free software; you can redistribute it and/or |
5 # modify it under the terms of the GNU General Public License | 5 # modify it under the terms of the GNU General Public License |
6 # as published by the Free Software Foundation; either version 2 | 6 # as published by the Free Software Foundation; either version 2 |
7 # of the License, or (at your option) any later version. | 7 # of the License, or (at your option) any later version. |
15 # along with this program; if not, write to the Free Software | 15 # along with this program; if not, write to the Free Software |
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | 17 |
18 require File.expand_path('../../../test_helper', __FILE__) | 18 require File.expand_path('../../../test_helper', __FILE__) |
19 | 19 |
20 class ApiTest::IssuesTest < ActionController::IntegrationTest | 20 class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base |
21 fixtures :projects, | 21 fixtures :projects, |
22 :users, | 22 :users, |
23 :roles, | 23 :roles, |
24 :members, | 24 :members, |
25 :member_roles, | 25 :member_roles, |
451 end | 451 end |
452 end | 452 end |
453 end | 453 end |
454 end | 454 end |
455 | 455 |
456 test "GET /issues/:id.xml?include=watchers should include watchers" do | |
457 Watcher.create!(:user_id => 3, :watchable => Issue.find(1)) | |
458 | |
459 get '/issues/1.xml?include=watchers', {}, credentials('jsmith') | |
460 | |
461 assert_response :ok | |
462 assert_equal 'application/xml', response.content_type | |
463 assert_select 'issue' do | |
464 assert_select 'watchers', Issue.find(1).watchers.count | |
465 assert_select 'watchers' do | |
466 assert_select 'user[id=3]' | |
467 end | |
468 end | |
469 end | |
470 | |
456 context "POST /issues.xml" do | 471 context "POST /issues.xml" do |
457 should_allow_api_authentication( | 472 should_allow_api_authentication( |
458 :post, | 473 :post, |
459 '/issues.xml', | 474 '/issues.xml', |
460 {:issue => {:project_id => 1, :subject => 'API test', :tracker_id => 2, :status_id => 3}}, | 475 {:issue => {:project_id => 1, :subject => 'API test', :tracker_id => 2, :status_id => 3}}, |
476 assert_equal 'application/xml', @response.content_type | 491 assert_equal 'application/xml', @response.content_type |
477 assert_tag 'issue', :child => {:tag => 'id', :content => issue.id.to_s} | 492 assert_tag 'issue', :child => {:tag => 'id', :content => issue.id.to_s} |
478 end | 493 end |
479 end | 494 end |
480 | 495 |
496 test "POST /issues.xml with watcher_user_ids should create issue with watchers" do | |
497 assert_difference('Issue.count') do | |
498 post '/issues.xml', | |
499 {:issue => {:project_id => 1, :subject => 'Watchers', | |
500 :tracker_id => 2, :status_id => 3, :watcher_user_ids => [3, 1]}}, credentials('jsmith') | |
501 assert_response :created | |
502 end | |
503 issue = Issue.order('id desc').first | |
504 assert_equal 2, issue.watchers.size | |
505 assert_equal [1, 3], issue.watcher_user_ids.sort | |
506 end | |
507 | |
481 context "POST /issues.xml with failure" do | 508 context "POST /issues.xml with failure" do |
482 should "have an errors tag" do | 509 should "have an errors tag" do |
483 assert_no_difference('Issue.count') do | 510 assert_no_difference('Issue.count') do |
484 post '/issues.xml', {:issue => {:project_id => 1}}, credentials('jsmith') | 511 post '/issues.xml', {:issue => {:project_id => 1}}, credentials('jsmith') |
485 end | 512 end |
716 assert_equal '', response.body | 743 assert_equal '', response.body |
717 end | 744 end |
718 | 745 |
719 assert_nil Issue.find_by_id(6) | 746 assert_nil Issue.find_by_id(6) |
720 end | 747 end |
748 end | |
749 | |
750 test "POST /issues/:id/watchers.xml should add watcher" do | |
751 assert_difference 'Watcher.count' do | |
752 post '/issues/1/watchers.xml', {:user_id => 3}, credentials('jsmith') | |
753 | |
754 assert_response :ok | |
755 assert_equal '', response.body | |
756 end | |
757 watcher = Watcher.order('id desc').first | |
758 assert_equal Issue.find(1), watcher.watchable | |
759 assert_equal User.find(3), watcher.user | |
760 end | |
761 | |
762 test "DELETE /issues/:id/watchers/:user_id.xml should remove watcher" do | |
763 Watcher.create!(:user_id => 3, :watchable => Issue.find(1)) | |
764 | |
765 assert_difference 'Watcher.count', -1 do | |
766 delete '/issues/1/watchers/3.xml', {}, credentials('jsmith') | |
767 | |
768 assert_response :ok | |
769 assert_equal '', response.body | |
770 end | |
771 assert_equal false, Issue.find(1).watched_by?(User.find(3)) | |
721 end | 772 end |
722 | 773 |
723 def test_create_issue_with_uploaded_file | 774 def test_create_issue_with_uploaded_file |
724 set_tmp_attachments_directory | 775 set_tmp_attachments_directory |
725 # upload the file | 776 # upload the file |