summaryrefslogtreecommitdiffstats
path: root/test/functional
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-01-08 11:16:54 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-01-08 11:16:54 +0000
commit121bc44cc504b3086c35d40f984d75d978c59fb0 (patch)
treece23bebc4b702daad08241c105f36bba18bee68d /test/functional
parentf134eeef459e7027b43500cc6a3b7306882c10b7 (diff)
downloadredmine-121bc44cc504b3086c35d40f984d75d978c59fb0.tar.gz
redmine-121bc44cc504b3086c35d40f984d75d978c59fb0.zip
Use the regular issue form to copy a single issue.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8552 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/functional')
-rw-r--r--test/functional/context_menus_controller_test.rb5
-rw-r--r--test/functional/issues_controller_test.rb52
2 files changed, 52 insertions, 5 deletions
diff --git a/test/functional/context_menus_controller_test.rb b/test/functional/context_menus_controller_test.rb
index 7a188560b..426ca67b5 100644
--- a/test/functional/context_menus_controller_test.rb
+++ b/test/functional/context_menus_controller_test.rb
@@ -43,11 +43,8 @@ class ContextMenusControllerTest < ActionController::TestCase
assert_tag :tag => 'a', :content => 'Dave Lopper',
:attributes => { :href => '/issues/bulk_update?ids%5B%5D=1&amp;issue%5Bassigned_to_id%5D=3',
:class => '' }
- assert_tag :tag => 'a', :content => 'Duplicate',
- :attributes => { :href => '/projects/ecookbook/issues/1/copy',
- :class => 'icon-duplicate' }
assert_tag :tag => 'a', :content => 'Copy',
- :attributes => { :href => '/issues/bulk_edit?copy=1&amp;ids%5B%5D=1',
+ :attributes => { :href => '/projects/ecookbook/issues/1/copy',
:class => 'icon-copy' }
assert_no_tag :tag => 'a', :content => 'Move'
assert_tag :tag => 'a', :content => 'Delete',
diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb
index 9b09d7f6b..5879e666b 100644
--- a/test/functional/issues_controller_test.rb
+++ b/test/functional/issues_controller_test.rb
@@ -1571,13 +1571,63 @@ class IssuesControllerTest < ActionController::TestCase
end
end
- def test_copy_issue
+ def test_new_as_copy
@request.session[:user_id] = 2
get :new, :project_id => 1, :copy_from => 1
+
+ assert_response :success
assert_template 'new'
+
assert_not_nil assigns(:issue)
orig = Issue.find(1)
+ assert_equal 1, assigns(:issue).project_id
assert_equal orig.subject, assigns(:issue).subject
+ assert assigns(:issue).copy?
+
+ assert_tag 'form', :attributes => {:id => 'issue-form', :action => '/projects/ecookbook/issues'}
+ assert_tag 'select', :attributes => {:name => 'issue[project_id]'}
+ assert_tag 'select', :attributes => {:name => 'issue[project_id]'},
+ :child => {:tag => 'option', :attributes => {:value => '1', :selected => 'selected'}, :content => 'eCookbook'}
+ assert_tag 'select', :attributes => {:name => 'issue[project_id]'},
+ :child => {:tag => 'option', :attributes => {:value => '2', :selected => nil}, :content => 'OnlineStore'}
+ assert_tag 'input', :attributes => {:name => 'copy_from', :value => '1'}
+ end
+
+ def test_create_as_copy_on_different_project
+ @request.session[:user_id] = 2
+ assert_difference 'Issue.count' do
+ post :create, :project_id => 1, :copy_from => 1,
+ :issue => {:project_id => '2', :tracker_id => '3', :status_id => '1', :subject => 'Copy'}
+
+ assert_not_nil assigns(:issue)
+ assert assigns(:issue).copy?
+ end
+ issue = Issue.first(:order => 'id DESC')
+ assert_redirected_to "/issues/#{issue.id}"
+
+ assert_equal 2, issue.project_id
+ assert_equal 3, issue.tracker_id
+ assert_equal 'Copy', issue.subject
+ end
+
+ def test_create_as_copy_with_failure
+ @request.session[:user_id] = 2
+ post :create, :project_id => 1, :copy_from => 1,
+ :issue => {:project_id => '2', :tracker_id => '3', :status_id => '1', :subject => ''}
+
+ assert_response :success
+ assert_template 'new'
+
+ assert_not_nil assigns(:issue)
+ assert assigns(:issue).copy?
+
+ assert_tag 'form', :attributes => {:id => 'issue-form', :action => '/projects/ecookbook/issues'}
+ assert_tag 'select', :attributes => {:name => 'issue[project_id]'}
+ assert_tag 'select', :attributes => {:name => 'issue[project_id]'},
+ :child => {:tag => 'option', :attributes => {:value => '1', :selected => nil}, :content => 'eCookbook'}
+ assert_tag 'select', :attributes => {:name => 'issue[project_id]'},
+ :child => {:tag => 'option', :attributes => {:value => '2', :selected => 'selected'}, :content => 'OnlineStore'}
+ assert_tag 'input', :attributes => {:name => 'copy_from', :value => '1'}
end
def test_get_edit