提交 9c8e9046 编写于 作者: S 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
上级 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% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册