From 0a002e230badf96f5c89d55945ddd85113edd628 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20=C4=8Cupi=C4=87?= Date: Fri, 22 Dec 2017 21:28:25 +0100 Subject: [PATCH] Implement ResetProjectCacheService --- app/services/reset_project_cache_service.rb | 1 + .../reset_project_cache_service_spec.rb | 20 +++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/app/services/reset_project_cache_service.rb b/app/services/reset_project_cache_service.rb index 85ba6d953a2..0886c6b8315 100644 --- a/app/services/reset_project_cache_service.rb +++ b/app/services/reset_project_cache_service.rb @@ -1,4 +1,5 @@ class ResetProjectCacheService < BaseService def execute + @project.increment!(:cache_index) end end diff --git a/spec/services/reset_project_cache_service_spec.rb b/spec/services/reset_project_cache_service_spec.rb index 9623035a5a4..df969d08f39 100644 --- a/spec/services/reset_project_cache_service_spec.rb +++ b/spec/services/reset_project_cache_service_spec.rb @@ -6,7 +6,23 @@ describe ResetProjectCacheService do subject { described_class.new(project, user).execute } - it "resets project cache" do - fail + context 'when project cache_index is nil' do + 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