Sha256: 054311d48a31b5f97605eb83c1aacb7d24924d066aa1ddbfc87806f0c0fc7dde

Contents?: true

Size: 1.12 KB

Versions: 83

Compression:

Stored size: 1.12 KB

Contents

require 'spec_helper'
include ActionDispatch::TestProcess

connection = ActiveRecord::Base.connection
connection.drop_table :dogs rescue nil
connection.create_table :dogs do |t|
  # Nada
end

class Dog < ActiveRecord::Base
  has_asset :avatar, styles: { dog_size: '250x250#' }
end

describe Tenon::HasAsset do
  let(:dog) { Dog.new }
  context '.has_asset' do
    %i(avatar_join avatar avatar= avatar_id=).each do |meth|
      it "should define ##{meth}" do
        expect(dog).to respond_to(meth)
      end
    end
  end

  context '#avatar' do
    context 'when no avatar has been set' do
      it 'should be nil' do
        expect(dog.avatar).to be_nil
      end
    end

    context 'when an avatar has been set on an unsaved dog' do
      before do
        dog.avatar = fixture_file_upload('files/test.png')
      end

      it 'should be a Tenon::ProxyAttachment' do
        expect(dog.avatar).to be_a(Tenon::ProxyAttachment)
      end

      it 'should include a dog_size style on the original attachment' do
        styles = dog.avatar.attachment.styles.keys
        expect(styles).to include(:dog_avatar_dog_size)
      end
    end
  end
end

Version data entries

83 entries across 83 versions & 1 rubygems

Version Path
tenon-1.1.8 spec/lib/tenon/has_asset_spec.rb
tenon-1.1.7 spec/lib/tenon/has_asset_spec.rb
tenon-1.1.6 spec/lib/tenon/has_asset_spec.rb
tenon-1.1.5 spec/lib/tenon/has_asset_spec.rb
tenon-1.1.4 spec/lib/tenon/has_asset_spec.rb
tenon-1.1.3 spec/lib/tenon/has_asset_spec.rb
tenon-1.1.2 spec/lib/tenon/has_asset_spec.rb
tenon-1.1.1 spec/lib/tenon/has_asset_spec.rb
tenon-1.0.76 spec/lib/tenon/has_asset_spec.rb
tenon-1.0.75 spec/lib/tenon/has_asset_spec.rb
tenon-1.0.74 spec/lib/tenon/has_asset_spec.rb
tenon-1.0.73 spec/lib/tenon/has_asset_spec.rb
tenon-1.0.72 spec/lib/tenon/has_asset_spec.rb
tenon-1.0.71 spec/lib/tenon/has_asset_spec.rb
tenon-1.0.70 spec/lib/tenon/has_asset_spec.rb
tenon-1.0.69 spec/lib/tenon/has_asset_spec.rb
tenon-1.0.68 spec/lib/tenon/has_asset_spec.rb
tenon-1.0.67 spec/lib/tenon/has_asset_spec.rb
tenon-1.0.66 spec/lib/tenon/has_asset_spec.rb
tenon-1.0.65 spec/lib/tenon/has_asset_spec.rb