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

adapt specs

ulfertsfd6d707fa85f
diff --git a/spec/contracts/work_packages/base_contract_spec.rb b/spec/contracts/work_packages/base_contract_spec.rb
index ef7c9a18be4..ecd67ac0a2c 100644
--- a/spec/contracts/work_packages/base_contract_spec.rb
+++ b/spec/contracts/work_packages/base_contract_spec.rb
@@ -212,21 +212,25 @@ describe WorkPackages::BaseContract do
allow(Status)
.to receive(:find_by)
- .with(id: work_package.status_id)
- .and_return(work_package.status)
+ .with(id: work_package.status_id)
+ .and_return(work_package.status)
# Breaking abstraction here to avoid mocking hell.
# We might want to extract the assignable_... into separate
# objects.
allow(contract)
.to receive(:new_statuses_allowed_from)
- .with(work_package.status)
- .and_return(new_statuses_scope)
+ .with(work_package.status)
+ .and_return(new_statuses_scope)
+
+ allow(new_statuses_scope)
+ .to receive(:order_by_position)
+ .and_return(new_statuses_scope)
allow(new_statuses_scope)
.to receive(:exists?)
- .with(new_status.id)
- .and_return(valid_transition_result)
+ .with(new_status.id)
+ .and_return(valid_transition_result)
status_change
diff --git a/spec/services/work_packages/set_attributes_service_spec.rb b/spec/services/work_packages/set_attributes_service_spec.rb
index 53f88264d48..2dd0f5a0d90 100644
--- a/spec/services/work_packages/set_attributes_service_spec.rb
+++ b/spec/services/work_packages/set_attributes_service_spec.rb
@@ -48,13 +48,15 @@ describe WorkPackages::SetAttributesService, type: :model do
let(:new_work_package) do
WorkPackage.new
end
+ let(:statuses) { [] }
let(:contract_class) { WorkPackages::UpdateContract }
let(:mock_contract) do
double(contract_class,
new: mock_contract_instance)
end
let(:mock_contract_instance) do
- mock = mock_model(contract_class)
+ mock = mock_model(contract_class,
+ assignable_statuses: statuses)
allow(mock)
.to receive(:validate)
.and_return contract_valid
@@ -140,10 +142,6 @@ describe WorkPackages::SetAttributesService, type: :model do
let(:new_statuses) { [other_status, default_status] }
before do
- allow(work_package)
- .to receive(:new_statuses_allowed_to)
- .with(user, true)
- .and_return(new_statuses)
allow(Status)
.to receive(:default)
.and_return(default_status)
@@ -450,10 +448,6 @@ describe WorkPackages::SetAttributesService, type: :model do
end
before do
- allow(work_package)
- .to receive(:new_statuses_allowed_to)
- .with(user, true)
- .and_return(new_statuses)
allow(new_project)
.to receive(:shared_versions)
.and_return(new_versions)