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
replace usage of OpenStruct
ulfertse4cbf6deeecf
diff --git a/app/services/api/parse_resource_params_service.rb b/app/services/api/parse_resource_params_service.rbindex b4441830958..73888a8931e 100644--- a/app/services/api/parse_resource_params_service.rb+++ b/app/services/api/parse_resource_params_service.rb@@ -72,16 +72,17 @@ module API.from_hash(request_body)deep_to_h(struct)+ .deep_symbolize_keysenddef struct- OpenStruct.new+ Hashie::Mash.newenddef deep_to_h(value)# Does not yet factor in Arrays. There hasn't been the need to do that, yet.case value- when OpenStruct, Hash+ when Hashie::Mash, Hashvalue.to_h.transform_values do |sub_value|deep_to_h(sub_value)enddiff --git a/app/services/api/v3/parse_resource_params_service.rb b/app/services/api/v3/parse_resource_params_service.rbindex 575626c27f9..4f0c312f315 100644--- a/app/services/api/v3/parse_resource_params_service.rb+++ b/app/services/api/v3/parse_resource_params_service.rb@@ -46,10 +46,10 @@ module APIenddef struct- if model&.respond_to?(:available_custom_fields)- OpenStruct.new available_custom_fields: model.available_custom_fields(model.new)- else- super+ super.tap do |instance|+ if model.respond_to?(:available_custom_fields)+ instance.available_custom_fields = model.available_custom_fields(model.new)+ endendendenddiff --git a/app/services/api/v3/work_package_collection_from_query_service.rb b/app/services/api/v3/work_package_collection_from_query_service.rbindex ded1386b8fa..61caf0f03e2 100644--- a/app/services/api/v3/work_package_collection_from_query_service.rb+++ b/app/services/api/v3/work_package_collection_from_query_service.rb@@ -125,7 +125,7 @@ module APIenddef format_query_sums(sums)- OpenStruct.new(format_column_keys(sums).merge(available_custom_fields: WorkPackageCustomField.summable.to_a))+ Hashie::Mash.new(format_column_keys(sums).merge(available_custom_fields: WorkPackageCustomField.summable.to_a))enddef format_column_keys(hash_by_column)diff --git a/lib/api/utilities/meta_property.rb b/lib/api/utilities/meta_property.rbindex 1adf15bce10..326a97d3da0 100644--- a/lib/api/utilities/meta_property.rb+++ b/lib/api/utilities/meta_property.rb@@ -58,7 +58,7 @@ module APIprotecteddef meta_representer- meta_representer_class.create(meta || OpenStruct.new, current_user: current_user)+ meta_representer_class.create(meta || Hashie::Mash.new, current_user: current_user)enddef meta_representer_classdiff --git a/lib/api/v3/projects/project_representer.rb b/lib/api/v3/projects/project_representer.rbindex 6584f5ec7c6..9404c5711af 100644--- a/lib/api/v3/projects/project_representer.rb+++ b/lib/api/v3/projects/project_representer.rb@@ -58,11 +58,11 @@ module APIstruct.status = struct.status_attributes# Remove temporary attributes workaround- struct.delete_field(:status_attributes)+ struct.delete(:status_attributes)# Remove nil status_explanation when passed as nilif struct.respond_to?(:status_explanation)- struct.delete_field(:status_explanation)+ struct.delete(:status_explanation)endendend@@ -216,7 +216,7 @@ module APIend},setter: ->(fragment:, represented:, **) {- represented.status_attributes ||= OpenStruct.new+ represented.status_attributes ||= Hashie::Mash.newlink = ::API::Decorators::LinkObject.new(represented.status_attributes,path: :project_status,@@ -235,7 +235,7 @@ module APIplain: false)},setter: ->(fragment:, represented:, **) {- represented.status_attributes ||= OpenStruct.new+ represented.status_attributes ||= Hashie::Mash.newrepresented.status_attributes[:explanation] = fragment["raw"]}diff --git a/spec/lib/api/v3/projects/project_payload_representer_parsing_spec.rb b/spec/lib/api/v3/projects/project_payload_representer_parsing_spec.rbindex 1215ce2fafe..5884b7a4060 100644--- a/spec/lib/api/v3/projects/project_payload_representer_parsing_spec.rb+++ b/spec/lib/api/v3/projects/project_payload_representer_parsing_spec.rb@@ -32,7 +32,7 @@ describe ::API::V3::Projects::ProjectPayloadRepresenter, 'parsing' doinclude ::API::V3::Utilities::PathHelperlet(:object) do- OpenStruct.new available_custom_fields: []+ Hashie::Mash.new available_custom_fields: []endlet(:user) { build_stubbed(:user) }let(:representer) do@@ -117,16 +117,16 @@ describe ::API::V3::Projects::ProjectPayloadRepresenter, 'parsing' doendit 'does set status to nil' do- project = representer.from_hash(hash).to_h+ project = representer.from_hash(hash)expect(project).to have_key(:status)status = project[:status]- expect(status.to_h)+ expect(status).to have_key(:code)- expect(status.to_h)+ expect(status).not_to have_key(:explanation)expect(status[:code])@@ -150,7 +150,7 @@ describe ::API::V3::Projects::ProjectPayloadRepresenter, 'parsing' doendit 'sets the parent_id to the value' do- project = representer.from_hash(hash).to_h+ project = representer.from_hash(hash)expect(project[:parent_id]).to eq "5"@@ -169,7 +169,7 @@ describe ::API::V3::Projects::ProjectPayloadRepresenter, 'parsing' doendit 'sets the parent_id to nil' do- project = representer.from_hash(hash).to_h+ project = representer.from_hash(hash)expect(project).to have_key(:parent_id)@@ -191,7 +191,7 @@ describe ::API::V3::Projects::ProjectPayloadRepresenter, 'parsing' doendit 'omits the parent information' do- project = representer.from_hash(hash).to_h+ project = representer.from_hash(hash)expect(project).not_to have_key(:parent_id)diff --git a/spec/services/api/v3/work_package_collection_from_query_service_spec.rb b/spec/services/api/v3/work_package_collection_from_query_service_spec.rbindex 7e1ce78ac1b..8cdbd387d8e 100644--- a/spec/services/api/v3/work_package_collection_from_query_service_spec.rb+++ b/spec/services/api/v3/work_package_collection_from_query_service_spec.rb@@ -250,7 +250,7 @@ describe ::API::V3::WorkPackageCollectionFromQueryService,.to receive(:summable).and_return(custom_fields)- expected = OpenStruct.new(estimated_hours: 0.0, available_custom_fields: custom_fields)+ expected = Hashie::Mash.new(estimated_hours: 0.0, available_custom_fields: custom_fields)expect(subject.total_sums).to eq(expected)