Sha256: be7bc070c9aa86c91d0f11b1cd85344a0b056f72a44f82f5d321119659776482

Contents?: true

Size: 1.1 KB

Versions: 26

Compression:

Stored size: 1.1 KB

Contents

def all_uploaders
  @all_uploaders ||= begin
    Dir[Rails.root.join('app/uploaders/*.rb')].each { |u| require u }
    AbAdmin::CarrierWave::BaseUploader.subclasses
  end
end

def enable_processing
  all_uploaders.each do |u|
    u.enable_processing = true
  end
end

def disable_processing
  all_uploaders.each do |u|
    u.enable_processing = false
  end
end

RSpec.configure do |config|
  config.treat_symbols_as_metadata_keys_with_true_values = true
  config.around :each, :js do |example|
    enable_processing
    example.run
    disable_processing
  end

  config.after :all do
    FileUtils.rm_rf(Dir["#{Rails.root}/spec/support/uploads"])
  end
end

if defined?(CarrierWave)
  CarrierWave.configure do |config|
    config.storage = :file
    config.enable_processing = false
  end

  CarrierWave::Uploader::Base.descendants.each do |klass|
    next if klass.anonymous?
    klass.class_eval do
      def cache_dir
        "#{Rails.root}/spec/support/uploads/tmp"
      end

      def store_dir
        "#{Rails.root}/spec/support/uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
ab_admin-0.2.2 lib/generators/ab_admin/install/templates/spec/support/carrierwave.rb
ab_admin-0.2.1 lib/generators/ab_admin/install/templates/spec/support/carrierwave.rb
ab_admin-0.2.0 lib/generators/ab_admin/install/templates/spec/support/carrierwave.rb
ab_admin-0.1.2 lib/generators/ab_admin/install/templates/spec/support/carrierwave.rb
ab_admin-0.1.1 lib/generators/ab_admin/install/templates/spec/support/carrierwave.rb
ab_admin-0.1.0 lib/generators/ab_admin/install/templates/spec/support/carrierwave.rb