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 parse api request with application/hal+json content type
Christophe Bliardbf687d9d222f
diff --git a/lib/api/root.rb b/lib/api/root.rbindex fe64cde5e91..b13d1697767 100644--- a/lib/api/root.rb+++ b/lib/api/root.rb@@ -31,6 +31,7 @@ module APIcontent_type "hal+json", "application/hal+json; charset=utf-8"format "hal+json"formatter "hal+json", API::Formatter.new+ parser "hal+json", Grape::Parser::Jsondefault_format "hal+json"parser :json, API::V3::Parser.newdiff --git a/spec/requests/api/v3/root_resource_spec.rb b/spec/requests/api/v3/root_resource_spec.rbindex 46501b452b6..069ca3dbe22 100644--- a/spec/requests/api/v3/root_resource_spec.rb+++ b/spec/requests/api/v3/root_resource_spec.rb@@ -86,6 +86,17 @@ RSpec.describe "API v3 Root resource" doexpect(subject).to have_json_path("instanceName")endend++ context "with content-type application/hal+json" do+ before do+ header("Content-Type", "application/hal+json")+ end++ it "responds with 200" do+ get get_path+ expect(response).to have_http_status(:ok)+ end+ endendendenddiff --git a/spec/requests/api/v3/work_packages/update_resource_spec.rb b/spec/requests/api/v3/work_packages/update_resource_spec.rbindex 9113592e44f..73fa9d24a45 100644--- a/spec/requests/api/v3/work_packages/update_resource_spec.rb+++ b/spec/requests/api/v3/work_packages/update_resource_spec.rb@@ -69,6 +69,12 @@ RSpec.describe "API v3 Work package resource",endend+ shared_context "with application/hal+json content type" do+ before do+ header("Content-Type", "application/hal+json")+ end+ end+context "user without needed permissions" docontext "no permission to see the work package" dolet(:work_package) { create(:work_package) }@@ -157,6 +163,7 @@ RSpec.describe "API v3 Work package resource",context "subject" dolet(:params) { valid_params.merge(subject: "Updated subject") }+ include_context "with application/hal+json content type"include_context "patch request"it { expect(response).to have_http_status(:ok) }