summaryrefslogtreecommitdiff
path: root/spec/workers
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@vanlanduyt.co>2018-08-31 19:16:34 +0200
committerBob Van Landuyt <bob@vanlanduyt.co>2018-10-19 11:57:20 +0200
commitf3fba178b931cd2ba67f81ee667893cb84e7d42f (patch)
tree24c5a688880d5edd75642a7f16623124bde9fc22 /spec/workers
parent4321d70d24a6a7dc99f80fa4211ba6250504d99b (diff)
downloadgitlab-ce-f3fba178b931cd2ba67f81ee667893cb84e7d42f.tar.gz
Remove the `ForkedProjectLink` model
This removes the `ForkedProjectLink` model that has been replaced by the `ForkNetworkMember` and `ForkNetwork` combination. All existing relations have been adjusted to use these new models. The `forked_project_link` table has been dropped. The "Forks" count on the admin dashboard has been updated to count all `ForkNetworkMember` rows and deduct the number of `ForkNetwork` rows. This is because now the "root-project" of a fork network also has a `ForkNetworkMember` row. This count could become inaccurate when the root of a fork network is deleted.
Diffstat (limited to 'spec/workers')
-rw-r--r--spec/workers/namespaceless_project_destroy_worker_spec.rb4
-rw-r--r--spec/workers/rebase_worker_spec.rb12
-rw-r--r--spec/workers/repository_fork_worker_spec.rb32
3 files changed, 26 insertions, 22 deletions
diff --git a/spec/workers/namespaceless_project_destroy_worker_spec.rb b/spec/workers/namespaceless_project_destroy_worker_spec.rb
index eec110dfbfb..2f21a1321e1 100644
--- a/spec/workers/namespaceless_project_destroy_worker_spec.rb
+++ b/spec/workers/namespaceless_project_destroy_worker_spec.rb
@@ -71,10 +71,10 @@ describe NamespacelessProjectDestroyWorker do
expect(merge_request.reload).to be_closed
end
- it 'destroys the link' do
+ it 'destroys fork network members' do
subject.perform(project.id)
- expect(parent_project.forked_project_links).to be_empty
+ expect(parent_project.forked_to_members).to be_empty
end
end
end
diff --git a/spec/workers/rebase_worker_spec.rb b/spec/workers/rebase_worker_spec.rb
index 20aff020dbb..936b9deaecc 100644
--- a/spec/workers/rebase_worker_spec.rb
+++ b/spec/workers/rebase_worker_spec.rb
@@ -1,25 +1,23 @@
require 'spec_helper'
describe RebaseWorker, '#perform' do
+ include ProjectForksHelper
+
context 'when rebasing an MR from a fork where upstream has protected branches' do
let(:upstream_project) { create(:project, :repository) }
- let(:fork_project) { create(:project, :repository) }
+ let(:forked_project) { fork_project(upstream_project, nil, repository: true) }
let(:merge_request) do
create(:merge_request,
- source_project: fork_project,
+ source_project: forked_project,
source_branch: 'feature_conflict',
target_project: upstream_project,
target_branch: 'master')
end
- before do
- create(:forked_project_link, forked_to_project: fork_project, forked_from_project: upstream_project)
- end
-
it 'sets the correct project for running hooks' do
expect(MergeRequests::RebaseService)
- .to receive(:new).with(fork_project, merge_request.author).and_call_original
+ .to receive(:new).with(forked_project, merge_request.author).and_call_original
subject.perform(merge_request, merge_request.author)
end
diff --git a/spec/workers/repository_fork_worker_spec.rb b/spec/workers/repository_fork_worker_spec.rb
index ac8716ecfb1..781f91ac9ca 100644
--- a/spec/workers/repository_fork_worker_spec.rb
+++ b/spec/workers/repository_fork_worker_spec.rb
@@ -1,6 +1,8 @@
require 'spec_helper'
describe RepositoryForkWorker do
+ include ProjectForksHelper
+
describe 'modules' do
it 'includes ProjectImportOptions' do
expect(described_class).to include_module(ProjectImportOptions)
@@ -8,9 +10,13 @@ describe RepositoryForkWorker do
end
describe "#perform" do
- let(:project) { create(:project, :repository) }
+ let(:project) { create(:project, :public, :repository) }
let(:shell) { Gitlab::Shell.new }
- let(:fork_project) { create(:project, :repository, :import_scheduled, forked_from_project: project) }
+ let(:forked_project) { create(:project, :repository, :import_scheduled) }
+
+ before do
+ fork_project(project, forked_project.creator, target_project: forked_project, repository: true)
+ end
shared_examples 'RepositoryForkWorker performing' do
before do
@@ -21,8 +27,8 @@ describe RepositoryForkWorker do
expect(shell).to receive(:fork_repository).with(
'default',
project.disk_path,
- fork_project.repository_storage,
- fork_project.disk_path
+ forked_project.repository_storage,
+ forked_project.disk_path
)
end
@@ -49,28 +55,28 @@ describe RepositoryForkWorker do
perform!
- expect(fork_project.protected_branches.first.name).to eq(fork_project.default_branch)
+ expect(forked_project.protected_branches.first.name).to eq(forked_project.default_branch)
end
it 'flushes various caches' do
expect_fork_repository.and_return(true)
# Works around https://github.com/rspec/rspec-mocks/issues/910
- expect(Project).to receive(:find).with(fork_project.id).and_return(fork_project)
- expect(fork_project.repository).to receive(:expire_emptiness_caches)
+ expect(Project).to receive(:find).with(forked_project.id).and_return(forked_project)
+ expect(forked_project.repository).to receive(:expire_emptiness_caches)
.and_call_original
- expect(fork_project.repository).to receive(:expire_exists_cache)
+ expect(forked_project.repository).to receive(:expire_exists_cache)
.and_call_original
- expect(fork_project.wiki.repository).to receive(:expire_emptiness_caches)
+ expect(forked_project.wiki.repository).to receive(:expire_emptiness_caches)
.and_call_original
- expect(fork_project.wiki.repository).to receive(:expire_exists_cache)
+ expect(forked_project.wiki.repository).to receive(:expire_exists_cache)
.and_call_original
perform!
end
it "handles bad fork" do
- error_message = "Unable to fork project #{fork_project.id} for repository #{project.disk_path} -> #{fork_project.disk_path}"
+ error_message = "Unable to fork project #{forked_project.id} for repository #{project.disk_path} -> #{forked_project.disk_path}"
expect_fork_repository.and_return(false)
@@ -80,7 +86,7 @@ describe RepositoryForkWorker do
context 'only project ID passed' do
def perform!
- subject.perform(fork_project.id)
+ subject.perform(forked_project.id)
end
it_behaves_like 'RepositoryForkWorker performing'
@@ -88,7 +94,7 @@ describe RepositoryForkWorker do
context 'project ID, storage and repo paths passed' do
def perform!
- subject.perform(fork_project.id, TestEnv.repos_path, project.disk_path)
+ subject.perform(forked_project.id, TestEnv.repos_path, project.disk_path)
end
it_behaves_like 'RepositoryForkWorker performing'