diff options
author | Tomasz Maczukin <tomasz@maczukin.pl> | 2015-11-20 02:13:56 +0300 |
---|---|---|
committer | Tomasz Maczukin <tomasz@maczukin.pl> | 2015-11-20 02:13:56 +0300 |
commit | 1144b70ab624ee1c1e7f2de0c92de021a7b5ea8e (patch) | |
tree | b5003704b9f44b1aa5e1d4db44ea607fb5238bfd /app | |
parent | 945e4293cb8f745b2e1a1aebdcf4df3eeba338cc (diff) |
Change update_forks_visibility_level into after_update hook in Project model
Diffstat (limited to 'app')
-rw-r--r-- | app/models/project.rb | 13 | ||||
-rw-r--r-- | app/services/projects/update_service.rb | 14 |
2 files changed, 13 insertions, 14 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 2562c441abe..b8495c6cd4f 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -61,6 +61,19 @@ class Project < ActiveRecord::Base 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 diff --git a/app/services/projects/update_service.rb b/app/services/projects/update_service.rb index cd7a8b18218..895e089bea3 100644 --- a/app/services/projects/update_service.rb +++ b/app/services/projects/update_service.rb @@ -13,7 +13,6 @@ module Projects 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 @@ module Projects 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 |