-
Notifications
You must be signed in to change notification settings - Fork 283
/
Copy pathstorage_spec.rb
44 lines (36 loc) · 1.34 KB
/
storage_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
require 'spec_helper'
require 'cloudinary'
module CarrierWave
module Storage
class Abstract
def initialize(uploader)
@uploader = uploader
end
attr_accessor :uploader
end
end
class SanitizedFile; end
end
RSpec.describe Cloudinary::CarrierWave::Storage do
describe '#store_cloudinary_identifier' do
let(:column) { 'example_field' }
let(:model) { double :model, _mounter: mount, write_attribute: true, read_attribute: true }
let(:mount) { double :mount, serialization_column: column }
let(:storage) { Cloudinary::CarrierWave::Storage.new(uploader) }
let(:store_identifier) { storage.store_cloudinary_identifier('1', 'test.png') }
let(:uploader) { double :uploader, model: model, mounted_as: :example, use_extended_identifier?: false }
describe 'when the ORM is Neo4j 5 and above' do
before { stub_const('Neo4j::VERSION', '5.0') }
subject! { store_identifier }
it 'writes the name to the datastore without triggering validations' do
expect(model).to have_received(:write_attribute).with(column, 'v1/test.png')
end
end
describe 'when the ORM is Neo4j 4' do
before { stub_const('Neo4j::VERSION', '4.0') }
it 'raises an unsupported exception' do
expect { store_identifier }.to raise_error(CloudinaryException)
end
end
end
end