Implement ResetProjectCacheService
This commit is contained in:
parent
f58cc2ee60
commit
0a002e230b
2 changed files with 19 additions and 2 deletions
|
@ -1,4 +1,5 @@
|
||||||
class ResetProjectCacheService < BaseService
|
class ResetProjectCacheService < BaseService
|
||||||
def execute
|
def execute
|
||||||
|
@project.increment!(:cache_index)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,7 +6,23 @@ describe ResetProjectCacheService do
|
||||||
|
|
||||||
subject { described_class.new(project, user).execute }
|
subject { described_class.new(project, user).execute }
|
||||||
|
|
||||||
it "resets project cache" do
|
context 'when project cache_index is nil' do
|
||||||
fail
|
before do
|
||||||
|
project.cache_index = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'sets project cache_index to one' do
|
||||||
|
expect { subject }.to change { project.reload.cache_index }.from(nil).to(1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when project cache_index is a numeric value' do
|
||||||
|
before do
|
||||||
|
project.update_attributes(cache_index: 1)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'increments project cache index' do
|
||||||
|
expect { subject }.to change { project.reload.cache_index }.by(1)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue