Skip to content

Fix project feature being deleted when updating project with invalid visibility level

Felipe Artur requested to merge issue_37640 into master

fix #37640 (closed)

This was being caused in accepts_nested_attributes_for :project_feature in Project model.

Using project.assign_attributes in Projects::UpdateService was setting project_id to nil in ProjectFeature record.
Check the example below:

pry(main)> p.assign_attributes({"project_feature_attributes"=>{"builds_access_level"=>"20", "issues_access_level"=>"20", "merge_requests_access_level"=>"20", "repository_access_level"=>"20", "snippets_access_level"=>"20", "wiki_access_level"=>"20"}})
   (0.2ms)  BEGIN
  SQL (0.4ms)  UPDATE "project_features" SET "project_id" = $1, "updated_at" = $2 WHERE "project_features"."id" = $3  [["project_id", nil], ["updated_at", "2017-09-12 19:43:09.181247"], ["id", 59]]
   (2.7ms)  COMMIT
Edited by Felipe Artur

Merge request reports

Loading