diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-10-03 17:06:09 +0200 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-10-07 11:46:23 +0200 |
commit | f90b27da7777b0c72782d2a930f770e2f27757e2 (patch) | |
tree | 50f1d5b84e40c45c29a1be2b8150029da7db2d87 /spec/models/namespace_spec.rb | |
parent | 8160550439d2027c12d5556c8ce1f8afd250628a (diff) | |
download | gitlab-ce-f90b27da7777b0c72782d2a930f770e2f27757e2.tar.gz |
Find forks within users/namespaces using fork memberships
Diffstat (limited to 'spec/models/namespace_spec.rb')
-rw-r--r-- | spec/models/namespace_spec.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb index 3ea614776ca..2ebf6acd42a 100644 --- a/spec/models/namespace_spec.rb +++ b/spec/models/namespace_spec.rb @@ -1,6 +1,8 @@ require 'spec_helper' describe Namespace do + include ProjectForksHelper + let!(:namespace) { create(:namespace) } describe 'associations' do @@ -520,4 +522,25 @@ describe Namespace do end end end + + describe '#has_forks_of?' do + let(:project) { create(:project, :public) } + let!(:forked_project) { fork_project(project, namespace.owner, namespace: namespace) } + + before do + # Reset the fork network relation + project.reload + end + + it 'knows if there is a direct fork in the namespace' do + expect(namespace.find_fork_of(project)).to eq(forked_project) + end + + it 'knows when there is as fork-of-fork in the namespace' do + other_namespace = create(:namespace) + other_fork = fork_project(forked_project, other_namespace.owner, namespace: other_namespace) + + expect(other_namespace.find_fork_of(project)).to eq(other_fork) + end + end end |