summaryrefslogtreecommitdiff
path: root/spec/services/reset_project_cache_service_spec.rb
blob: 1490ad5fe3be85fa5fcf2ba16c0667c5b4ac459d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
require 'spec_helper'

describe ResetProjectCacheService do
  let(:project) { create(:project) }
  let(:user) { create(:user) }

  subject { described_class.new(project, user).execute }

  context 'when project cache_index is nil' do
    before do
      project.jobs_cache_index = nil
    end

    it 'sets project cache_index to one' do
      expect { subject }.to change { project.reload.jobs_cache_index }.from(nil).to(1)
    end
  end

  context 'when project cache_index is a numeric value' do
    before do
      project.update(jobs_cache_index: 1)
    end

    it 'increments project cache index' do
      expect { subject }.to change { project.reload.jobs_cache_index }.by(1)
    end
  end
end