Commit 8a318984 authored by Gabriel Mazetto's avatar Gabriel Mazetto

A few more specs

parent 90719161
require 'spec_helper'
describe Geo::ScheduleRepoCreateService, services: true do
let(:project) { create(:project) }
subject { described_class.new(project_id: project.id) }
describe '#execute' do
it 'schedules the repository creation' do
Sidekiq::Worker.clear_all
Sidekiq::Testing.fake! do
expect{ subject.execute }.to change(GeoRepositoryCreateWorker.jobs, :size).by(1)
end
end
end
end
......@@ -5,11 +5,10 @@ describe GeoRepositoryCreateWorker do
let(:project) { create :project }
let(:perform!) { subject.perform(project.id) }
before { expect(Project).to receive(:find).at_least(:once).with(project.id) { project } }
context 'when no repository' do
before do
expect(Project).to receive(:find).at_least(:once).with(project.id) { project }
expect(project).to receive(:repository_exists?) { false }
end
before { expect(project).to receive(:repository_exists?) { false } }
it 'creates the repository' do
expect(project).to receive(:create_repository)
......@@ -17,4 +16,14 @@ describe GeoRepositoryCreateWorker do
perform!
end
end
context 'when repository exists' do
before { expect(project).to receive(:repository_exists?) { true } }
it 'does not try to create the repository again' do
expect(project).not_to receive(:create_repository)
perform!
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment