Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

rewrite failing backlogs cuke as spec (#8809)

ulferts3d756a765c72
diff --git a/features/step_definitions/priority_steps.rb b/features/step_definitions/priority_steps.rb
index 5b2cebdee17..6dd3d193acb 100644
--- a/features/step_definitions/priority_steps.rb
+++ b/features/step_definitions/priority_steps.rb
@@ -29,14 +29,8 @@
InstanceFinder.register(IssuePriority, Proc.new { |name| IssuePriority.find_by(name: name) })
-Given /^there is a(?:n)? (default )?issuepriority with:$/ do |default, table|
- name = table.raw.find { |ary| ary.include? 'name' }[table.raw.first.index('name') + 1].to_s
- project = get_project
- FactoryBot.build(:priority).tap do |prio|
- prio.name = name
- prio.is_default = !!default
- prio.project = project
- end.save!
+Given /^there is a(?:n)? (default )?issuepriority$/ do |default|
+ FactoryBot.create(:priority, is_default: !!default, project: get_project)
end
Given /^there are the following priorities:$/ do |table|
diff --git a/features/step_definitions/role_steps.rb b/features/step_definitions/role_steps.rb
index 40405706638..adb1142dcb2 100644
--- a/features/step_definitions/role_steps.rb
+++ b/features/step_definitions/role_steps.rb
@@ -31,6 +31,9 @@ Given /^the [Uu]ser "([^\"]*)" is a "([^\"]*)" (?:in|of) the [Pp]roject "([^\"]*
u = User.find_by_login(user)
r = Role.find_by(name: role)
p = Project.find_by(name: project) || Project.find_by(identifier: project)
+
+ next if Member.where(principal: u, project: p).exists?
+
as_admin do
Member.new.tap do |m|
m.principal = u
diff --git a/modules/backlogs/features/edit_story.feature b/modules/backlogs/features/edit_story.feature
index 42a3735726e..ede40686e01 100644
--- a/modules/backlogs/features/edit_story.feature
+++ b/modules/backlogs/features/edit_story.feature
@@ -73,8 +73,7 @@ Feature: Edit story on backlogs view
| Closed | true | false |
| Rejected | true | false |
And the type "Story" has the default workflow for the role "team member"
- And there is a default issuepriority with:
- | name | Normal |
+ And there is a default issuepriority
And the project has the following stories in the following owner backlogs:
| subject | backlog |
| Story 1 | Product Backlog |
diff --git a/modules/backlogs/features/edit_story_tracker_and_status.feature b/modules/backlogs/features/edit_story_tracker_and_status.feature
index bfcfc31119e..2c9a9709209 100644
--- a/modules/backlogs/features/edit_story_tracker_and_status.feature
+++ b/modules/backlogs/features/edit_story_tracker_and_status.feature
@@ -66,8 +66,7 @@ Feature: Edit story type and status
| Resolved | false | false |
| Closed | true | false |
| Rejected | true | false |
- And there is a default issuepriority with:
- | name | Normal |
+ And there is a default issuepriority
And the project has the following stories in the following sprints:
| subject | sprint | type | status | story_points |
| Story A | Sprint 001 | Bug | New | 10 |
diff --git a/modules/backlogs/features/export_card_configurations.feature b/modules/backlogs/features/export_card_configurations.feature
index 35408cf4e91..4cf2a469e69 100644
--- a/modules/backlogs/features/export_card_configurations.feature
+++ b/modules/backlogs/features/export_card_configurations.feature
@@ -67,8 +67,7 @@ Feature: Export sprint stories as PDF on the Backlogs view
| Closed | true | false |
| Rejected | true | false |
And the type "Story" has the default workflow for the role "team member"
- And there is a default issuepriority with:
- | name | Normal |
+ And there is a default issuepriority
And the project has the following stories in the following sprints:
| subject | sprint | story_points |
| Story A | Sprint 001 | 10 |
diff --git a/modules/backlogs/features/fixed_version_by_issue_hierarchy.feature b/modules/backlogs/features/fixed_version_by_issue_hierarchy.feature
index aeed53a2921..b3f48b962a7 100644
--- a/modules/backlogs/features/fixed_version_by_issue_hierarchy.feature
+++ b/modules/backlogs/features/fixed_version_by_issue_hierarchy.feature
@@ -57,8 +57,7 @@ Feature: The work_package hierarchy defines the allowed versions for each work_p
| Resolved | false | false |
| Closed | true | false |
| Rejected | true | false |
- And there is a default issuepriority with:
- | name | Normal |
+ And there is a default issuepriority
And the backlogs module is initialized
And the following types are configured to track stories:
| Story |
diff --git a/modules/backlogs/features/foldable_versions.feature b/modules/backlogs/features/foldable_versions.feature
index b24acc59138..2f197276e4c 100644
--- a/modules/backlogs/features/foldable_versions.feature
+++ b/modules/backlogs/features/foldable_versions.feature
@@ -51,8 +51,7 @@ Feature: Foldable versions in master backlog
| Task |
And there is a default status with:
| name | new |
- And there is a default issuepriority with:
- | name | Normal |
+ And there is a default issuepriority
And the type "Task" has the default workflow for the role "scrum master"
And there is 1 user with:
| login | markus |
diff --git a/modules/backlogs/features/issue_hierarchy_restriction_project_boundaries.feature b/modules/backlogs/features/issue_hierarchy_restriction_project_boundaries.feature
index da0e15995de..0954b63fd57 100644
--- a/modules/backlogs/features/issue_hierarchy_restriction_project_boundaries.feature
+++ b/modules/backlogs/features/issue_hierarchy_restriction_project_boundaries.feature
@@ -65,8 +65,7 @@ Feature: The work_package hierarchy between backlogs stories and backlogs tasks
| Resolved | false | false |
| Closed | true | false |
| Rejected | true | false |
- And there is a default issuepriority with:
- | name | Normal |
+ And there is a default issuepriority
And there is 1 user with:
| login | markus |
| firstname | Markus |
diff --git a/modules/backlogs/features/product_owner.feature b/modules/backlogs/features/product_owner.feature
index 1d48a665226..9914cbe8d41 100644
--- a/modules/backlogs/features/product_owner.feature
+++ b/modules/backlogs/features/product_owner.feature
@@ -57,8 +57,7 @@ Feature: Product Owner
And there is 1 project with:
| name | ecookbook |
And I am working in project "ecookbook"
- And there is a default issuepriority with:
- | name | Normal |
+ And there is a default issuepriority
And the project uses the following modules:
| backlogs |
And the project uses the following types:
diff --git a/modules/backlogs/features/scrum_master.feature b/modules/backlogs/features/scrum_master.feature
index e74859cdd83..8d5b8248aaf 100644
--- a/modules/backlogs/features/scrum_master.feature
+++ b/modules/backlogs/features/scrum_master.feature
@@ -65,8 +65,7 @@ Feature: Scrum Master
| Resolved | false | false |
| Closed | true | false |
| Rejected | true | false |
- And there is a default issuepriority with:
- | name | Normal |
+ And there is a default issuepriority
And the type "Task" has the default workflow for the role "scrum master"
And there is 1 user with:
| login | markus |
@@ -129,96 +128,6 @@ Feature: Scrum Master
And I should not see "Subtask 1"
And I should not see "Subfeature"
- @javascript
- Scenario: Create an impediment
- Given I am on the taskboard for "Sprint 001"
- When I click on the element with class "add_new" within "#impediments"
- And I fill in "Bad Company" for "subject"
- And I fill in the ids of the tasks "Task 1" for "blocks_ids"
- And I select "Markus Master" from "assigned_to_id"
- And I press "OK"
- And the impediment "Bad Company" should signal successful saving
- Then I should see "Bad Company" within "#impediments"
-
- @javascript
- Scenario: Create an impediment blocking an work_package of another sprint
- Given I am on the taskboard for "Sprint 001"
- When I click on the element with class "add_new" within "#impediments"
- And I fill in "Bad Company" for "subject"
- And I fill in the ids of the stories "Story C" for "blocks_ids"
- And I select "Markus Master" from "assigned_to_id"
- And I press "OK"
- Then I should see "Bad Company" within "#impediments"
- And the impediment "Bad Company" should signal unsuccessful saving
- And the error alert should show "IDs of blocked work packages can only contain IDs of work packages in the current sprint."
-
- @javascript
- Scenario: Create an impediment blocking a non existent work_package
- Given I am on the taskboard for "Sprint 001"
- When I click on the element with class "add_new" within "#impediments"
- And I fill in "Bad Company" for "subject"
- And I fill in "0" for "blocks_ids"
- And I select "Markus Master" from "assigned_to_id"
- And I press "OK"
- Then I should see "Bad Company" within "#impediments"
- And the impediment "Bad Company" should signal unsuccessful saving
- And the error alert should show "IDs of blocked work packages can only contain IDs of work packages in the current sprint."
-
- @javascript
- Scenario: Create an impediment without specifying what it blocks
- Given I am on the taskboard for "Sprint 001"
- When I click on the element with class "add_new" within "#impediments"
- And I fill in "Bad Company" for "subject"
- And I fill in "" for "blocks_ids"
- And I select "Markus Master" from "assigned_to_id"
- And I press "OK"
- Then I should see "Bad Company" within "#impediments"
- And the impediment "Bad Company" should signal unsuccessful saving
- And the error alert should show "IDs of blocked work packages must contain the ID of at least one ticket"
-
- @javascript
- Scenario: Update an impediment
- Given I am on the taskboard for "Sprint 001"
- When I click on the impediment called "Impediment 1"
- And I fill in "Bad Company" for "subject"
- And I fill in the ids of the tasks "Task 1" for "blocks_ids"
- And I press "OK"
- Then I should see "Bad Company" within "#impediments"
- And the impediment "Bad Company" should signal successful saving
-
- @javascript
- Scenario: Update an impediment to block an work_package of another sprint
- Given I am on the taskboard for "Sprint 001"
- When I click on the impediment called "Impediment 1"
- And I fill in "Bad Company" for "subject"
- And I fill in the ids of the stories "Story C" for "blocks_ids"
- And I press "OK"
- Then I should see "Bad Company" within "#impediments"
- And the impediment "Bad Company" should signal unsuccessful saving
- And the error alert should show "IDs of blocked work packages can only contain IDs of work packages in the current sprint."
-
- @javascript
- Scenario: Update an impediment to block a non existent work_package
- Given I am on the taskboard for "Sprint 001"
- When I click on the impediment called "Impediment 1"
- And I fill in "Bad Company" for "subject"
- And I fill in "0" for "blocks_ids"
- And I press "OK"
- Then I should see "Bad Company" within "#impediments"
- And the impediment "Bad Company" should signal unsuccessful saving
- And the error alert should show "IDs of blocked work packages can only contain IDs of work packages in the current sprint."
-
- @javascript
- Scenario: Update an impediment to not block anything
- Given I am on the taskboard for "Sprint 001"
- When I click on the impediment called "Impediment 1"
- And I fill in "Bad Company" for "subject"
- And I fill in "" for "blocks_ids"
- And I press "OK"
- Then I should see "Bad Company" within "#impediments"
- And the impediment "Bad Company" should signal unsuccessful saving
- And the error alert should show "IDs of blocked work packages must contain the ID of at least one ticket"
-
@javascript
Scenario: Update sprint details
Given I am on the master backlog
@@ -278,20 +187,6 @@ Feature: Scrum Master
And Story D should be in the 2nd position of the sprint named Sprint 005
And Story E should be the higher item of Story D
- @javascript
- Scenario: View epic, stories, tasks, subtasks in the work_package list
- When I go to the work_packages index page
- Then I should see "Epic 1" within ".work-package-table--container table"
- And I should see "Story D" within ".work-package-table--container table"
- And I should see "Story E" within ".work-package-table--container table"
- And I should see "Task 10" within ".work-package-table--container table"
- And I should see "Task 11" within ".work-package-table--container table"
- And I should see "Subtask 1" within ".work-package-table--container table"
- And I should see "Subtask 2" within ".work-package-table--container table"
- And I should see "Subtask 3" within ".work-package-table--container table"
- And I should see "Subfeature" within ".work-package-table--container table"
- And I should see "Subsubtask" within ".work-package-table--container table"
-
@javascript
Scenario: Move a task with subtasks around in the taskboard
Given I am on the taskboard for "Sprint 005"
diff --git a/modules/backlogs/features/shared_versions.feature b/modules/backlogs/features/shared_versions.feature
index 6654b9b3364..ac7fc73d704 100644
--- a/modules/backlogs/features/shared_versions.feature
+++ b/modules/backlogs/features/shared_versions.feature
@@ -54,8 +54,7 @@ Feature: Shared Versions
And I am working in project "child"
And there is a default status with:
| name | new |
- And there is a default issuepriority with:
- | name | Normal |
+ And there is a default issuepriority
And there is 1 user with:
| login | padme |
And there is a role "project admin"
diff --git a/modules/backlogs/features/show_story.feature b/modules/backlogs/features/show_story.feature
index b1b64e38952..f488342c37a 100644
--- a/modules/backlogs/features/show_story.feature
+++ b/modules/backlogs/features/show_story.feature
@@ -54,8 +54,7 @@ Feature: Show story
| Task |
And there is a default status with:
| name | new |
- And there is a default issuepriority with:
- | name | Normal |
+ And there is a default issuepriority
And the type "Task" has the default workflow for the role "scrum master"
And there is 1 user with:
| login | markus |
diff --git a/modules/backlogs/features/team_member.feature b/modules/backlogs/features/team_member.feature
index 501e771abeb..a537e1f612a 100644
--- a/modules/backlogs/features/team_member.feature
+++ b/modules/backlogs/features/team_member.feature
@@ -46,8 +46,7 @@ Feature: Team Member
| Task |
And there is a default status with:
| name | new |
- And there is a default issuepriority with:
- | name | Normal |
+ And there is a default issuepriority
And there is 1 user with:
| login | paul |
And there is a role "team member"
diff --git a/modules/backlogs/spec/features/impediments_spec.rb b/modules/backlogs/spec/features/impediments_spec.rb
new file mode 100644
index 00000000000..c6352f3e593
--- /dev/null
+++ b/modules/backlogs/spec/features/impediments_spec.rb
@@ -0,0 +1,190 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2020 the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2017 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See docs/COPYRIGHT.rdoc for more details.
+#++
+
+require 'spec_helper'
+
+describe 'Impediments on taskboard',
+ type: :feature,
+ js: true do
+ let!(:project) do
+ FactoryBot.create(:project,
+ types: [story, task],
+ enabled_module_names: %w(work_package_tracking backlogs))
+ end
+ let!(:story) { FactoryBot.create(:type_feature) }
+ let!(:task) { FactoryBot.create(:type_task) }
+ let!(:priority) { FactoryBot.create(:default_priority) }
+ let!(:status) { FactoryBot.create(:status, is_default: true) }
+ let!(:other_status) { FactoryBot.create(:status) }
+ let!(:workflows) do
+ FactoryBot.create(:workflow,
+ old_status: status,
+ new_status: other_status,
+ role: role,
+ type_id: story.id)
+ FactoryBot.create(:workflow,
+ old_status: status,
+ new_status: other_status,
+ role: role,
+ type_id: task.id)
+ end
+ let(:role) do
+ FactoryBot.create(:role,
+ permissions: %i(view_taskboards
+ add_work_packages
+ view_work_packages
+ edit_work_packages
+ manage_subtasks
+ assign_versions))
+
+ end
+ let!(:current_user) do
+ FactoryBot.create(:user,
+ member_in_project: project,
+ member_through_role: role)
+ end
+ let!(:task1) do
+ FactoryBot.create(:work_package,
+ status: status,
+ project: project,
+ type: task,
+ version: sprint,
+ parent: story1)
+ end
+ let!(:story1) do
+ FactoryBot.create(:work_package,
+ project: project,
+ type: story,
+ version: sprint)
+ end
+ let!(:other_task) do
+ FactoryBot.create(:work_package,
+ project: project,
+ type: task,
+ version: sprint,
+ parent: other_story)
+ end
+ let!(:other_story) do
+ FactoryBot.create(:work_package,
+ project: project,
+ type: story,
+ version: other_sprint)
+ end
+ let!(:sprint) do
+ FactoryBot.create(:version, project: project)
+ end
+ let!(:other_sprint) do
+ FactoryBot.create(:version, project: project)
+ end
+
+ before do
+ login_as current_user
+ allow(Setting)
+ .to receive(:plugin_openproject_backlogs)
+ .and_return('story_types' => [story.id.to_s],
+ 'task_type' => task.id.to_s)
+ end
+
+ it 'allows creating and updating impediments' do
+ visit backlogs_project_sprint_taskboard_path(project, sprint)
+
+ find('#impediments .add_new').click
+
+ fill_in 'subject', with: 'New impediment'
+ fill_in 'blocks_ids', with: task1.id
+ select current_user.name, from: 'assigned_to_id'
+ click_on 'OK'
+
+ # Saves successfully
+ expect(page)
+ .to have_selector('div.impediment', text: 'New impediment')
+ expect(page)
+ .not_to have_selector('div.impediment.error', text: 'New impediment')
+
+ # Attempt to create a new impediment with the id of a story from another sprint
+ find('#impediments .add_new').click
+
+ fill_in 'subject', with: 'Other sprint impediment'
+ fill_in 'blocks_ids', with: other_story.id
+ click_on 'OK'
+
+ # Saves unsuccessfully
+ expect(page)
+ .to have_selector('div.impediment', text: 'Other sprint impediment')
+ expect(page)
+ .to have_selector('div.impediment.error', text: 'Other sprint impediment')
+ expect(page)
+ .to have_selector('#msgBox', text: "IDs of blocked work packages can only contain IDs of work packages in the current sprint.")
+
+ click_on 'OK'
+
+ # Attempt to create a new impediment with a non existing id
+ find('#impediments .add_new').click
+
+ fill_in 'subject', with: 'Invalid id impediment'
+ fill_in 'blocks_ids', with: '0'
+ click_on 'OK'
+
+ # Saves unsuccessfully
+ expect(page)
+ .to have_selector('div.impediment', text: 'Invalid id impediment')
+ expect(page)
+ .to have_selector('div.impediment.error', text: 'Invalid id impediment')
+ expect(page)
+ .to have_selector('#msgBox', text: "IDs of blocked work packages can only contain IDs of work packages in the current sprint.")
+ click_on 'OK'
+
+ # Attempt to create a new impediment without specifying the blocked story/task
+ find('#impediments .add_new').click
+
+ fill_in 'subject', with: 'Unblocking impediment'
+ click_on 'OK'
+
+ # Saves unsuccessfully
+ expect(page)
+ .to have_selector('div.impediment', text: 'Unblocking impediment')
+ expect(page)
+ .to have_selector('div.impediment.error', text: 'Unblocking impediment')
+ expect(page)
+ .to have_selector('#msgBox', text: "IDs of blocked work packages must contain the ID of at least one ticket")
+ click_on 'OK'
+
+ # Updating an impediment
+ find('#impediments .subject', text: 'New impediment').click
+
+ fill_in 'subject', with: 'Updated impediment'
+ fill_in 'blocks_ids', with: story.id
+ click_on 'OK'
+
+ # Saves successfully
+ expect(page)
+ .to have_selector('div.impediment', text: 'Updated impediment')
+ expect(page)
+ .not_to have_selector('div.impediment.error', text: 'Updated impediment')
+ end
+end