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

Store visible custom fields in request store

Klaus Zandersaffb06587c33
diff --git a/spec/services/queries/projects/project_queries/set_attributes_service_spec.rb b/spec/services/queries/projects/project_queries/set_attributes_service_spec.rb
index b3eb4feeabd..06ae67e47d1 100644
--- a/spec/services/queries/projects/project_queries/set_attributes_service_spec.rb
+++ b/spec/services/queries/projects/project_queries/set_attributes_service_spec.rb
@@ -30,32 +30,15 @@ require "spec_helper"
RSpec.describe Queries::Projects::ProjectQueries::SetAttributesService, type: :model do
let(:current_user) { build_stubbed(:user) }
- let!(:custom_field) do
- build_stubbed(:project_custom_field, id: 1) do |cf|
- scope = instance_double(ActiveRecord::Relation)
-
- allow(ProjectCustomField)
- .to receive(:visible)
- .and_return(scope)
-
- allow(scope)
- .to receive(:find_by)
- .with(id: cf.id.to_s)
- .and_return(cf)
- end
- end
-
let(:contract_instance) do
contract = instance_double(Queries::Projects::ProjectQueries::CreateContract)
allow(contract)
.to receive_messages(validate: contract_valid, errors: contract_errors)
contract
end
-
let(:contract_errors) { instance_double(ActiveModel::Errors) }
let(:contract_valid) { true }
let(:model_valid) { true }
-
let(:instance) do
described_class.new(user: current_user,
model: model_instance,
@@ -70,13 +53,25 @@ RSpec.describe Queries::Projects::ProjectQueries::SetAttributesService, type: :m
Queries::Projects::ProjectQueries::CreateContract
end
-
let(:params) { {} }
+ let!(:custom_field) do
+ build_stubbed(:project_custom_field, id: 1) do |cf|
+ scope = instance_double(ActiveRecord::Relation)
+
+ allow(ProjectCustomField)
+ .to receive(:visible)
+ .and_return(scope)
+
+ allow(scope)
+ .to receive(:find_by)
+ .with(id: cf.id.to_s)
+ .and_return(cf)
+ end
+ end
before do
- allow(model_instance)
- .to receive(:valid?)
- .and_return(model_valid)
+ RequestStore.store[:custom_sortable_project_custom_fields] = "1"
+ allow(model_instance).to receive(:valid?).and_return(model_valid)
end
subject { instance.call(params) }
@@ -190,7 +185,7 @@ RSpec.describe Queries::Projects::ProjectQueries::SetAttributesService, type: :m
subject
expect(model_instance.selects.map(&:attribute))
- .to eql [:favored, :name]
+ .to eql %i[favored name]
end
end