Sha256: 7e4972fa676f9e5ca7d06973bd6cbe910d401bd992bebf94055da02985251240

Contents?: true

Size: 790 Bytes

Versions: 4

Compression:

Stored size: 790 Bytes

Contents

require "helper"

class MissingTest < Test::Unit::TestCase
  Photo = Class.new(Struct.new(:id))

  test "adding it using extend" do
    imagery = Imagery.new(Photo.new(1001))
    imagery.extend Imagery::Missing
    imagery.existing = ""
    assert_equal '/missing/photo/original.png', imagery.url
  end
  
  class WithMissing < Imagery::Model
    include Imagery::Missing
  end

  test "adding it using include" do
    imagery = WithMissing.new(Photo.new(1001))
    imagery.existing = ""

    assert_equal '/missing/photo/original.png', imagery.url
  end

  test "still returns as normal when not missing" do
    imagery = WithMissing.new(Photo.new(1001))
    imagery.root = '/tmp'
    imagery.existing = 'lake.jpg'
    assert_equal '/system/photo/1001/original.png', imagery.url
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
imagery-0.0.6 test/test_missing.rb
imagery-0.0.5 test/test_missing.rb
imagery-0.0.4 test/test_missing.rb
imagery-0.0.3 test/test_missing.rb