gitlab-org--gitlab-foss/spec/workers/repository_fork_worker_spec.rb

43 lines
1.2 KiB
Ruby
Raw Normal View History

require 'spec_helper'
describe RepositoryForkWorker do
let(:project) { create(:project) }
let(:fork_project) { create(:project, forked_from_project: project) }
subject { RepositoryForkWorker.new }
describe "#perform" do
it "creates a new repository from a fork" do
expect_any_instance_of(Gitlab::Shell).to receive(:fork_repository).with(
2015-12-15 02:53:52 +00:00
project.path_with_namespace,
fork_project.namespace.path
).and_return(true)
2015-12-15 02:53:52 +00:00
subject.perform(
project.id,
project.path_with_namespace,
fork_project.namespace.path)
end
it 'flushes the empty caches' do
expect_any_instance_of(Gitlab::Shell).to receive(:fork_repository).
with(project.path_with_namespace, fork_project.namespace.path).
and_return(true)
expect_any_instance_of(Repository).to receive(:expire_emptiness_caches).
and_call_original
subject.perform(project.id, project.path_with_namespace,
fork_project.namespace.path)
end
it "handles bad fork" do
expect_any_instance_of(Gitlab::Shell).to receive(:fork_repository).and_return(false)
2015-12-15 02:53:52 +00:00
subject.perform(
project.id,
project.path_with_namespace,
fork_project.namespace.path)
end
end
end