debian-mirror-gitlab/spec/workers/repository_fork_worker_spec.rb

61 lines
1.6 KiB
Ruby
Raw Normal View History

2015-09-25 12:07:36 +05:30
require 'spec_helper'
describe RepositoryForkWorker do
2017-08-17 22:00:37 +05:30
let(:project) { create(:project, :repository) }
let(:fork_project) { create(:project, :repository, forked_from_project: project) }
2016-06-02 11:05:42 +05:30
let(:shell) { Gitlab::Shell.new }
2015-09-25 12:07:36 +05:30
2017-08-17 22:00:37 +05:30
subject { described_class.new }
2015-09-25 12:07:36 +05:30
2016-06-02 11:05:42 +05:30
before do
allow(subject).to receive(:gitlab_shell).and_return(shell)
end
2015-09-25 12:07:36 +05:30
describe "#perform" do
it "creates a new repository from a fork" do
2016-06-02 11:05:42 +05:30
expect(shell).to receive(:fork_repository).with(
2016-08-24 12:49:21 +05:30
'/test/path',
2017-08-17 22:00:37 +05:30
project.full_path,
2016-08-24 12:49:21 +05:30
project.repository_storage_path,
2017-08-17 22:00:37 +05:30
fork_project.namespace.full_path
2015-12-23 02:04:40 +05:30
).and_return(true)
2015-09-25 12:07:36 +05:30
2015-12-23 02:04:40 +05:30
subject.perform(
project.id,
2016-08-24 12:49:21 +05:30
'/test/path',
2017-08-17 22:00:37 +05:30
project.full_path,
fork_project.namespace.full_path)
2015-09-25 12:07:36 +05:30
end
2016-06-02 11:05:42 +05:30
it 'flushes various caches' do
2016-08-24 12:49:21 +05:30
expect(shell).to receive(:fork_repository).with(
'/test/path',
2017-08-17 22:00:37 +05:30
project.full_path,
2016-08-24 12:49:21 +05:30
project.repository_storage_path,
2017-08-17 22:00:37 +05:30
fork_project.namespace.full_path
2016-08-24 12:49:21 +05:30
).and_return(true)
2016-04-02 18:10:28 +05:30
expect_any_instance_of(Repository).to receive(:expire_emptiness_caches).
and_call_original
2016-06-02 11:05:42 +05:30
expect_any_instance_of(Repository).to receive(:expire_exists_cache).
and_call_original
2017-08-17 22:00:37 +05:30
subject.perform(project.id, '/test/path', project.full_path,
fork_project.namespace.full_path)
2016-04-02 18:10:28 +05:30
end
2015-09-25 12:07:36 +05:30
it "handles bad fork" do
2016-06-02 11:05:42 +05:30
expect(shell).to receive(:fork_repository).and_return(false)
expect(subject.logger).to receive(:error)
2015-12-23 02:04:40 +05:30
subject.perform(
project.id,
2016-08-24 12:49:21 +05:30
'/test/path',
2017-08-17 22:00:37 +05:30
project.full_path,
fork_project.namespace.full_path)
2015-09-25 12:07:36 +05:30
end
end
end