Sha256: ab1c4f6e006c2743d56949ea061646b4e8dc28eac50264b55883b961edb4235c

Contents?: true

Size: 1.32 KB

Versions: 10

Compression:

Stored size: 1.32 KB

Contents

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 }
    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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
cloudinary-1.13.0 spec/storage_spec.rb
cloudinary-1.12.0 spec/storage_spec.rb
cloudinary-1.11.1 spec/storage_spec.rb
cloudinary-1.11.0 spec/storage_spec.rb
cloudinary-1.10.1.pre.rc spec/storage_spec.rb
cloudinary-1.10.0 spec/storage_spec.rb
cloudinary-1.9.1 spec/storage_spec.rb
cloudinary-1.9.0 spec/storage_spec.rb
cloudinary-1.8.3 spec/storage_spec.rb
cloudinary-1.8.2 spec/storage_spec.rb