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

Change update_forks_visibility_level into after_update hook in Project model

parent 945e4293
...@@ -61,6 +61,19 @@ class Project < ActiveRecord::Base ...@@ -61,6 +61,19 @@ class Project < ActiveRecord::Base
update_column(:last_activity_at, self.created_at) update_column(:last_activity_at, self.created_at)
end 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 ActsAsTaggableOn.strict_case_match = true
acts_as_taggable_on :tags acts_as_taggable_on :tags
......
...@@ -13,7 +13,6 @@ module Projects ...@@ -13,7 +13,6 @@ module Projects
end end
return false unless visibility_level_allowed?(new_visibility) return false unless visibility_level_allowed?(new_visibility)
update_forks_visibility_level(new_visibility.to_i)
end end
new_branch = params[:default_branch] new_branch = params[:default_branch]
...@@ -42,18 +41,5 @@ module Projects ...@@ -42,18 +41,5 @@ module Projects
false false
end 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
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