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

replace cuke with spec

ulfertseff9bd21bd65
diff --git a/modules/backlogs/app/services/impediments/create_service.rb b/modules/backlogs/app/services/impediments/create_service.rb
index 9b55411c3a2..bac49e5ecb8 100644
--- a/modules/backlogs/app/services/impediments/create_service.rb
+++ b/modules/backlogs/app/services/impediments/create_service.rb
@@ -38,6 +38,6 @@ class Impediments::CreateService
WorkPackages::CreateService
.new(user: user)
- .call(attributes.merge(work_package: Impediment.new).symbolize_keys)
+ .call(**attributes.merge(work_package: Impediment.new).symbolize_keys)
end
end
diff --git a/modules/backlogs/app/services/impediments/update_service.rb b/modules/backlogs/app/services/impediments/update_service.rb
index 7b44372bce7..3dbe4c6a133 100644
--- a/modules/backlogs/app/services/impediments/update_service.rb
+++ b/modules/backlogs/app/services/impediments/update_service.rb
@@ -38,6 +38,6 @@ class Impediments::UpdateService
WorkPackages::UpdateService
.new(user: user,
model: impediment)
- .call(attributes)
+ .call(**attributes)
end
end
diff --git a/modules/backlogs/app/services/stories/create_service.rb b/modules/backlogs/app/services/stories/create_service.rb
index 429325e2db1..1ccb9d2550a 100644
--- a/modules/backlogs/app/services/stories/create_service.rb
+++ b/modules/backlogs/app/services/stories/create_service.rb
@@ -36,7 +36,7 @@ class Stories::CreateService
def call(attributes: {}, prev: nil)
create_call = WorkPackages::CreateService
.new(user: user)
- .call(attributes.symbolize_keys)
+ .call(**attributes.symbolize_keys)
if create_call.success?
create_call.result.move_after prev
diff --git a/modules/backlogs/app/services/stories/update_service.rb b/modules/backlogs/app/services/stories/update_service.rb
index b2b7cb76dad..e0222b41aa2 100644
--- a/modules/backlogs/app/services/stories/update_service.rb
+++ b/modules/backlogs/app/services/stories/update_service.rb
@@ -38,7 +38,7 @@ class Stories::UpdateService
create_call = WorkPackages::UpdateService
.new(user: user,
model: story)
- .call(attributes.symbolize_keys)
+ .call(**attributes.symbolize_keys)
if create_call.success? && prev
create_call.result.move_after prev
diff --git a/modules/backlogs/app/services/tasks/create_service.rb b/modules/backlogs/app/services/tasks/create_service.rb
index d15d7b43020..cb94101e30a 100644
--- a/modules/backlogs/app/services/tasks/create_service.rb
+++ b/modules/backlogs/app/services/tasks/create_service.rb
@@ -38,7 +38,7 @@ class Tasks::CreateService
create_call = WorkPackages::CreateService
.new(user: user)
- .call(attributes)
+ .call(**attributes)
if create_call.success?
create_call.result.move_after prev
diff --git a/modules/backlogs/app/services/tasks/update_service.rb b/modules/backlogs/app/services/tasks/update_service.rb
index f5081491a94..a2f2a42a503 100644
--- a/modules/backlogs/app/services/tasks/update_service.rb
+++ b/modules/backlogs/app/services/tasks/update_service.rb
@@ -38,7 +38,7 @@ class Tasks::UpdateService
create_call = WorkPackages::UpdateService
.new(user: user,
model: task)
- .call(attributes)
+ .call(**attributes)
if create_call.success?
create_call.result.move_after prev
diff --git a/modules/backlogs/app/views/rb_stories/_helpers.html.erb b/modules/backlogs/app/views/rb_stories/_helpers.html.erb
index 81006149895..3ede0079848 100644
--- a/modules/backlogs/app/views/rb_stories/_helpers.html.erb
+++ b/modules/backlogs/app/views/rb_stories/_helpers.html.erb
@@ -42,13 +42,14 @@ See docs/COPYRIGHT.rdoc for more details.
<% all_work_package_status.each do |old_status| %>
<select class="status_id helper" id="status_id_options_default_<%= old_status.id %>">
- <option value="<%= default_work_package_status.id %>" class="<%= (default_work_package_status.is_closed? ? t(:label_closed_work_packages) + ' ' : "") %>">
- <%= default_work_package_status.name %>
- </option>
<% if old_status != default_work_package_status %>
<option value="<%= old_status.id %>" class="<%= (old_status.is_closed? ? t(:label_closed_work_packages) + ' ' : "") %>">
<%= old_status.name %>
</option>
+ <% else %>
+ <option value="<%= default_work_package_status.id %>" class="<%= (default_work_package_status.is_closed? ? t(:label_closed_work_packages) + ' ' : "") %>">
+ <%= default_work_package_status.name %>
+ </option>
<% end %>
</select>
<% end %>
diff --git a/modules/backlogs/features/edit_story_tracker_and_status.feature b/modules/backlogs/features/edit_story_tracker_and_status.feature
index 2c9a9709209..2a8fe4a02a3 100644
--- a/modules/backlogs/features/edit_story_tracker_and_status.feature
+++ b/modules/backlogs/features/edit_story_tracker_and_status.feature
@@ -83,25 +83,6 @@ Feature: Edit story type and status
And I am already logged in as "romano"
And I am on the master backlog
- @javascript
- Scenario: Display only statuses which are allowed by workflow
- When I click on the text "Story A"
-
- And the available status of the story called "Story A" should be the following:
- | New |
- | Closed |
-
- When I select "Closed" from "status_id"
- And I confirm the story form
-
- Then the displayed attributes of the story called "Story A" should be the following:
- | Status | Closed |
-
- When I click on the text "Story A"
-
- Then the available status of the story called "Story A" should be the following:
- | Closed |
-
@javascript
Scenario: Select a status and change to a type that does not offer the status
When I click on the text "Story B"
@@ -128,21 +109,3 @@ Feature: Edit story type and status
Then the displayed attributes of the story called "Story B" should be the following:
| Status | New |
-
- @javascript
- Scenario: Edit a story having no permission for the status of the current ticket
- When the Type "Bug" has for the Role "manager" the following workflows:
- | old_status | new_status |
- | New | Resolved |
- And I am on the master backlog
- And I click on the text "Story C"
-
- Then the available status of the story called "Story C" should be the following:
- | New |
- | Resolved |
-
- When I select "Resolved" from "status_id"
- And I confirm the story form
-
- Then the displayed attributes of the story called "Story C" should be the following:
- | Status | Resolved |
diff --git a/modules/backlogs/features/product_owner.feature b/modules/backlogs/features/product_owner.feature
index 9914cbe8d41..35166a03497 100644
--- a/modules/backlogs/features/product_owner.feature
+++ b/modules/backlogs/features/product_owner.feature
@@ -90,14 +90,7 @@ Feature: Product Owner
| Story B | Sprint 001 |
And I am already logged in as "mathias"
- @javascript
- Scenario: View the product backlog
- When I go to the master backlog
- Then I should see the product backlog
- And I should see 4 stories in the "Product Backlog"
- And I should see 4 sprint backlogs
- And I should see 2 product owner backlogs
-
+ # TODO: add to stories_in_backlog spec
@javascript
Scenario: Create a new story
When I go to the master backlog
@@ -108,25 +101,6 @@ Feature: Product Owner
Then the 1st story in the "Product Backlog" should be "A Whole New Story"
And all positions should be unique for each version
- @javascript
- Scenario: Update a story
- Given I am on the master backlog
- And I want to edit the story with subject Story 3
- And I set the subject of the story to Relaxdiego was here
- And I set the type of the story to Epic
- When I update the story
- Then the story should have a subject of Relaxdiego was here
- And the story should have a type of Epic
- And the story should be at position 3
-
- @javascript
- Scenario: Close a story
- Given I am on the master backlog
- And I want to edit the story with subject Story 4
- And I set the status of the story to Closed
- When I update the story
- Then the status of the story should be set as closed
-
@javascript
Scenario: Move a story to the top
Given I am on the master backlog
diff --git a/modules/backlogs/features/scrum_master.feature b/modules/backlogs/features/scrum_master.feature
index 8d5b8248aaf..5ff987ea5d8 100644
--- a/modules/backlogs/features/scrum_master.feature
+++ b/modules/backlogs/features/scrum_master.feature
@@ -119,15 +119,6 @@ Feature: Scrum Master
| Subsubtask | Sprint 005 | Subfeature | Task |
And I am already logged in as "markus"
- @javascript
- Scenario: View stories that have a parent ticket
- Given I am on the master backlog
- Then I should see 2 stories in "Sprint 005"
- And I should not see "Epic 1"
- And I should not see "Task 10"
- And I should not see "Subtask 1"
- And I should not see "Subfeature"
-
@javascript
Scenario: Update sprint details
Given I am on the master backlog
diff --git a/modules/backlogs/features/shared_versions.feature b/modules/backlogs/features/shared_versions.feature
index ac7fc73d704..00068521073 100644
--- a/modules/backlogs/features/shared_versions.feature
+++ b/modules/backlogs/features/shared_versions.feature
@@ -76,6 +76,7 @@ Feature: Shared Versions
Given I am on the master backlog
Then I should see "ParentSprint" within "#sprint_backlogs_container .backlog:first-child .sprint .name"
+ # TODO: Add to stories_in_backlog spec
@javascript
Scenario: Only stories of current project are displayed
Given the project "parent" has the following stories in the following sprints:
diff --git a/modules/backlogs/features/show_story.feature b/modules/backlogs/features/show_story.feature
deleted file mode 100644
index f488342c37a..00000000000
--- a/modules/backlogs/features/show_story.feature
+++ /dev/null
@@ -1,76 +0,0 @@
-#-- 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.
-#++
-
-Feature: Show story
-
- Background:
- Given there is 1 project with:
- | name | ecookbook |
- And I am working in project "ecookbook"
- And the project uses the following modules:
- | backlogs |
- And there is a role "scrum master"
- And the role "scrum master" may have the following rights:
- | view_master_backlog |
- | view_taskboards |
- | update_sprints |
- | view_wiki_pages |
- | edit_wiki_pages |
- | view_work_packages |
- | add_work_packages |
- | edit_work_packages |
- | manage_subtasks |
- And the backlogs module is initialized
- And the following types are configured to track stories:
- | Story |
- And the type "Task" is configured to track tasks
- And the project uses the following types:
- | Story |
- | Task |
- And there is a default status with:
- | name | new |
- 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 |
- | firstname | Markus |
- | Lastname | Master |
- And the user "markus" is a "scrum master"
- And the project has the following sprints:
- | name | start_date | effective_date |
- | Sprint 001 | 2010-01-01 | 2010-01-31 |
- And the project has the following stories in the following sprints:
- | subject | sprint |
- | Story A | Sprint 001 |
- And I am already logged in as "markus"
-
- @javascript
- Scenario: Show work_package in modal box via click
- When I go to the master backlog
- And I click on the link for the story "Story A"
- Then I should see "Story A" within "#content"
diff --git a/modules/backlogs/spec/features/stories_in_backlog_spec.rb b/modules/backlogs/spec/features/stories_in_backlog_spec.rb
index f90ecac231d..011db5864b6 100644
--- a/modules/backlogs/spec/features/stories_in_backlog_spec.rb
+++ b/modules/backlogs/spec/features/stories_in_backlog_spec.rb
@@ -40,19 +40,14 @@ describe 'Stories in backlog',
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!(:default_status) { FactoryBot.create(:status, is_default: true) }
let!(:other_status) { FactoryBot.create(:status) }
let!(:workflows) do
FactoryBot.create(:workflow,
- old_status: status,
+ old_status: default_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,
@@ -73,13 +68,29 @@ describe 'Stories in backlog',
FactoryBot.create(:work_package,
project: project,
type: story,
+ status: default_status,
version: sprint,
story_points: 10)
end
+ let!(:sprint_story1_task) do
+ FactoryBot.create(:work_package,
+ project: project,
+ type: task,
+ status: default_status,
+ version: sprint)
+ end
+ let!(:sprint_story2_parent) do
+ FactoryBot.create(:work_package,
+ project: project,
+ type: FactoryBot.create(:type),
+ status: default_status,
+ version: sprint)
+ end
let!(:sprint_story2) do
FactoryBot.create(:work_package,
project: project,
type: story,
+ status: default_status,
version: sprint,
story_points: 20)
end
@@ -87,6 +98,7 @@ describe 'Stories in backlog',
FactoryBot.create(:work_package,
project: project,
type: story,
+ status: default_status,
version: backlog)
end
let!(:sprint) do
@@ -116,10 +128,25 @@ describe 'Stories in backlog',
backlogs_page
.expect_velocity(sprint_story1, 30)
- # Editing in a sprint
+ # All stories are visible in their sprint/backlog
+ # but non stories are not displayed
backlogs_page
.expect_story_in_sprint(sprint_story1, sprint)
+ backlogs_page
+ .expect_story_in_sprint(sprint_story2, sprint)
+
+ backlogs_page
+ .expect_story_in_sprint(backlog_story1, backlog)
+
+ backlogs_page
+ .expect_story_not_in_sprint(sprint_story2_parent, sprint)
+
+ backlogs_page
+ .expect_story_not_in_sprint(sprint_story1_task, sprint)
+
+ # Editing in a sprint
+
backlogs_page
.edit_story(sprint_story1,
subject: 'Altered story1',
@@ -138,18 +165,47 @@ describe 'Stories in backlog',
.expect_velocity(sprint_story1, 35)
# Editing in the backlog
+
backlogs_page
- .expect_story_in_sprint(backlog_story1, backlog)
+ .enter_edit_story_mode(backlog_story1)
+
+ # The available statuses include those available by the workflow:
+ # Current and every reachable one
+ backlogs_page
+ .expect_status_options(backlog_story1,
+ [default_status, other_status])
backlogs_page
- .edit_story(backlog_story1, subject: 'Altered backlog story1')
+ .alter_attributes_in_edit_mode(backlog_story1,
+ subject: 'Altered backlog story1',
+ status: other_status.name)
+ backlogs_page
+ .save_story_from_edit_mode(backlog_story1)
backlog_story1.reload
expect(backlog_story1.subject)
.to eql 'Altered backlog story1'
+ expect(backlog_story1.status)
+ .to eql other_status
+
+ backlogs_page
+ .expect_for_story(backlog_story1,
+ subject: 'Altered backlog story1',
+ status: other_status.name)
+
+ backlogs_page
+ .enter_edit_story_mode(backlog_story1)
+
+ # Since we switched to other status, only the current status is available now.
+ backlogs_page
+ .expect_status_options(backlog_story1,
+ [other_status])
+
+ # One can switch to the work package page by clicking on the id
+ # Clicking on it will open the wp in another tab which seems to trip up selenium.
backlogs_page
- .expect_for_story(backlog_story1, subject: 'Altered backlog story1')
+ .expect_story_link_to_wp_page(sprint_story1)
end
end
diff --git a/modules/backlogs/spec/support/pages/backlogs.rb b/modules/backlogs/spec/support/pages/backlogs.rb
index 77a19824bee..a8c2497f6f9 100644
--- a/modules/backlogs/spec/support/pages/backlogs.rb
+++ b/modules/backlogs/spec/support/pages/backlogs.rb
@@ -37,21 +37,31 @@ module Pages
@project = project
end
- def edit_story(story, attributes)
+ def enter_edit_story_mode(story)
within_story(story) do
find('*', text: story.subject).click
+ end
+ end
+ def alter_attributes_in_edit_mode(story, attributes)
+ within_story(story) do
attributes.each do |key, value|
case key
when :subject
fill_in 'subject', with: value
when :story_points
fill_in 'story points', with: value
+ when :status
+ select value, from: 'status'
else
raise NotImplementedError
end
end
+ end
+ end
+ def save_story_from_edit_mode(story)
+ within_story(story) do
find('input[name=subject]').native.send_key :return
expect(page)
@@ -62,11 +72,24 @@ module Pages
.not_to have_selector("#{story_selector(story)}.ajax_indicator")
end
+ def edit_story(story, attributes)
+ enter_edit_story_mode(story)
+
+ alter_attributes_in_edit_mode(story, attributes)
+
+ save_story_from_edit_mode(story)
+ end
+
def expect_story_in_sprint(story, sprint)
expect(page)
.to have_selector("#backlog_#{sprint.id} #{story_selector(story)}")
end
+ def expect_story_not_in_sprint(story, sprint)
+ expect(page)
+ .not_to have_selector("#backlog_#{sprint.id} #{story_selector(story)}")
+ end
+
def expect_for_story(story, attributes)
within_story(story) do
attributes.each do |key, value|
@@ -74,6 +97,9 @@ module Pages
when :subject
expect(page)
.to have_selector('div.subject', text: value)
+ when :status
+ expect(page)
+ .to have_selector('div.status_id', text: value)
else
raise NotImplementedError
end
@@ -81,6 +107,20 @@ module Pages
end
end
+ def expect_story_link_to_wp_page(story)
+ within_story(story) do
+ expect(page)
+ .to have_link(story.id, href: work_package_path(story))
+ end
+ end
+
+ def expect_status_options(story, statuses)
+ within_story(story) do
+ expect(all('.status_id option').map { |n| n.text.strip } )
+ .to match_array(statuses.map(&:name))
+ end
+ end
+
def expect_velocity(backlog, velocity)
expect(page)
.to have_selector("#backlog_#{backlog.id} .velocity", text: velocity.to_s)