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

ulfertsa50f4091f4a3
diff --git a/modules/backlogs/features/edit_story.feature b/modules/backlogs/features/edit_story.feature
deleted file mode 100644
index ede40686e01..00000000000
--- a/modules/backlogs/features/edit_story.feature
+++ /dev/null
@@ -1,107 +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: Edit story on backlogs view
- As a team member
- I want to manage story details and story priority on the scrum backlogs view
- So that I do not loose context while filling in details
-
- 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 the following types are configured to track stories:
- | Story |
- | Epic |
- | Bug |
- And the type "Task" is configured to track tasks
- And the project uses the following types:
- | Story |
- | Bug |
- | Task |
- And there is 1 user with:
- | login | mathias |
- And there is a role "team member"
- And the role "team member" may have the following rights:
- | view_master_backlog |
- | 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:
- | name | start_date | effective_date |
- | Sprint 001 | 2010-01-01 | 2010-01-31 |
- | Sprint 002 | 2010-02-01 | 2010-02-28 |
- | Sprint 003 | 2010-03-01 | 2010-03-31 |
- | Sprint 004 | 2010-03-01 | 2010-03-31 |
- And the project has the following owner backlogs:
- | Product Backlog |
- | Wishlist |
- And there are the following issue status:
- | name | is_closed | is_default |
- | New | false | true |
- | In Progress | false | false |
- | Resolved | false | false |
- | 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
- And the project has the following stories in the following owner backlogs:
- | subject | backlog |
- | Story 1 | Product Backlog |
- | Story 2 | Product Backlog |
- | Story 3 | Product Backlog |
- | Story 4 | Product Backlog |
- And the project has the following stories in the following sprints:
- | subject | sprint | story_points |
- | Story A | Sprint 001 | 10 |
- | Story B | Sprint 001 | 20 |
- And I am already logged in as "mathias"
-
- @javascript
- Scenario: Edit story in the backlog
- Given I am on the master backlog
- When I click on the text "Story 2"
- And I fill in "Story 2 revisited" for "subject"
- And I confirm the story form
- Then I should see 4 stories in "Product Backlog"
- And the 2nd story in the "Product Backlog" should be "Story 2 revisited"
-
- @javascript
- Scenario: Edit story in a sprint
- Given I am on the master backlog
- When I click on the text "Story A"
- And I fill in "Story A revisited" for "subject"
- And I fill in "11" for "story_points"
- And I confirm the story form
- Then the 1st story in the "Sprint 001" should be "Story A revisited"
- And I should see 2 stories in "Sprint 001"
- And the velocity of "Sprint 001" should be "31"
diff --git a/modules/backlogs/spec/features/stories_in_backlog_spec.rb b/modules/backlogs/spec/features/stories_in_backlog_spec.rb
new file mode 100644
index 00000000000..f90ecac231d
--- /dev/null
+++ b/modules/backlogs/spec/features/stories_in_backlog_spec.rb
@@ -0,0 +1,155 @@
+#-- 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'
+require_relative '../support/pages/backlogs'
+
+describe 'Stories in backlog',
+ 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_master_backlog
+ 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!(:sprint_story1) do
+ FactoryBot.create(:work_package,
+ project: project,
+ type: story,
+ version: sprint,
+ story_points: 10)
+ end
+ let!(:sprint_story2) do
+ FactoryBot.create(:work_package,
+ project: project,
+ type: story,
+ version: sprint,
+ story_points: 20)
+ end
+ let!(:backlog_story1) do
+ FactoryBot.create(:work_package,
+ project: project,
+ type: story,
+ version: backlog)
+ end
+ let!(:sprint) do
+ FactoryBot.create(:version,
+ project: project,
+ version_settings_attributes: [{ project: project, display: VersionSetting::DISPLAY_LEFT }])
+ end
+ let!(:backlog) do
+ FactoryBot.create(:version,
+ project: project,
+ version_settings_attributes: [{ project: project, display: VersionSetting::DISPLAY_RIGHT }])
+ end
+ let(:backlogs_page) { Pages::Backlogs.new(project) }
+
+ 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 'displays stories which are editable' do
+ backlogs_page.visit!
+
+ # Velocity is calculated by summing up all story points in a sprint
+ backlogs_page
+ .expect_velocity(sprint_story1, 30)
+
+ # Editing in a sprint
+ backlogs_page
+ .expect_story_in_sprint(sprint_story1, sprint)
+
+ backlogs_page
+ .edit_story(sprint_story1,
+ subject: 'Altered story1',
+ story_points: 15)
+
+ sprint_story1.reload
+
+ expect(sprint_story1.subject)
+ .to eql 'Altered story1'
+
+ backlogs_page
+ .expect_for_story(sprint_story1, subject: 'Altered story1')
+
+ # Updating the story_points of a story will update the velocity of the sprint
+ backlogs_page
+ .expect_velocity(sprint_story1, 35)
+
+ # Editing in the backlog
+ backlogs_page
+ .expect_story_in_sprint(backlog_story1, backlog)
+
+ backlogs_page
+ .edit_story(backlog_story1, subject: 'Altered backlog story1')
+
+ backlog_story1.reload
+
+ expect(backlog_story1.subject)
+ .to eql 'Altered backlog story1'
+
+ backlogs_page
+ .expect_for_story(backlog_story1, subject: 'Altered backlog story1')
+ end
+end
diff --git a/modules/backlogs/spec/support/pages/backlogs.rb b/modules/backlogs/spec/support/pages/backlogs.rb
new file mode 100644
index 00000000000..77a19824bee
--- /dev/null
+++ b/modules/backlogs/spec/support/pages/backlogs.rb
@@ -0,0 +1,103 @@
+#-- 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 'support/pages/page'
+
+module Pages
+ class Backlogs < Page
+ attr_reader :project
+
+ def initialize(project)
+ super()
+ @project = project
+ end
+
+ def edit_story(story, attributes)
+ within_story(story) do
+ find('*', text: story.subject).click
+
+ attributes.each do |key, value|
+ case key
+ when :subject
+ fill_in 'subject', with: value
+ when :story_points
+ fill_in 'story points', with: value
+ else
+ raise NotImplementedError
+ end
+ end
+
+ find('input[name=subject]').native.send_key :return
+
+ expect(page)
+ .not_to have_selector('input[name=subject]')
+ end
+
+ expect(page)
+ .not_to have_selector("#{story_selector(story)}.ajax_indicator")
+ end
+
+ def expect_story_in_sprint(story, sprint)
+ expect(page)
+ .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|
+ case key
+ when :subject
+ expect(page)
+ .to have_selector('div.subject', text: value)
+ else
+ raise NotImplementedError
+ end
+ end
+ end
+ end
+
+ def expect_velocity(backlog, velocity)
+ expect(page)
+ .to have_selector("#backlog_#{backlog.id} .velocity", text: velocity.to_s)
+ end
+
+ def path
+ backlogs_project_backlogs_path(project)
+ end
+
+ private
+
+ def within_story(story, &block)
+ within(story_selector(story), &block)
+ end
+
+ def story_selector(story)
+ "#story_#{story.id}"
+ end
+ end
+end