summaryrefslogtreecommitdiff
path: root/spec/services/projects
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@vanlanduyt.co>2017-09-28 16:38:12 +0200
committerBob Van Landuyt <bob@vanlanduyt.co>2017-10-07 11:46:23 +0200
commitd328007214786c7137c31d2c73e9ee76b025e6ed (patch)
treefe4ec118148b7397890f86c6b2982ce667086c38 /spec/services/projects
parent20727db1702849b78e6714197f16f602f68cecf8 (diff)
downloadgitlab-ce-d328007214786c7137c31d2c73e9ee76b025e6ed.tar.gz
Create a fork network when forking a project
When no fork network exists for the source projects, we create a new one with the correct source
Diffstat (limited to 'spec/services/projects')
-rw-r--r--spec/services/projects/fork_service_spec.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/services/projects/fork_service_spec.rb b/spec/services/projects/fork_service_spec.rb
index fa9d6969830..a5ec4111b70 100644
--- a/spec/services/projects/fork_service_spec.rb
+++ b/spec/services/projects/fork_service_spec.rb
@@ -60,6 +60,33 @@ describe Projects::ForkService do
expect(@from_project.forks_count).to eq(1)
end
+
+ it 'creates a fork network with the new project and the root project set' do
+ to_project
+ fork_network = @from_project.reload.fork_network
+
+ expect(fork_network).not_to be_nil
+ expect(fork_network.root_project).to eq(@from_project)
+ expect(fork_network.projects).to contain_exactly(@from_project, to_project)
+ end
+ end
+
+ context 'creating a fork of a fork' do
+ let(:from_forked_project) { fork_project(@from_project, @to_user) }
+ let(:other_namespace) do
+ group = create(:group)
+ group.add_owner(@to_user)
+ group
+ end
+ let(:to_project) { fork_project(from_forked_project, @to_user, namespace: other_namespace) }
+
+ it 'sets the root of the network to the root project' do
+ expect(to_project.fork_network.root_project).to eq(@from_project)
+ end
+
+ it 'sets the forked_from_project on the membership' do
+ expect(to_project.fork_network_member.forked_from_project).to eq(from_forked_project)
+ end
end
end