Sha256: ec9a06e347958c2fb1d4cde8c3f93a4bafb0a6fa7463543dbd7de70cceb82eaf
Contents?: true
Size: 1.34 KB
Versions: 2
Compression:
Stored size: 1.34 KB
Contents
require "spec_helper" require "carrierwave/base64/orm/activerecord" RSpec.describe Carrierwave::Base64::ActiveRecord do describe ".mount_base64_uploader" do let(:uploader) { Class.new CarrierWave::Uploader::Base } subject do Post.mount_base64_uploader(:image, uploader) Post.new end it "mounts the uploader on the image field" do expect(subject.image).to be_an_instance_of(uploader) end it "should work with normal file uploads" do sham_rack_app = ShamRack.at('www.example.com').stub sham_rack_app.register_resource("/test.jpg", file_path("fixtures", "test.jpg"), "images/jpg") subject[:image] = "test.jpg" subject.save! subject.reload expect(subject.image.current_path).to eq file_path("../uploads", "test.jpg") end it "should work with base64 file uploads" do subject.image = File.read(file_path("fixtures", "base64_image.fixture")).strip subject.save! subject.reload expect(subject.image.current_path).to eq file_path("../uploads", "image.jpg") end it "should work with base64 file uploads with trailing newline" do subject.image = File.read(file_path("fixtures", "base64_image.fixture")) subject.save! subject.reload expect(subject.image.current_path).to eq file_path("../uploads", "image.jpg") end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
carrierwave-base64-1.2 | spec/orm/activerecord_spec.rb |
carrierwave-base64-1.1 | spec/orm/activerecord_spec.rb |