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
correctly apply filters for time entry users
ulferts7beb9f5fc0ca
diff --git a/lib/api/v3/utilities/path_helper.rb b/lib/api/v3/utilities/path_helper.rbindex 238aca1e926..499ec95eac2 100644--- a/lib/api/v3/utilities/path_helper.rb+++ b/lib/api/v3/utilities/path_helper.rb@@ -519,11 +519,6 @@ module API"#{project(project_id)}/work_packages"end- def self.filtered_path(base_path, *filters)- escaped = CGI.escape(::JSON.dump(filters))- "#{base_path}?filters=#{escaped}"- end-def self.path_for(path, filters: nil, sort_by: nil, group_by: nil, page_size: nil, offset: nil, select: nil)query_params = {filters: filters&.to_json,diff --git a/modules/costs/lib/api/v3/time_entries/schemas/time_entry_schema_representer.rb b/modules/costs/lib/api/v3/time_entries/schemas/time_entry_schema_representer.rbindex 86726b9f306..1672f5b27d3 100644--- a/modules/costs/lib/api/v3/time_entries/schemas/time_entry_schema_representer.rb+++ b/modules/costs/lib/api/v3/time_entries/schemas/time_entry_schema_representer.rb@@ -103,10 +103,12 @@ module APIenddef allowed_user_href- api_v3_paths.filtered_path api_v3_paths.principals,- status: { operator: '!', values: [Principal.statuses[:locked].to_s] },- type: { operator: '=', values: ['User'] },- member: { operator: '=', values: [represented.project_id] }+ api_v3_paths.path_for :principals,+ filters: [+ { status: { operator: '!', values: [Principal.statuses[:locked].to_s] } },+ { type: { operator: '=', values: ['User'] } },+ { member: { operator: '=', values: [represented.project_id] } }+ ]endendenddiff --git a/modules/costs/spec/lib/api/v3/time_entries/schemas/time_entry_schema_representer_spec.rb b/modules/costs/spec/lib/api/v3/time_entries/schemas/time_entry_schema_representer_spec.rbindex f3e9a6b43dd..3b7b5287a30 100644--- a/modules/costs/spec/lib/api/v3/time_entries/schemas/time_entry_schema_representer_spec.rb+++ b/modules/costs/spec/lib/api/v3/time_entries/schemas/time_entry_schema_representer_spec.rb@@ -238,6 +238,33 @@ describe ::API::V3::TimeEntries::Schemas::TimeEntrySchemaRepresenter doendendend++ describe 'user' do+ let(:path) { 'user' }++ it_behaves_like 'has basic schema properties' do+ let(:type) { 'User' }+ let(:name) { TimeEntry.human_attribute_name('user') }+ let(:required) { true }+ let(:writable) { true }+ let(:location) { '_links' }+ end++ context 'if embedding' do+ let(:embedded) { true }++ it_behaves_like 'links to allowed values via collection link' do+ let(:href) do+ api_v3_paths.path_for :principals,+ filters: [+ { status: { operator: '!', values: [Principal.statuses[:locked].to_s] } },+ { type: { operator: '=', values: ['User'] } },+ { member: { operator: '=', values: [project.id] } }+ ]+ end+ end+ end+ endendcontext 'custom value' do