Commit 9c8e9046 authored by Stan Hu's avatar Stan Hu

Fix Error 500 when updating a project

If no parameters were specified for project features but Wikis were disabled,
we would get "NoMethodError: undefined method `[]' for nil:NilClass".

Closes #44019
parent cb1538bb
...@@ -58,7 +58,7 @@ module Projects ...@@ -58,7 +58,7 @@ module Projects
def enabling_wiki? def enabling_wiki?
return false if @project.wiki_enabled? 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 end
def ensure_wiki_exists def ensure_wiki_exists
......
...@@ -132,6 +132,15 @@ describe Projects::UpdateService do ...@@ -132,6 +132,15 @@ describe Projects::UpdateService do
expect(result).to eq({ status: :success }) expect(result).to eq({ status: :success })
expect(project.wiki_repository_exists?).to be false expect(project.wiki_repository_exists?).to be false
end 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 end
context 'when enabling a wiki' do context 'when enabling a wiki' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment