Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatija Čupić <matteeyah@gmail.com>2018-05-17 14:06:23 +0300
committerMatija Čupić <matteeyah@gmail.com>2018-05-17 14:06:23 +0300
commit13298bb3d1f1d8f10be5568d1617348e6ec0c0b1 (patch)
tree84dff82fcc681a66224d0acf29bf200776cdaa33 /spec/models
parenta63ada5e77c4d817b05552d066dc6004003aaf98 (diff)
Add test for #cast_value_from_cache
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/concerns/redis_cacheable_spec.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/models/concerns/redis_cacheable_spec.rb b/spec/models/concerns/redis_cacheable_spec.rb
index 2da0f33e27b..066021a32cd 100644
--- a/spec/models/concerns/redis_cacheable_spec.rb
+++ b/spec/models/concerns/redis_cacheable_spec.rb
@@ -83,4 +83,40 @@ describe RedisCacheable do
expect(instance.name).to eq('new_value')
end
end
+
+ describe '#cast_value_from_cache' do
+ let(:instance) { Ci::Runner.new }
+
+ subject { instance.__send__(:cast_value_from_cache, attribute, value) }
+
+ shared_context 'runner contacted_at context' do
+ let(:attribute) { :contacted_at }
+ let(:value) { '2018-05-07 13:53:08 UTC' }
+ end
+
+ context 'on rails5' do
+ include_context 'runner contacted_at context'
+
+ before do
+ allow(Gitlab).to receive(:rails5?).and_return(true)
+ end
+
+ it 'converts cache string to appropriate type' do
+ pending 'Migration to rails5'
+ expect(subject).to be_an_instance_of(ActiveSupport::TimeWithZone)
+ end
+ end
+
+ context 'not on rails5' do
+ include_context 'runner contacted_at context'
+
+ before do
+ allow(Gitlab).to receive(:rails5?).and_return(false)
+ end
+
+ it 'converts cache string to appropriate type' do
+ expect(subject).to be_an_instance_of(ActiveSupport::TimeWithZone)
+ end
+ end
+ end
end