Sha256: 7234e52d3f9ba1563b0db5e1309bff00ee47a900272f105393c3fd7155168b74

Contents?: true

Size: 865 Bytes

Versions: 4

Compression:

Stored size: 865 Bytes

Contents

require 'editor/test_helper'

class ImageTest < ActiveSupport::TestCase

  Struct.new('File', :original_filename)

  test 'should only return favorited images' do
    Image.favorites.each do |image|
      assert image.favorite?, 'Image should be favorited'
    end
  end

  test 'path should handle blank base_folder' do
    Rails.application.secrets.s3['path'] = ""
    file = Struct::File.new('some_image.jpg')

    image = Admin::Image.new
    image.post = Admin::Post.first

    assert_equal image.send(:path, file), "#{image.post.id}/some_image.jpg"
  end

  test 'path should handle base_folder' do
    Rails.application.secrets.s3['path'] = "my_blog"
    file = Struct::File.new('some_image.jpg')

    image = Admin::Image.new
    image.post = Admin::Post.first

    assert_equal image.send(:path, file), "my_blog/#{image.post.id}/some_image.jpg"
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ecrire-0.23.0 test/editor/models/image_test.rb
ecrire-0.22.1 test/editor/models/image_test.rb
ecrire-0.21.0 test/editor/models/image_test.rb
ecrire-0.20.0 test/editor/models/image_test.rb