gitlab-org--gitlab-foss/spec/services/reset_project_cache_service_spec.rb

31 lines
740 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2017-12-20 19:31:16 -05:00
require 'spec_helper'
RSpec.describe ResetProjectCacheService do
2017-12-20 19:31:16 -05:00
let(:project) { create(:project) }
let(:user) { create(:user) }
subject { described_class.new(project, user).execute }
2017-12-22 15:28:25 -05:00
context 'when project cache_index is nil' do
before do
project.jobs_cache_index = nil
2017-12-22 15:28:25 -05:00
end
it 'sets project cache_index to one' do
expect { subject }.to change { project.reload.jobs_cache_index }.from(nil).to(1)
2017-12-22 15:28:25 -05:00
end
end
context 'when project cache_index is a numeric value' do
before do
project.update!(jobs_cache_index: 1)
2017-12-22 15:28:25 -05:00
end
it 'increments project cache index' do
expect { subject }.to change { project.reload.jobs_cache_index }.by(1)
2017-12-22 15:28:25 -05:00
end
2017-12-20 19:31:16 -05:00
end
end