]> source.dussan.org Git - redmine.git/commitdiff
Makes Issue.generate_with_descendants! helper accept attributes only.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 12 Oct 2012 08:56:09 +0000 (08:56 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 12 Oct 2012 08:56:09 +0000 (08:56 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10612 e93f8b46-1217-0410-a6f0-8f06a7374b81

test/functional/issues_controller_test.rb
test/object_helpers.rb
test/unit/issue_test.rb
test/unit/project_test.rb

index 82160f5f921aa301d248b16f605cf04846f7511b..01eb26c9631018b6264f69f453f6975a9c531625 100644 (file)
@@ -2320,7 +2320,7 @@ class IssuesControllerTest < ActionController::TestCase
 
   def test_new_as_copy_with_subtasks_should_show_copy_subtasks_checkbox
     @request.session[:user_id] = 2
-    issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
+    issue = Issue.generate_with_descendants!
     get :new, :project_id => 1, :copy_from => issue.id
 
     assert_select 'input[type=checkbox][name=copy_subtasks][checked=checked][value=1]'
@@ -2422,7 +2422,7 @@ class IssuesControllerTest < ActionController::TestCase
 
   def test_create_as_copy_should_copy_subtasks
     @request.session[:user_id] = 2
-    issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
+    issue = Issue.generate_with_descendants!
     count = issue.descendants.count
 
     assert_difference 'Issue.count', count+1 do
@@ -2439,7 +2439,7 @@ class IssuesControllerTest < ActionController::TestCase
 
   def test_create_as_copy_without_copy_subtasks_option_should_not_copy_subtasks
     @request.session[:user_id] = 2
-    issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
+    issue = Issue.generate_with_descendants!
 
     assert_difference 'Issue.count', 1 do
       assert_no_difference 'Journal.count' do
@@ -3634,7 +3634,7 @@ class IssuesControllerTest < ActionController::TestCase
   end
 
   def test_bulk_copy_should_allow_not_copying_the_subtasks
-    issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
+    issue = Issue.generate_with_descendants!
     @request.session[:user_id] = 2
 
     assert_difference 'Issue.count', 1 do
@@ -3646,7 +3646,7 @@ class IssuesControllerTest < ActionController::TestCase
   end
 
   def test_bulk_copy_should_allow_copying_the_subtasks
-    issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
+    issue = Issue.generate_with_descendants!
     count = issue.descendants.count
     @request.session[:user_id] = 2
 
@@ -3661,7 +3661,7 @@ class IssuesControllerTest < ActionController::TestCase
   end
 
   def test_bulk_copy_should_not_copy_selected_subtasks_twice
-    issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
+    issue = Issue.generate_with_descendants!
     count = issue.descendants.count
     @request.session[:user_id] = 2
 
index 2c224bcfc0c6a335066f53d4cb4e33e105fcecc7..575c9f2338698a2930c9b382d4dc154175337a35 100644 (file)
@@ -70,12 +70,12 @@ module ObjectHelpers
     issue
   end
 
-  # Generates an issue with some children and a grandchild
-  def Issue.generate_with_descendants!(project, attributes={})
-    issue = Issue.generate!(attributes.merge(:project => project))
-    child = Issue.generate!(:project => project, :subject => 'Child1', :parent_issue_id => issue.id)
-    Issue.generate!(:project => project, :subject => 'Child2', :parent_issue_id => issue.id)
-    Issue.generate!(:project => project, :subject => 'Child11', :parent_issue_id => child.id)
+  # Generates an issue with 2 children and a grandchild
+  def Issue.generate_with_descendants!(attributes={})
+    issue = Issue.generate!(attributes)
+    child = Issue.generate!(:project => issue.project, :subject => 'Child1', :parent_issue_id => issue.id)
+    Issue.generate!(:project => issue.project, :subject => 'Child2', :parent_issue_id => issue.id)
+    Issue.generate!(:project => issue.project, :subject => 'Child11', :parent_issue_id => child.id)
     issue.reload
   end
 
index 329d6436172b7b69a1b1b62539b17134935c5307..0747f5c8421313e1b4b89268a5bad8767e0a9a3a 100644 (file)
@@ -650,7 +650,7 @@ class IssueTest < ActiveSupport::TestCase
   end
 
   def test_copy_should_copy_subtasks
-    issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
+    issue = Issue.generate_with_descendants!
 
     copy = issue.reload.copy
     copy.author = User.find(7)
@@ -665,7 +665,7 @@ class IssueTest < ActiveSupport::TestCase
   end
 
   def test_copy_should_copy_subtasks_to_target_project
-    issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
+    issue = Issue.generate_with_descendants!
 
     copy = issue.copy(:project_id => 3)
     assert_difference 'Issue.count', 1+issue.descendants.count do
@@ -675,7 +675,7 @@ class IssueTest < ActiveSupport::TestCase
   end
 
   def test_copy_should_not_copy_subtasks_twice_when_saving_twice
-    issue = Issue.generate_with_descendants!(Project.find(1), :subject => 'Parent')
+    issue = Issue.generate_with_descendants!
 
     copy = issue.reload.copy
     assert_difference 'Issue.count', 1+issue.descendants.count do
index 8338a1f535c4e082d6c377fae026f95efb9ea423..8960f24af07a28ca6694df158070f1c0706859f0 100644 (file)
@@ -1054,7 +1054,7 @@ class ProjectTest < ActiveSupport::TestCase
 
   def test_copy_should_copy_subtasks
     source = Project.generate!(:tracker_ids => [1])
-    issue = Issue.generate_with_descendants!(source, :subject => 'Parent')
+    issue = Issue.generate_with_descendants!(:project => source)
     project = Project.new(:name => 'Copy', :identifier => 'copy', :tracker_ids => [1])
 
     assert_difference 'Project.count' do