Sha256: b41f2ae65cde23982aab0eb0ecc88195cba247c909a33e1f95d17d0b45d74eac

Contents?: true

Size: 971 Bytes

Versions: 2

Compression:

Stored size: 971 Bytes

Contents

require 'spec_helper'

describe 'Model without paperclip' do
  class UserWithoutPaperclip
    include Artwork::Model

    def attachment_styles_for(attachment_name)
      if attachment_name.to_sym == :avatar
        ModelSpec::IMAGE_STYLES.keys
      end
    end

    def avatar
      Avatar.new
    end
  end

  class Avatar
    def url(style, options)
      "/avatar-#{style}.jpg"
    end
  end

  it_behaves_like 'an artwork model' do
    let(:model) { UserWithoutPaperclip }
    let(:instance) { UserWithoutPaperclip.new }
    let(:attachment_name) { :avatar }
  end

  # if you want to use artwork_tag like this:
  # <%= artwork_tag record, :avatar, '320x', auto_height: true %>
  # you will have to provide Avatar#width and Avatar#height which will be used to generate
  # the padding-bottom % of the .img-holder
  #
  # n.b. you could use the artwork_tag also like this:
  # <%= artwork_tag record, :avatar, '320x', auto_height: [image_width, image_height] %>
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
artwork-1.0.0 spec/examples/model_without_paperclip_spec.rb
artwork-0.7.3 spec/examples/model_without_paperclip_spec.rb