Prevent unnecessary forks iteration at parent update

This commit is contained in:
Tomasz Maczukin 2015-11-19 23:40:29 +01:00
parent 6f41e3d9ca
commit 945e4293cb

View file

@ -13,7 +13,7 @@ module Projects
end
return false unless visibility_level_allowed?(new_visibility)
update_forks_visibility_level(new_visibility)
update_forks_visibility_level(new_visibility.to_i)
end
new_branch = params[:default_branch]
@ -44,11 +44,13 @@ module Projects
end
def update_forks_visibility_level(new_level)
return unless new_level < project.visibility_level
project.forks.each do |forked_project|
fork_level = forked_project.visibility_level
if fork_level > new_level.to_i
forked_project.visibility_level = new_level.to_i
if fork_level > new_level
forked_project.visibility_level = new_level
forked_project.save!
end
end