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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Make spec faster
Christophe Bliard22d804c2102f
diff --git a/modules/backlogs/spec/contracts/work_packages/base_contract_spec.rb b/modules/backlogs/spec/contracts/work_packages/base_contract_spec.rbindex 2e0b6ba5218..56e94aadf3a 100644--- a/modules/backlogs/spec/contracts/work_packages/base_contract_spec.rb+++ b/modules/backlogs/spec/contracts/work_packages/base_contract_spec.rb@@ -29,48 +29,28 @@require 'spec_helper'RSpec.describe WorkPackages::BaseContract, type: :model do+ shared_let(:type_feature) { create(:type_feature) }+ shared_let(:type_task) { create(:type_task) }+ shared_let(:type_bug) { create(:type_bug) }+ shared_let(:backlogs_types) { [type_feature, type_task, type_bug] }+ shared_let(:project) do+ create(:project, types: backlogs_types)+ end+ shared_let(:other_project) do+ create(:project, types: backlogs_types)+ end+ shared_let(:user) do+ create(:admin, member_with_roles: { project => create(:project_role),+ other_project => create(:project_role) })+ end+let(:instance) { described_class.new(work_package, user) }- let(:type_feature) { build(:type_feature) }- let(:type_task) { build(:type_task) }- let(:type_bug) { build(:type_bug) }let(:version1) { build_stubbed(:version, name: 'Version1', project: p) }let(:version2) { build_stubbed(:version, name: 'Version2', project: p) }- let(:role) { build(:project_role) }- let(:user) { build(:admin) }+let(:issue_priority) { build(:priority) }let(:status) { build_stubbed(:status, name: 'status 1', is_default: true) }- let(:project) do- p = build(:project, members: [build(:member,- principal: user,- roles: [role])],- types: [type_feature, type_task, type_bug])-- allow(p)- .to receive(:assignable_versions)- .and_return([version1,- version2])-- p.enabled_module_names += ['backlogs']-- p- end-- let(:other_project) do- p = build(:project, members: [build(:member,- principal: user,- roles: [role])],- types: [type_feature, type_task, type_bug])-- allow(p)- .to receive(:assignable_versions)- .and_return([version1,- version2])- p.enabled_module_names += ['backlogs']-- p- end-let(:story) dobuild_stubbed(:work_package,subject: 'Story',@@ -141,12 +121,8 @@ RSpec.describe WorkPackages::BaseContract, type: :model doscope = instance_double(ActiveRecord::Relation)allow(scope)- .to receive(:where)- .and_return(scope)-- allow(scope)- .to receive(:empty?)- .and_return(false)+ .to receive_messages(where: scope,+ empty?: false)scopeend@@ -154,7 +130,12 @@ RSpec.describe WorkPackages::BaseContract, type: :model dosubject(:valid) { instance.validate }before do- project.save!+ allow(project)+ .to receive(:assignable_versions)+ .and_return([version1, version2])+ allow(other_project)+ .to receive(:assignable_versions)+ .and_return([version1, version2])allow(WorkPackage).to receive(:relatable)@@ -183,7 +164,7 @@ RSpec.describe WorkPackages::BaseContract, type: :model doshared_examples_for 'version being restricted by the parent' dobefore do- work_package.parent = parent if work_package.parent.blank?+ work_package.parent ||= parentenddescribe 'WITHOUT a version and the parent also having no version' do@@ -192,7 +173,7 @@ RSpec.describe WorkPackages::BaseContract, type: :model dowork_package.version = nilend- it_behaves_like 'is valid'+ include_examples 'is valid'enddescribe 'WITHOUT a version and the parent having a version' do@@ -201,7 +182,7 @@ RSpec.describe WorkPackages::BaseContract, type: :model dowork_package.version = nilend- it_behaves_like 'is invalid and notes the error'+ include_examples 'is invalid and notes the error'enddescribe 'WITH a version and the parent having a different version' do@@ -210,7 +191,7 @@ RSpec.describe WorkPackages::BaseContract, type: :model dowork_package.version = version2end- it_behaves_like 'is invalid and notes the error'+ include_examples 'is invalid and notes the error'enddescribe 'WITH a version and the parent having the same version' do@@ -219,7 +200,7 @@ RSpec.describe WorkPackages::BaseContract, type: :model dowork_package.version = version1end- it_behaves_like 'is valid'+ include_examples 'is valid'enddescribe 'WITH a version and the parent having no version' do@@ -228,13 +209,13 @@ RSpec.describe WorkPackages::BaseContract, type: :model dowork_package.version = version1end- it_behaves_like 'is invalid and notes the error'+ include_examples 'is invalid and notes the error'endendshared_examples_for 'version not being restricted by the parent' dobefore do- work_package.parent = parent if work_package.parent.blank?+ work_package.parent ||= parentenddescribe 'WITHOUT a version and the parent also having no version' do@@ -243,7 +224,7 @@ RSpec.describe WorkPackages::BaseContract, type: :model dowork_package.version = nilend- it_behaves_like 'is valid'+ include_examples 'is valid'enddescribe 'WITHOUT a version and the parent having a version' do@@ -252,7 +233,7 @@ RSpec.describe WorkPackages::BaseContract, type: :model dowork_package.version = nilend- it_behaves_like 'is valid'+ include_examples 'is valid'enddescribe 'WITH a version and the parent having a different version' do@@ -261,7 +242,7 @@ RSpec.describe WorkPackages::BaseContract, type: :model dowork_package.version = version2end- it_behaves_like 'is valid'+ include_examples 'is valid'enddescribe 'WITH a version and the parent having the same version' do@@ -270,7 +251,7 @@ RSpec.describe WorkPackages::BaseContract, type: :model dowork_package.version = version1end- it_behaves_like 'is valid'+ include_examples 'is valid'enddescribe 'WITH a version and the parent having no version' do@@ -279,7 +260,7 @@ RSpec.describe WorkPackages::BaseContract, type: :model dowork_package.version = version1end- it_behaves_like 'is valid'+ include_examples 'is valid'endend@@ -289,7 +270,7 @@ RSpec.describe WorkPackages::BaseContract, type: :model dowork_package.version = nilend- it_behaves_like 'is valid'+ include_examples 'is valid'enddescribe 'WITH a version' do@@ -297,7 +278,7 @@ RSpec.describe WorkPackages::BaseContract, type: :model dowork_package.version = version1end- it_behaves_like 'is valid'+ include_examples 'is valid'endend@@ -335,13 +316,13 @@ RSpec.describe WorkPackages::BaseContract, type: :model dolet(:parent) { task2 }- it_behaves_like 'version being restricted by the parent'+ include_examples 'version being restricted by the parent'enddescribe "WITH a story as its parent" dolet(:parent) { story }- it_behaves_like 'version being restricted by the parent'+ include_examples 'version being restricted by the parent'enddescribe "WITH a non backlogs tracked work_package as its parent" do@@ -386,7 +367,7 @@ RSpec.describe WorkPackages::BaseContract, type: :model dowork_package.parent = parentend- it_behaves_like 'is valid'+ include_examples 'is valid'enddescribe 'WITH the work_package having a different project' do@@ -395,7 +376,7 @@ RSpec.describe WorkPackages::BaseContract, type: :model dowork_package.project = other_projectend- it_behaves_like 'is valid'+ include_examples 'is valid'endend@@ -405,13 +386,13 @@ RSpec.describe WorkPackages::BaseContract, type: :model dodescribe 'WITH a story as its parent' dolet(:parent) { story }- it_behaves_like 'project id unrestricted by parent'+ include_examples 'project id unrestricted by parent'enddescribe 'WITH a non backlogs work package as its parent' dolet(:parent) { bug }- it_behaves_like 'project id unrestricted by parent'+ include_examples 'project id unrestricted by parent'endend@@ -421,13 +402,13 @@ RSpec.describe WorkPackages::BaseContract, type: :model dodescribe 'WITH a story as its parent' dolet(:parent) { story2 }- it_behaves_like 'project id unrestricted by parent'+ include_examples 'project id unrestricted by parent'enddescribe 'WITH a non backlogs work package as its parent' dolet(:parent) { bug }- it_behaves_like 'project id unrestricted by parent'+ include_examples 'project id unrestricted by parent'endend@@ -437,13 +418,13 @@ RSpec.describe WorkPackages::BaseContract, type: :model dodescribe 'WITH a story as its parent' dolet(:parent) { story }- it_behaves_like 'project id unrestricted by parent'+ include_examples 'project id unrestricted by parent'enddescribe 'WITH a non backlogs work package as its parent' dolet(:parent) { bug2 }- it_behaves_like 'project id unrestricted by parent'+ include_examples 'project id unrestricted by parent'endendend