Commit 1144b70a authored by Tomasz Maczukin's avatar Tomasz Maczukin
Browse files

Change update_forks_visibility_level into after_update hook in Project model

parent 04fbc8c77b4d
......@@ -61,6 +61,19 @@ def set_last_activity_at
update_column(:last_activity_at, self.created_at)
end
# update visibility_levet of forks
after_update :update_forks_visibility_level
def update_forks_visibility_level
return unless visibility_level < visibility_level_was
forks.each do |forked_project|
if forked_project.visibility_level > visibility_level
forked_project.visibility_level = visibility_level
forked_project.save!
end
end
end
ActsAsTaggableOn.strict_case_match = true
acts_as_taggable_on :tags
......
......@@ -13,7 +13,6 @@ def execute
end
return false unless visibility_level_allowed?(new_visibility)
update_forks_visibility_level(new_visibility.to_i)
end
new_branch = params[:default_branch]
......@@ -42,18 +41,5 @@ def visibility_level_allowed?(level)
false
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
forked_project.visibility_level = new_level
forked_project.save!
end
end
end
end
end
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