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

use feature flag spec helper for all duration specs

ulfertsec01d40440c9
diff --git a/spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb b/spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb
index bbfd2ae8168..dfb82fe4c5e 100644
--- a/spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb
+++ b/spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb
@@ -293,15 +293,13 @@ describe ::API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
end
end
- describe 'duration' do
+ describe 'duration', with_flag: { work_packages_duration_field_active: true } do
+ let(:milestone?) { false }
+
before do
- # TODO: remove feature flag once the implementation is complete
- allow(OpenProject::FeatureDecisions)
- .to receive(:work_packages_duration_field_active?)
- .and_return(true)
allow(schema)
.to receive(:milestone?)
- .and_return(false)
+ .and_return(milestone?)
end
it_behaves_like 'has basic schema properties' do
@@ -313,24 +311,14 @@ describe ::API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
end
context 'when the work package is a milestone' do
- before do
- allow(schema)
- .to receive(:milestone?)
- .and_return(true)
- end
+ let(:milestone?) { true }
it 'has no duration attribute' do
expect(subject).not_to have_json_path('duration')
end
end
- context 'when the feature flag is off' do
- before do
- allow(OpenProject::FeatureDecisions)
- .to receive(:work_packages_duration_field_active?)
- .and_return(false)
- end
-
+ context 'when the feature flag is off', with_flag: { work_packages_duration_field_active: false } do
it 'has no duration attribute' do
expect(subject).not_to have_json_path('duration')
end
@@ -348,16 +336,7 @@ describe ::API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
end
end
- describe 'ignoreNonWorkingDays' do
- let(:feature_active) { true }
-
- before do
- # TODO: remove feature flag once the implementation is complete
- allow(OpenProject::FeatureDecisions)
- .to receive(:work_packages_duration_field_active?)
- .and_return(feature_active)
- end
-
+ describe 'ignoreNonWorkingDays', with_flag: { work_packages_duration_field_active: true } do
it_behaves_like 'has basic schema properties' do
let(:path) { 'ignoreNonWorkingDays' }
let(:type) { 'Boolean' }
@@ -366,9 +345,7 @@ describe ::API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
let(:writable) { false }
end
- context 'when the feature flag is off' do
- let(:feature_active) { false }
-
+ context 'when the feature flag is off', with_flag: { work_packages_duration_field_active: false } do
it 'has no ignoreNonWorkingDays attribute' do
expect(subject).not_to have_json_path('ignoreNonWorkingDays')
end
diff --git a/spec/models/queries/work_packages/columns/property_column_spec.rb b/spec/models/queries/work_packages/columns/property_column_spec.rb
index 035d0750915..5465336bc79 100644
--- a/spec/models/queries/work_packages/columns/property_column_spec.rb
+++ b/spec/models/queries/work_packages/columns/property_column_spec.rb
@@ -55,22 +55,14 @@ describe Queries::WorkPackages::Columns::PropertyColumn, type: :model do
end
end
- context 'when duration feature flag disabled' do
+ context 'when duration feature flag disabled', with_flag: { work_packages_duration_field_active: false } do
it 'column does not exist' do
- allow(OpenProject::FeatureDecisions)
- .to receive(:work_packages_duration_field_active?)
- .and_return(false)
-
expect(described_class.instances.map(&:name)).not_to include :duration
end
end
- context 'when duration feature flag enabled' do
+ context 'when duration feature flag enabled', with_flag: { work_packages_duration_field_active: true } do
it 'column exists' do
- allow(OpenProject::FeatureDecisions)
- .to receive(:work_packages_duration_field_active?)
- .and_return(true)
-
expect(described_class.instances.map(&:name)).to include :duration
end
end