Sha256: f9e14f720237631d84b5031fbb6506eb4101e9135e3e4639feef137063bec597

Contents?: true

Size: 1.59 KB

Versions: 10

Compression:

Stored size: 1.59 KB

Contents

require 'spec_helper'


describe "Uploads" do
  if Settings.file_uploads_engine != :shrine
    pending "shrine not detected, skipped. To run use UPLOADS=shrine rspec"
  else
    before :each do
      f = "#{File.dirname(__FILE__)}/../uploads/1024x768.gif"
      if File.file?(f)
        File.unlink(f)
      end
    end
    it 'supports file kind' do
      Settings.set('file', File.open("#{File.dirname(__FILE__)}/support/1024x768.gif"), kind: 'file')
      expect(Settings.get(:file).file.metadata["filename"]).to eq '1024x768.gif'
      expect(Settings.get(:file).file.metadata["size"]).to eq 4357
      expect(Settings.get(:file).file.metadata["mime_type"]).to eq "image/gif"
      expect(Settings.get(:file).file.id.split(".").last).to eq "gif"
      expect(Settings.file.split("/").second + "/" + Settings.file.split("/").last.split(".").last).to eq "uploads/gif"
      expect(File.exists?("public/uploads/#{Settings.get(:file).file.id}")).to be_truthy
    end
    it 'supports image kind' do
      Settings.set('file', File.open("#{File.dirname(__FILE__)}/support/1024x768.gif"), kind: 'image')
      expect(Settings.get(:file).file.metadata["filename"]).to eq '1024x768.gif'
      expect(Settings.get(:file).file.metadata["size"]).to eq 4357
      expect(Settings.get(:file).file.metadata["mime_type"]).to eq "image/gif"
      expect(Settings.get(:file).file.id.split(".").last).to eq "gif"
      expect(Settings.file.split("/").second + "/" + Settings.file.split("/").last.split(".").last).to eq "uploads/gif"
      expect(File.exists?("public/uploads/#{Settings.get(:file).file.id}")).to be_truthy
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
thecore_settings-2.0.9 spec/shrine_spec.rb
thecore_settings-2.0.8 spec/shrine_spec.rb
thecore_settings-2.0.7 spec/shrine_spec.rb
thecore_settings-2.0.6 spec/shrine_spec.rb
thecore_settings-2.0.5 spec/shrine_spec.rb
thecore_settings-2.0.4 spec/shrine_spec.rb
thecore_settings-2.0.3 spec/shrine_spec.rb
thecore_settings-2.0.2 spec/shrine_spec.rb
rails_admin_settings-1.7.0 spec/shrine_spec.rb
rails_admin_settings-1.6.0 spec/shrine_spec.rb