Add test for #cast_value_from_cache
This commit is contained in:
parent
a63ada5e77
commit
13298bb3d1
1 changed files with 36 additions and 0 deletions
|
@ -83,4 +83,40 @@ describe RedisCacheable do
|
||||||
expect(instance.name).to eq('new_value')
|
expect(instance.name).to eq('new_value')
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
Loading…
Reference in a new issue