Commit 6f41e3d9 authored by Tomasz Maczukin's avatar Tomasz Maczukin

Change forks method to has_many relation

parent e40c13ae
......@@ -97,9 +97,12 @@ class Project < ActiveRecord::Base
has_one :gitlab_issue_tracker_service, dependent: :destroy
has_one :external_wiki_service, dependent: :destroy
has_one :forked_project_link, dependent: :destroy, foreign_key: "forked_to_project_id"
has_one :forked_project_link, dependent: :destroy, foreign_key: "forked_to_project_id"
has_one :forked_from_project, through: :forked_project_link
has_many :forked_project_links, foreign_key: "forked_from_project_id"
has_many :forks, through: :forked_project_links, source: :forked_to_project
has_one :forked_from_project, through: :forked_project_link
# Merge Requests for target project should be removed with it
has_many :merge_requests, dependent: :destroy, foreign_key: 'target_project_id'
# Merge requests from source project should be kept when source project was removed
......@@ -734,10 +737,6 @@ class Project < ActiveRecord::Base
forks.count
end
def forks
ForkedProjectLink.where(forked_from_project_id: self.id)
end
def find_label(name)
labels.find_by(name: name)
end
......
......@@ -44,8 +44,7 @@ module Projects
end
def update_forks_visibility_level(new_level)
project.forks.each do |forked_link|
forked_project = forked_link.forked_to_project
project.forks.each do |forked_project|
fork_level = forked_project.visibility_level
if fork_level > new_level.to_i
......
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