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]'
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
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
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
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
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
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
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)
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
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
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