Commit 0a002e23 authored by Matija Čupić's avatar Matija Čupić

Implement ResetProjectCacheService

parent f58cc2ee
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 ...@@ -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
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