summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-03-08 07:03:53 -0800
committerStan Hu <stanhu@gmail.com>2018-03-08 07:03:53 -0800
commit9c8e9046c7a10ff761a09697610eb52fd6578b88 (patch)
tree3d79020154ebcddec66e96292d561c1533c17f4e
parentcb1538bba7afac965f6ba2b09e8b94afdcdd7fbc (diff)
downloadgitlab-ce-9c8e9046c7a10ff761a09697610eb52fd6578b88.tar.gz
Fix Error 500 when updating a projectsh-fix-update-service
If no parameters were specified for project features but Wikis were disabled, we would get "NoMethodError: undefined method `[]' for nil:NilClass". Closes #44019
-rw-r--r--app/services/projects/update_service.rb2
-rw-r--r--spec/services/projects/update_service_spec.rb9
2 files changed, 10 insertions, 1 deletions
diff --git a/app/services/projects/update_service.rb b/app/services/projects/update_service.rb
index 379a8068023..5f2615a2c01 100644
--- a/app/services/projects/update_service.rb
+++ b/app/services/projects/update_service.rb
@@ -58,7 +58,7 @@ module Projects
def enabling_wiki?
return false if @project.wiki_enabled?
- params[:project_feature_attributes][:wiki_access_level].to_i > ProjectFeature::DISABLED
+ params.dig(:project_feature_attributes, :wiki_access_level).to_i > ProjectFeature::DISABLED
end
def ensure_wiki_exists
diff --git a/spec/services/projects/update_service_spec.rb b/spec/services/projects/update_service_spec.rb
index ad5a289290c..d454ac0bda5 100644
--- a/spec/services/projects/update_service_spec.rb
+++ b/spec/services/projects/update_service_spec.rb
@@ -132,6 +132,15 @@ describe Projects::UpdateService do
expect(result).to eq({ status: :success })
expect(project.wiki_repository_exists?).to be false
end
+
+ it 'handles empty project feature attributes' do
+ project.project_feature.update(wiki_access_level: ProjectFeature::DISABLED)
+
+ result = update_project(project, user, { name: 'test1' })
+
+ expect(result).to eq({ status: :success })
+ expect(project.wiki_repository_exists?).to be false
+ end
end
context 'when enabling a wiki' do