Sha256: aa66fea2616b2ca8c5a40c2ec726de933394fbececce514058cbb0848646d54b
Contents?: true
Size: 1.49 KB
Versions: 14
Compression:
Stored size: 1.49 KB
Contents
require 'spec_helper' describe Journey::Resource::Attachments do let(:klass) do Class.new(Journey::Resource) do self.element_name = 'job' attachment :important_file attachment :boring_file end end describe '.attachment' do let(:instance) do klass.new(display_attachments: OpenStruct.new({ 'important_file' => OpenStruct.new({ 'original' => 'O.jpg', 'thumbnail' => 'T.jpg', 'with_sha' => '/S?sha=asdasd' }) })) end describe '##{attachment}_path' do it 'defaults to original size' do expect(instance.important_file_path).to eq 'O.jpg' end it 'returns path from #display_attachments for a given size' do expect(instance.important_file_path(:thumbnail)).to eq 'T.jpg' end it 'is blank when attachment doesnt exist' do expect(instance.boring_file_path).to be_nil end it 'handles missing display_attachments gracefully' do instance.display_attachments = nil expect{ instance.important_file_path }.not_to raise_error end end describe '##{attachment}_url' do it 'is blank when attachment doesnt exist' do expect(instance.boring_file_url).to be_blank end it 'generates a valid url with sha (update due to journey attachment security updates)' do expect(instance.important_file_url('with_sha')).to include(instance.display_attachments.important_file.with_sha) end end end end
Version data entries
14 entries across 14 versions & 1 rubygems