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 string attributes for custom_field_changes to align it with non custom field attribute changes. Fix specs.

Dombi Attilab94e3cb75731
diff --git a/spec/requests/api/v3/projects/update_resource_spec.rb b/spec/requests/api/v3/projects/update_resource_spec.rb
index e0db2b45dcd..47d2bb2e285 100644
--- a/spec/requests/api/v3/projects/update_resource_spec.rb
+++ b/spec/requests/api/v3/projects/update_resource_spec.rb
@@ -341,8 +341,8 @@ RSpec.describe "API v3 Project resource update", content_type: :json do
end
it "responds with 200 OK" do
- expect(last_response.status)
- .to eq(200)
+ expect(last_response)
+ .to have_http_status(200)
end
it "archives the project" do
@@ -360,8 +360,8 @@ RSpec.describe "API v3 Project resource update", content_type: :json do
let(:permissions) { [:edit_project] }
it "responds with 403" do
- expect(last_response.status)
- .to eq(403)
+ expect(last_response)
+ .to have_http_status(403)
end
it "does not alter the project" do
@@ -374,8 +374,8 @@ RSpec.describe "API v3 Project resource update", content_type: :json do
let(:permissions) { [:archive_project] }
it "responds with 200 OK" do
- expect(last_response.status)
- .to eq(200)
+ expect(last_response)
+ .to have_http_status(200)
end
it "archives the project" do
@@ -394,8 +394,8 @@ RSpec.describe "API v3 Project resource update", content_type: :json do
let(:child_project) { create(:project) }
it "responds with 422 (and not 403?)" do
- expect(last_response.status)
- .to eq(422)
+ expect(last_response)
+ .to have_http_status(422)
end
it "does not alter the project" do
@@ -429,8 +429,8 @@ RSpec.describe "API v3 Project resource update", content_type: :json do
end
it "responds with 200 OK" do
- expect(last_response.status)
- .to eq(200)
+ expect(last_response)
+ .to have_http_status(200)
end
it "sets the cf value" do
@@ -453,8 +453,8 @@ RSpec.describe "API v3 Project resource update", content_type: :json do
let(:permissions) { [:edit_project] }
it "responds with 403" do
- expect(last_response.status)
- .to eq(403)
+ expect(last_response)
+ .to have_http_status(403)
end
end
@@ -462,17 +462,26 @@ RSpec.describe "API v3 Project resource update", content_type: :json do
let(:permissions) { [:archive_project] }
it "responds with 403" do
- expect(last_response.status)
- .to eq(403)
+ expect(last_response)
+ .to have_http_status(403)
end
end
- context "for a user with both archive_project and edit_project permissions" do
+ context "for a user with archive_project and edit_project permissions" do
let(:permissions) { %i[archive_project edit_project] }
+ it "responds with 422 unprocessable_entity" do
+ expect(last_response)
+ .to have_http_status(422)
+ end
+ end
+
+ context "for a user with archive_project and edit_project and edit_project_attributes permissions" do
+ let(:permissions) { %i[archive_project edit_project edit_project_attributes] }
+
it "responds with 200 OK" do
- expect(last_response.status)
- .to eq(200)
+ expect(last_response)
+ .to have_http_status(200)
end
end
end
@@ -499,8 +508,8 @@ RSpec.describe "API v3 Project resource update", content_type: :json do
end
it "responds with 200 OK" do
- expect(last_response.status)
- .to eq(200)
+ expect(last_response)
+ .to have_http_status(200)
end
it "unarchives the project" do
@@ -518,8 +527,8 @@ RSpec.describe "API v3 Project resource update", content_type: :json do
let(:permissions) { %i[archive_project edit_project] }
it "responds with 404" do
- expect(last_response.status)
- .to eq(404)
+ expect(last_response)
+ .to have_http_status(404)
end
it "does not alter the project" do
diff --git a/spec/support/shared/acts_as_customizable.rb b/spec/support/shared/acts_as_customizable.rb
index 58155b4577b..0ceb7a155eb 100644
--- a/spec/support/shared/acts_as_customizable.rb
+++ b/spec/support/shared/acts_as_customizable.rb
@@ -45,7 +45,7 @@ RSpec.shared_examples_for "acts_as_customizable included" do
it "returns the field changes" do
model_instance.custom_field_values = { custom_field.id => "test" }
expect(model_instance.custom_field_changes)
- .to eq({ custom_field.attribute_name.to_sym => [nil, "test"] })
+ .to eq({ custom_field.attribute_name => [nil, "test"] })
end
end
end
@@ -54,7 +54,7 @@ RSpec.shared_examples_for "acts_as_customizable included" do
it "returns the field changes" do
model_instance.custom_field_values = { custom_field.id => "test" }
expect(model_instance.custom_field_changes)
- .to eq({ custom_field.attribute_name.to_sym => [nil, "test"] })
+ .to eq({ custom_field.attribute_name => [nil, "test"] })
end
end
@@ -67,7 +67,7 @@ RSpec.shared_examples_for "acts_as_customizable included" do
it "returns the field changes" do
model_instance.custom_field_values = { custom_field.id => "test2" }
expect(model_instance.custom_field_changes)
- .to eq({ custom_field.attribute_name.to_sym => ["test", "test2"] })
+ .to eq({ custom_field.attribute_name => ["test", "test2"] })
end
end
@@ -92,7 +92,7 @@ RSpec.shared_examples_for "acts_as_customizable included" do
it "returns the field changes" do
model_instance.custom_field_values = { custom_field.id => nil }
expect(model_instance.custom_field_changes)
- .to eq({ custom_field.attribute_name.to_sym => ["test", nil] })
+ .to eq({ custom_field.attribute_name => ["test", nil] })
end
end
end