debian-mirror-gitlab/spec/models/appearance_spec.rb

45 lines
1 KiB
Ruby
Raw Normal View History

2016-04-02 18:10:28 +05:30
require 'rails_helper'
2018-03-17 18:26:18 +05:30
describe Appearance do
2016-11-03 12:29:30 +05:30
subject { build(:appearance) }
2016-04-02 18:10:28 +05:30
it { is_expected.to be_valid }
2017-08-17 22:00:37 +05:30
it { is_expected.to have_many(:uploads).dependent(:destroy) }
2017-09-10 17:25:29 +05:30
describe '.current', :use_clean_rails_memory_store_caching do
let!(:appearance) { create(:appearance) }
it 'returns the current appearance row' do
expect(described_class.current).to eq(appearance)
end
it 'caches the result' do
expect(described_class).to receive(:first).once
2.times { described_class.current }
end
end
describe '#flush_redis_cache' do
it 'flushes the cache in Redis' do
appearance = create(:appearance)
expect(Rails.cache).to receive(:delete).with(described_class::CACHE_KEY)
appearance.flush_redis_cache
end
end
describe '#single_appearance_row' do
it 'adds an error when more than 1 row exists' do
create(:appearance)
new_row = build(:appearance)
new_row.save
expect(new_row.valid?).to eq(false)
end
end
2016-04-02 18:10:28 +05:30
end