diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2018-06-05 16:46:43 +0000 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2018-06-05 16:46:43 +0000 |
commit | ced0b4453e1928353b123051dab8ca1ed0137b0e (patch) | |
tree | ee98e550f5d3b2e77a275a86806fe67dd6cc2bdc /spec/models/ci | |
parent | da246582db2577107ffdfbcf5741daccc8e029c0 (diff) | |
parent | 1fc6935e642a31cebc31c3c8dbc258a9b6467e0a (diff) | |
download | gitlab-ce-ced0b4453e1928353b123051dab8ca1ed0137b0e.tar.gz |
Merge branch 'master' into 'backstage/gb/use-persisted-stages-to-improve-pipelines-table'
# Conflicts:
# db/schema.rb
Diffstat (limited to 'spec/models/ci')
-rw-r--r-- | spec/models/ci/runner_spec.rb | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/spec/models/ci/runner_spec.rb b/spec/models/ci/runner_spec.rb index 0f072aa1719..f6433234573 100644 --- a/spec/models/ci/runner_spec.rb +++ b/spec/models/ci/runner_spec.rb @@ -549,7 +549,7 @@ describe Ci::Runner do end describe '#update_cached_info' do - let(:runner) { create(:ci_runner) } + let(:runner) { create(:ci_runner, :project) } subject { runner.update_cached_info(architecture: '18-bit') } @@ -570,17 +570,22 @@ describe Ci::Runner do runner.contacted_at = 2.hours.ago end - it 'updates database' do - expect_redis_update + context 'with invalid runner' do + before do + runner.projects = [] + end + + it 'still updates redis cache and database' do + expect(runner).to be_invalid - expect { subject }.to change { runner.reload.read_attribute(:contacted_at) } - .and change { runner.reload.read_attribute(:architecture) } + expect_redis_update + does_db_update + end end - it 'updates cache' do + it 'updates redis cache and database' do expect_redis_update - - subject + does_db_update end end @@ -590,6 +595,11 @@ describe Ci::Runner do expect(redis).to receive(:set).with(redis_key, anything, any_args) end end + + def does_db_update + expect { subject }.to change { runner.reload.read_attribute(:contacted_at) } + .and change { runner.reload.read_attribute(:architecture) } + end end describe '#destroy' do |