summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2018-05-28 18:17:18 +0200
committerKamil Trzciński <ayufan@ayufan.eu>2018-06-05 10:28:22 +0200
commit36fbe1422666cb5553ccde9e534bb2a504f0f2c1 (patch)
tree71ce34a44e20b4a84bae51ab6bf7a9729c2fc6f9 /spec/models
parent3571b97effd81f9a84f238f918544c6e5c625b76 (diff)
downloadgitlab-ce-36fbe1422666cb5553ccde9e534bb2a504f0f2c1.tar.gz
Do not validate cached dataoptimise-runner-update-cached-info
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/ci/runner_spec.rb26
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