Commit d76b9e3bfc2c63c829e4c2ee85d405f9918a74d1

Authored by Antonio Terceiro
1 parent 18a99bd2

Don't crash if referenced image gallery is deleted

(ActionItem1494)
app/models/slideshow_block.rb
... ... @@ -10,7 +10,7 @@ class SlideshowBlock < Block
10 10 end
11 11  
12 12 def gallery
13   - gallery_id ? Folder.find(gallery_id) : nil
  13 + gallery_id ? Folder.find(:first, :conditions => { :id => gallery_id }) : nil
14 14 end
15 15  
16 16 def block_images
... ...
test/unit/slideshow_block_test.rb
... ... @@ -15,6 +15,10 @@ class SlideshowBlockTest < ActiveSupport::TestCase
15 15 assert_equal gallery, slideshow_block.gallery
16 16 end
17 17  
  18 + should 'not crash if referencing unexisting folder' do
  19 + assert_nil SlideshowBlock.new(:gallery_id => -999).gallery
  20 + end
  21 +
18 22 should 'default interval between transitions is 4 seconds' do
19 23 slideshow = SlideshowBlock.new
20 24 assert_equal 4, slideshow.interval
... ...