Sha256: 7c01974704c344d4d9633299695329a9c284f9a04b6288781bfecd7570395a13

Contents?: true

Size: 1 KB

Versions: 2

Compression:

Stored size: 1 KB

Contents

require File.expand_path('../test_helper', File.dirname(__FILE__))

class SlideTest < ActiveSupport::TestCase
  
  def test_fixtures_validity
    Carousel::Slide.all.each do |slide|
      assert slide.valid?, slide.errors.inspect
    end
  end
  
  def test_validations
    slide = Carousel::Slide.new
    assert slide.invalid?
    assert_has_errors_on slide, [:carousel_id, :label]
  end
  
  def test_creation
    carousel = carousel_carousels(:default)
    assert_difference 'Carousel::Slide.count' do
      slide = carousel.slides.create(
        :label    => 'Test',
        :content  => 'Test Content',
        :url      => 'http://google.com',
        :file     => fixture_file_upload('files/image.jpg', 'image/jpeg')
      )
      assert_equal 1, slide.position
      assert_equal carousel, slide.carousel
    end
  end
  
  def test_is_image?
    slide = carousel_slides(:default)
    assert slide.is_image?
    
    slide.update_attribute(:file_content_type, 'application/pdf')
    assert !slide.is_image?
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
comfy_carousel-0.0.3 test/unit/slide_test.rb
comfy_carousel-0.0.2 test/unit/slide_test.rb