Commit 18bbe44576c3a352b4e03c6552ac6db40a91f825
1 parent
eaf3e2fc
Exists in
master
and in
29 other branches
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,12 +9,12 @@ class SlideshowBlockTest < ActiveSupport::TestCase | ||
9 | 9 | ||
10 | should 'refer to a gallery' do | 10 | should 'refer to a gallery' do |
11 | gallery = fast_create(Gallery, :profile_id => profile.id) | 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 | assert_equal gallery, slideshow_block.gallery | 13 | assert_equal gallery, slideshow_block.gallery |
14 | end | 14 | end |
15 | 15 | ||
16 | should 'not crash if referencing unexisting folder' do | 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 | end | 18 | end |
19 | 19 | ||
20 | should 'default interval between transitions is 4 seconds' do | 20 | should 'default interval between transitions is 4 seconds' do |
@@ -37,7 +37,7 @@ class SlideshowBlockTest < ActiveSupport::TestCase | @@ -37,7 +37,7 @@ class SlideshowBlockTest < ActiveSupport::TestCase | ||
37 | gallery = mock | 37 | gallery = mock |
38 | images = [] | 38 | images = [] |
39 | shuffled = [] | 39 | shuffled = [] |
40 | - block = SlideshowBlock.new(:shuffle => true) | 40 | + block = build(SlideshowBlock, :shuffle => true) |
41 | block.stubs(:gallery).returns(gallery) | 41 | block.stubs(:gallery).returns(gallery) |
42 | block.stubs(:block_images).returns(images) | 42 | block.stubs(:block_images).returns(images) |
43 | images.expects(:shuffle).once.returns(shuffled) | 43 | images.expects(:shuffle).once.returns(shuffled) |
@@ -68,7 +68,7 @@ class SlideshowBlockTest < ActiveSupport::TestCase | @@ -68,7 +68,7 @@ class SlideshowBlockTest < ActiveSupport::TestCase | ||
68 | end | 68 | end |
69 | 69 | ||
70 | should 'set different image size' do | 70 | should 'set different image size' do |
71 | - block = SlideshowBlock.new(:image_size => 'slideshow') | 71 | + block = build(SlideshowBlock, :image_size => 'slideshow') |
72 | assert_equal 'slideshow', block.image_size | 72 | assert_equal 'slideshow', block.image_size |
73 | end | 73 | end |
74 | 74 | ||
@@ -77,7 +77,7 @@ class SlideshowBlockTest < ActiveSupport::TestCase | @@ -77,7 +77,7 @@ class SlideshowBlockTest < ActiveSupport::TestCase | ||
77 | image.expects(:public_filename).with('slideshow').returns('/bli/slideshow.png') | 77 | image.expects(:public_filename).with('slideshow').returns('/bli/slideshow.png') |
78 | File.expects(:exists?).with("#{Rails.root}/public/bli/slideshow.png").returns(true) | 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 | end | 81 | end |
82 | 82 | ||
83 | should 'display the default slideshow image if thumbnails were not processed' do | 83 | should 'display the default slideshow image if thumbnails were not processed' do |
@@ -85,11 +85,11 @@ class SlideshowBlockTest < ActiveSupport::TestCase | @@ -85,11 +85,11 @@ class SlideshowBlockTest < ActiveSupport::TestCase | ||
85 | image.expects(:public_filename).with('slideshow').returns('/images/icons-app/image-loading-slideshow.png') | 85 | image.expects(:public_filename).with('slideshow').returns('/images/icons-app/image-loading-slideshow.png') |
86 | File.expects(:exists?).with("#{Rails.root}/public/images/icons-app/image-loading-slideshow.png").returns(true) | 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 | end | 89 | end |
90 | 90 | ||
91 | should 'fallback to existing size in case the requested size does not exist' do | 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 | image = mock | 94 | image = mock |
95 | # "slideshow" size does not exist | 95 | # "slideshow" size does not exist |