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 unit spec

ulferts685441b2e9c9
diff --git a/modules/backlogs/features/team_member.feature b/modules/backlogs/features/team_member.feature
deleted file mode 100644
index 0a80de7cddc..00000000000
--- a/modules/backlogs/features/team_member.feature
+++ /dev/null
@@ -1,120 +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: Team Member
- As a team member
- I want to manage update stories and tasks
- So that I can update everyone on the status of the project
-
- 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 |
- 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 there is 1 user with:
- | login | paul |
- And there is a role "team member"
- And the role "team member" may have the following rights:
- | view_master_backlog |
- | view_taskboards |
- | view_work_packages |
- | edit_work_packages |
- | manage_subtasks |
- | add_work_packages |
- | assign_versions |
- And the user "paul" 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 stories in the following sprints:
- | subject | sprint |
- | Story 1 | Sprint 001 |
- | Story 2 | Sprint 001 |
- | Story 3 | Sprint 001 |
- | Story 4 | Sprint 002 |
- And the project has the following tasks:
- | subject | parent |
- | Task 1 | Story 1 |
- And the project has the following impediments:
- | subject | sprint | blocks |
- | Impediment 1 | Sprint 001 | Story 1 |
- | Impediment 2 | Sprint 001 | Story 2 |
- And I am already logged in as "paul"
-
- @javascript
- Scenario: Copy estimate to remaining
- Given I am on the taskboard for "Sprint 001"
- And I want to create a task for Story 1
- And I set the subject of the task to A Whole New Task
- And I set the estimated_hours of the task to 3
- When I create the task
- Then the request should complete successfully
- And task A Whole New Task should have remaining_hours set to 3
-
- @javascript
- Scenario: Copy remaining to estimate
- Given I am on the taskboard for "Sprint 001"
- And I want to create a task for Story 1
- And I set the subject of the task to A Whole New Task
- And I set the remaining_hours of the task to 3
- When I create the task
- Then the request should complete successfully
- And task A Whole New Task should have estimated_hours set to 3
-
- @javascript
- Scenario: Set both estimate and remaining
- Given I am on the taskboard for "Sprint 001"
- And I want to create a task for Story 1
- And I set the subject of the task to A Whole New Task
- And I set the remaining_hours of the task to 3
- And I set the estimated_hours of the task to 8
- When I create the task
- And I want to create a task for Story 1
- And I set the subject of the task to A Second New Task
- And I set the remaining_hours of the task to 1
- And I set the estimated_hours of the task to 2
- When I create the task
- Then the request should complete successfully
- And task A Whole New Task should have remaining_hours set to 3
- And task A Whole New Task should have estimated_hours set to 8
- And story Story 1 should have remaining_hours set to 4
- And story Story 1 should have derived_estimated_hours set to 10
diff --git a/modules/backlogs/spec/models/task_spec.rb b/modules/backlogs/spec/models/task_spec.rb
new file mode 100644
index 00000000000..7b400cfe9fe
--- /dev/null
+++ b/modules/backlogs/spec/models/task_spec.rb
@@ -0,0 +1,92 @@
+#-- 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 File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+
+describe Task, type: :model do
+ let(:task_type) { FactoryBot.create(:type) }
+ let(:default_status) { FactoryBot.create(:default_status) }
+ let(:project) { FactoryBot.create(:project) }
+ let(:task) {
+ FactoryBot.build(:task,
+ project: project,
+ status: default_status,
+ type: task_type)
+ }
+
+ before(:each) do
+ allow(Setting)
+ .to receive(:plugin_openproject_backlogs)
+ .and_return({ 'task_type' => task_type.id.to_s })
+ end
+
+ describe 'copying remaining_hours to estimated_hours and vice versa' do
+ context 'providing only remaining_hours' do
+ before do
+ task.remaining_hours = 3
+
+ task.save!
+ end
+
+ it 'copies to estimated_hours' do
+ expect(task.estimated_hours)
+ .to eql task.remaining_hours
+ end
+ end
+
+ context 'providing only estimated_hours' do
+ before do
+ task.estimated_hours = 3
+
+ task.save!
+ end
+
+ it 'copies to estimated_hours' do
+ expect(task.remaining_hours)
+ .to eql task.estimated_hours
+ end
+ end
+
+ context 'providing estimated_hours and remaining_hours' do
+ before do
+ task.estimated_hours = 3
+ task.remaining_hours = 5
+
+ task.save!
+ end
+
+ it 'leaves the values unchanged' do
+ expect(task.remaining_hours)
+ .to eql 5.0
+
+ expect(task.estimated_hours)
+ .to eql 3.0
+ end
+ end
+ end
+end
diff --git a/modules/backlogs/spec/services/work_packages/update_ancestors_service_spec.rb b/modules/backlogs/spec/services/work_packages/update_ancestors_service_spec.rb
index 49717d1fa57..38f7abf03a9 100644
--- a/modules/backlogs/spec/services/work_packages/update_ancestors_service_spec.rb
+++ b/modules/backlogs/spec/services/work_packages/update_ancestors_service_spec.rb
@@ -83,8 +83,8 @@ describe WorkPackages::UpdateAncestorsService do
context 'for the previous ancestors' do
let!(:work_package) do
FactoryBot.create :work_package,
- remaining_hours: work_package_remaining_hours,
- parent: parent
+ remaining_hours: work_package_remaining_hours,
+ parent: parent
end
subject do