Sha256: 99ed8d2be0ea7b78fec7d3039e2986ba7023d24593ede7e45dc79de360c2f3bb

Contents?: true

Size: 887 Bytes

Versions: 10

Compression:

Stored size: 887 Bytes

Contents

require 'test_helper'
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

10 entries across 10 versions & 1 rubygems

Version Path
ecrire-0.27.0 test/editor/models/image_test.rb
ecrire-0.26.3 test/editor/models/image_test.rb
ecrire-0.26.2 test/editor/models/image_test.rb
ecrire-0.26.1 test/editor/models/image_test.rb
ecrire-0.26.0 test/editor/models/image_test.rb
ecrire-0.25.2 test/editor/models/image_test.rb
ecrire-0.25.1 test/editor/models/image_test.rb
ecrire-0.25.0 test/editor/models/image_test.rb
ecrire-0.24.1 test/editor/models/image_test.rb
ecrire-0.24.0 test/editor/models/image_test.rb