Commit bf45b41184bf5bca43f59f820a8f6d85163b0e13
Committed by
Antonio Terceiro
1 parent
b8a612e5
Exists in
staging
and in
42 other branches
Slideshow block don't show folders
* Folders are being filtered in the slideshow's block. (ActionItem1447)
Showing
3 changed files
with
19 additions
and
5 deletions
Show diff stats
app/models/slideshow_block.rb
| ... | ... | @@ -13,10 +13,14 @@ class SlideshowBlock < Block |
| 13 | 13 | gallery_id ? Folder.find(gallery_id) : nil |
| 14 | 14 | end |
| 15 | 15 | |
| 16 | + def block_images | |
| 17 | + gallery.images.reject {|item| item.folder?} | |
| 18 | + end | |
| 19 | + | |
| 16 | 20 | def content |
| 17 | 21 | block = self |
| 18 | 22 | if gallery |
| 19 | - images = gallery.images | |
| 23 | + images = block_images | |
| 20 | 24 | if shuffle |
| 21 | 25 | images = images.shuffle |
| 22 | 26 | end | ... | ... |
app/views/box_organizer/_slideshow_block.rhtml
| 1 | 1 | <% galleries = @block.box.owner.articles.select {|article| article.folder? && article.display_as_gallery? } %> |
| 2 | 2 | <%= labelled_form_field _('Choose a gallery'), select('block', 'gallery_id', galleries.map { |item| |
| 3 | - [ _('%{gallery} (%{count} images)') % {:gallery => item.path, :count => item.images.count}, item.id ] | |
| 3 | + [ _('%{gallery} (%{count} images)') % {:gallery => item.path, :count => item.images.reject{|image| image.folder?}.count}, item.id ] | |
| 4 | 4 | }) %> |
| 5 | 5 | |
| 6 | 6 | <%= labelled_form_field _('Image transition:'), select('block', 'interval', [[_('No automatic transition'), 0]] + [1, 2, 3, 4, 5, 10, 20, 30, 60].map {|item| [n_('Every 1 second', 'Every %d seconds', item) % item, item]}) %> | ... | ... |
test/unit/slideshow_block_test.rb
| ... | ... | @@ -35,11 +35,11 @@ class SlideshowBlockTest < ActiveSupport::TestCase |
| 35 | 35 | gallery = mock |
| 36 | 36 | images = [] |
| 37 | 37 | shuffled = [] |
| 38 | - gallery.stubs(:images).returns(images) | |
| 39 | - images.expects(:shuffle).once.returns(shuffled) | |
| 40 | - | |
| 41 | 38 | block = SlideshowBlock.new(:shuffle => true) |
| 42 | 39 | block.stubs(:gallery).returns(gallery) |
| 40 | + block.stubs(:block_images).returns(images) | |
| 41 | + images.expects(:shuffle).once.returns(shuffled) | |
| 42 | + | |
| 43 | 43 | block.content |
| 44 | 44 | end |
| 45 | 45 | |
| ... | ... | @@ -51,4 +51,14 @@ class SlideshowBlockTest < ActiveSupport::TestCase |
| 51 | 51 | assert_equal false, SlideshowBlock.new.navigation |
| 52 | 52 | end |
| 53 | 53 | |
| 54 | + should 'not show folders' do | |
| 55 | + folder = fast_create(Folder, :profile_id => profile.id) | |
| 56 | + gallery = fast_create(Folder, :profile_id => profile.id) | |
| 57 | + gallery.children << folder | |
| 58 | + block = SlideshowBlock.new | |
| 59 | + block.stubs(:gallery).returns(gallery) | |
| 60 | + | |
| 61 | + assert_not_includes block.block_images, folder | |
| 62 | + end | |
| 63 | + | |
| 54 | 64 | end | ... | ... |