diff --git a/features/edit_story.feature b/features/edit_story.feature index 63fa3ad811..3ea34ce4f9 100644 --- a/features/edit_story.feature +++ b/features/edit_story.feature @@ -62,6 +62,7 @@ Feature: Edit story on backlogs view | update_stories | | view_work_packages | | edit_work_packages | + | add_work_packages | | manage_subtasks | And the user "mathias" is a "team member" And the project has the following sprints: @@ -160,3 +161,39 @@ Feature: Edit story on backlogs view And I follow "New Story" of the "Sprint 001" menu And I close the "Sprint 001" menu Then I should not see "Epic" within_hidden ".type_id.helper" + + @javascript + Scenario: Story duplication without copying tasks + Given the project has the following tasks: + | subject | parent | + | Task 1 | Story A | + And I am on the work package index page for the project called "ecookbook" + And I follow "Story A" + And I select "Duplicate" from the action menu + And I choose "copy_tasks_none" within "#backlogs-attributes" + And I press "Create" + Then I should not see "Task 1" + + @javascript + Scenario: Story duplication with copying all tasks + Given the project has the following tasks: + | subject | parent | + | Task 1 | Story A | + And I am on the work package index page for the project called "ecookbook" + And I follow "Story A" + And I select "Duplicate" from the action menu + And I choose "copy_tasks_all" within "#backlogs-attributes" + And I press "Create" + Then I should see "Task 1" + + @javascript + Scenario: Story duplication with copying open tasks + Given the project has the following tasks: + | subject | parent | + | Task 1 | Story A | + And I am on the work package index page for the project called "ecookbook" + And I follow "Story A" + And I select "Duplicate" from the action menu + And I choose "copy_tasks_open" within "#backlogs-attributes" + And I press "Create" + Then I should see "Task 1" diff --git a/lib/open_project/backlogs/hooks.rb b/lib/open_project/backlogs/hooks.rb index 4037308955..7e08e2a1da 100644 --- a/lib/open_project/backlogs/hooks.rb +++ b/lib/open_project/backlogs/hooks.rb @@ -137,9 +137,9 @@ module OpenProject::Backlogs::Hooks snippet << "#{check_box_tag('link_to_original', params[:copy_from], true)}

" snippet << "

" - snippet << "#{radio_button_tag('copy_tasks', 'open:' + params[:copy_from], true)} #{l(:rb_label_copy_tasks_open)}
" - snippet << "#{radio_button_tag('copy_tasks', 'none', false)} #{l(:rb_label_copy_tasks_none)}
" - snippet << "#{radio_button_tag('copy_tasks', 'all:' + params[:copy_from], false)} #{l(:rb_label_copy_tasks_all)}

" + snippet << "#{radio_button_tag('copy_tasks', 'open:' + params[:copy_from], true, { id: 'copy_tasks_open'})} #{l(:rb_label_copy_tasks_open)}
" + snippet << "#{radio_button_tag('copy_tasks', 'none', false, {id: 'copy_tasks_none'})} #{l(:rb_label_copy_tasks_none)}
" + snippet << "#{radio_button_tag('copy_tasks', 'all:' + params[:copy_from], false, {id: 'copy_tasks_all'})} #{l(:rb_label_copy_tasks_all)}

" end snippet << %() * 2 @@ -200,7 +200,7 @@ module OpenProject::Backlogs::Hooks params[:copy_tasks] += ':' if params[:copy_tasks] !~ /:/ action, id = *(params[:copy_tasks].split(/:/)) - story = (id == '' ? nil : Story.find(Integer(id))) + story = (id.nil? ? nil : Story.find(Integer(id))) if ! story.nil? && action != 'none' tasks = story.tasks