Commit 18bbe44576c3a352b4e03c6552ac6db40a91f825

Authored by Rodrigo Souto
1 parent eaf3e2fc

rails3: fix slideshow_block tests

Showing 1 changed file with 7 additions and 7 deletions   Show diff stats
test/unit/slideshow_block_test.rb
... ... @@ -9,12 +9,12 @@ class SlideshowBlockTest < ActiveSupport::TestCase
9 9  
10 10 should 'refer to a gallery' do
11 11 gallery = fast_create(Gallery, :profile_id => profile.id)
12   - slideshow_block = SlideshowBlock.create!(:gallery_id => gallery.id)
  12 + slideshow_block = create(SlideshowBlock, :gallery_id => gallery.id)
13 13 assert_equal gallery, slideshow_block.gallery
14 14 end
15 15  
16 16 should 'not crash if referencing unexisting folder' do
17   - assert_nil SlideshowBlock.new(:gallery_id => -999).gallery
  17 + assert_nil build(SlideshowBlock, :gallery_id => -999).gallery
18 18 end
19 19  
20 20 should 'default interval between transitions is 4 seconds' do
... ... @@ -37,7 +37,7 @@ class SlideshowBlockTest < ActiveSupport::TestCase
37 37 gallery = mock
38 38 images = []
39 39 shuffled = []
40   - block = SlideshowBlock.new(:shuffle => true)
  40 + block = build(SlideshowBlock, :shuffle => true)
41 41 block.stubs(:gallery).returns(gallery)
42 42 block.stubs(:block_images).returns(images)
43 43 images.expects(:shuffle).once.returns(shuffled)
... ... @@ -68,7 +68,7 @@ class SlideshowBlockTest < ActiveSupport::TestCase
68 68 end
69 69  
70 70 should 'set different image size' do
71   - block = SlideshowBlock.new(:image_size => 'slideshow')
  71 + block = build(SlideshowBlock, :image_size => 'slideshow')
72 72 assert_equal 'slideshow', block.image_size
73 73 end
74 74  
... ... @@ -77,7 +77,7 @@ class SlideshowBlockTest < ActiveSupport::TestCase
77 77 image.expects(:public_filename).with('slideshow').returns('/bli/slideshow.png')
78 78 File.expects(:exists?).with("#{Rails.root}/public/bli/slideshow.png").returns(true)
79 79  
80   - assert_equal '/bli/slideshow.png', SlideshowBlock.new(:image_size => 'slideshow').public_filename_for(image)
  80 + assert_equal '/bli/slideshow.png', build(SlideshowBlock, :image_size => 'slideshow').public_filename_for(image)
81 81 end
82 82  
83 83 should 'display the default slideshow image if thumbnails were not processed' do
... ... @@ -85,11 +85,11 @@ class SlideshowBlockTest < ActiveSupport::TestCase
85 85 image.expects(:public_filename).with('slideshow').returns('/images/icons-app/image-loading-slideshow.png')
86 86 File.expects(:exists?).with("#{Rails.root}/public/images/icons-app/image-loading-slideshow.png").returns(true)
87 87  
88   - assert_equal '/images/icons-app/image-loading-slideshow.png', SlideshowBlock.new(:image_size => 'slideshow').public_filename_for(image)
  88 + assert_equal '/images/icons-app/image-loading-slideshow.png', build(SlideshowBlock, :image_size => 'slideshow').public_filename_for(image)
89 89 end
90 90  
91 91 should 'fallback to existing size in case the requested size does not exist' do
92   - block = SlideshowBlock.new(:image_size => 'slideshow')
  92 + block = build(SlideshowBlock, :image_size => 'slideshow')
93 93  
94 94 image = mock
95 95 # "slideshow" size does not exist
... ...