|
3 | 3 | RSpec.describe CollectionBrandingInfo, type: :model do
|
4 | 4 | let(:banner) { FactoryBot.build(:collection_branding_banner) }
|
5 | 5 | let(:file_set) { FactoryBot.create(:file_set, id: 'file_set_id', uri: 'file_set_uri') }
|
6 |
| - let(:version) { double(uri: 'version_uri') } |
7 |
| - let(:versions) { double(any?: true, all: self, last: version) } |
8 |
| - |
| 6 | + let(:local_file) { File.open(RSpec.configuration.fixture_path + '/world.png') } |
| 7 | + let(:local_file_set) { FactoryBot.create(:file_set, content: local_file) } |
9 | 8 |
|
10 | 9 | describe '#initialize' do
|
11 | 10 | context 'with local_path value provided' do
|
|
101 | 100 | banner.send(:image_path=, nil)
|
102 | 101 | end
|
103 | 102 | context 'and unable to generate one' do
|
104 |
| - before do |
105 |
| - allow(banner).to receive(:file_set_versions).and_return([]) |
106 |
| - end |
107 | 103 | it 'returns nil' do
|
108 | 104 | expect(banner.file_set_image_path).to be_nil
|
109 | 105 | end
|
110 | 106 | end
|
111 | 107 | context 'but able to generate one' do
|
112 |
| - before do |
113 |
| - allow(banner).to receive(:file_set_versions).and_return(versions) |
114 |
| - allow(versions).to receive(:all).and_return(versions) |
115 |
| - end |
| 108 | + let(:banner) { FactoryBot.build(:collection_branding_banner, file_set_id: local_file_set.id) } |
116 | 109 | it 'sets the image_path value' do
|
117 | 110 | expect(banner).to receive(:image_path=)
|
118 | 111 | banner.file_set_image_path
|
119 | 112 | end
|
120 | 113 | it 'returns the image_path value' do
|
121 |
| - expect(banner.file_set_image_path).to match version.uri |
| 114 | + expect(banner.file_set_image_path).to match /^http/ |
122 | 115 | end
|
123 | 116 | end
|
124 | 117 | end
|
|
0 commit comments