2017-12-20 19:31:16 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe ResetProjectCacheService do
|
|
|
|
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
|
2018-01-04 13:40:07 -05:00
|
|
|
project.jobs_cache_index = nil
|
2017-12-22 15:28:25 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'sets project cache_index to one' do
|
2018-01-04 13:40:07 -05:00
|
|
|
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
|
2018-01-04 13:40:07 -05:00
|
|
|
project.update_attributes(jobs_cache_index: 1)
|
2017-12-22 15:28:25 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'increments project cache index' do
|
2018-01-04 13:40:07 -05:00
|
|
|
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
|