<commit_before>require 'spec_helper'

class AnonymousUploader < CarrierWave::Uploader::Base

  include CarrierWave::RMagick

  version :small do
    process :resize_to_fill => [30, 30]
  end

  version :small_without_dimension_processor do
    process :desaturate
  end

  version :small_multiple_processors do
    process :resize_to_fill => [30, 30]
    process :desaturate
  end

  def desaturate
    manipulate! do |img|
      img = img.quantize 256, Magick::GRAYColorspace
    end
  end

  version :small_without_processor

  include RetinaRails::CarrierWave

end

class CarrierWaveUpload

  extend CarrierWave::Mount

  attr_accessor :avatar
  attr_accessor :id

  mount_uploader :avatar, AnonymousUploader

  def initialize
    self.id = 999
  end

end

describe RetinaRails::CarrierWave do

  include CarrierWave::Test::Matchers

  subject { AnonymousUploader }

  before do
    AnonymousUploader.enable_processing = true
    @uploader = AnonymousUploader.new(CarrierWaveUpload.new, :avatar)
    @uploader.store!(File.open("#{File.dirname(__FILE__)}/fixtures/images/avatar.jpeg"))
  end

  after do
    AnonymousUploader.enable_processing = false
    @uploader.remove!
  end

  context 'with dimensions processor' do

    its(:versions) { should include :small_retina }

    it { @uploader.small.should have_dimensions(30, 30) }
    it { @uploader.small_retina.should have_dimensions(60, 60) }

    it { File.basename(@uploader.small.current_path, 'jpeg').should include 'small_'}

    it { File.basename(@uploader.small_retina.current_path, 'jpeg').should include '@2x'}
    it { File.basename(@uploader.small_retina.current_path, 'jpeg').should_not include 'retina_'}

  end

  context 'without dimensions processor' do

    its(:versions) { should_not include :small_without_dimension_processor_retina }

  end<commit_msg>Dimension > Dimensions<commit_after>require 'spec_helper'

class AnonymousUploader < CarrierWave::Uploader::Base

  include CarrierWave::RMagick

  version :small do
    process :resize_to_fill => [30, 30]
  end

  version :small_without_dimensions do
    process :desaturate
  end

  version :small_multiple_processors do
    process :resize_to_fill => [30, 30]
    process :desaturate
  end

  def desaturate
    manipulate! do |img|
      img = img.quantize 256, Magick::GRAYColorspace
    end
  end

  version :small_without_processor

  include RetinaRails::CarrierWave

end

class CarrierWaveUpload

  extend CarrierWave::Mount

  attr_accessor :avatar
  attr_accessor :id

  mount_uploader :avatar, AnonymousUploader

  def initialize
    self.id = 999
  end

end

describe RetinaRails::CarrierWave do

  include CarrierWave::Test::Matchers

  subject { AnonymousUploader }

  before do
    AnonymousUploader.enable_processing = true
    @uploader = AnonymousUploader.new(CarrierWaveUpload.new, :avatar)
    @uploader.store!(File.open("#{File.dirname(__FILE__)}/fixtures/images/avatar.jpeg"))
  end

  after do
    AnonymousUploader.enable_processing = false
    @uploader.remove!
  end

  context 'with dimensions processor' do

    its(:versions) { should include :small_retina }

    it { @uploader.small.should have_dimensions(30, 30) }
    it { @uploader.small_retina.should have_dimensions(60, 60) }

    it { File.basename(@uploader.small.current_path, 'jpeg').should include 'small_'}

    it { File.basename(@uploader.small_retina.current_path, 'jpeg').should include '@2x'}
    it { File.basename(@uploader.small_retina.current_path, 'jpeg').should_not include 'retina_'}

  end

  context 'without dimensions processor' do

    its(:versions) { should_not include :small_without_dimensions_retina }

  end
{'fraction_non_alphanumeric': 0.09110807113543092, 'fraction_numerical': 0.012585499316005472, 'mean_word_length': 4.290882778581765, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2326380', 'n_tokens_mistral': 1266, 'n_tokens_neox': 1146, 'n_words': 258}