From 44c42816d88e74fbd5c97265725a2eff3924127f Mon Sep 17 00:00:00 2001 From: Rodrigo Souto Date: Tue, 22 Dec 2009 10:32:25 -0300 Subject: [PATCH] Slideshow displays all images in gallery instead of only the ones in page --- app/controllers/public/content_viewer_controller.rb | 6 +++++- test/functional/content_viewer_controller_test.rb | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/app/controllers/public/content_viewer_controller.rb b/app/controllers/public/content_viewer_controller.rb index 3e40684..accb8e9 100644 --- a/app/controllers/public/content_viewer_controller.rb +++ b/app/controllers/public/content_viewer_controller.rb @@ -82,7 +82,8 @@ class ContentViewerController < ApplicationController end if @page.folder? && @page.view_as == 'image_gallery' - @images = @page.images.paginate(:per_page => 12, :page => params[:npage]) + @images = @page.images + @images = @images.paginate(:per_page => per_page, :page => params[:npage]) unless params[:slideshow] end @comments = @page.comments(true) @@ -114,4 +115,7 @@ class ContentViewerController < ApplicationController redirect_to :action => 'view_page', :profile => params[:profile], :page => @page.explode_path, :view => params[:view] end + def per_page + 12 + end end diff --git a/test/functional/content_viewer_controller_test.rb b/test/functional/content_viewer_controller_test.rb index 2448526..0c60f9c 100644 --- a/test/functional/content_viewer_controller_test.rb +++ b/test/functional/content_viewer_controller_test.rb @@ -804,6 +804,21 @@ class ContentViewerControllerTest < Test::Unit::TestCase assert_template 'slideshow' end + should 'display all images from profile in the slideshow' do + @controller.stubs(:per_page).returns(1) + folder = Folder.create!(:name => 'gallery', :profile => profile, :view_as => 'image_gallery') + + fixture_filename = '/files/other-pic.jpg' + filename = RAILS_ROOT + '/test/fixtures' + fixture_filename + system('echo "image for test" | convert -background yellow -page 32x32 text:- %s' % filename) + image1 = UploadedFile.create!(:profile => profile, :parent => folder, :uploaded_data => fixture_file_upload(fixture_filename, 'image/jpg')) + + image2 = UploadedFile.create!(:profile => profile, :parent => folder, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) + get :view_page, :profile => profile.identifier, :page => folder.explode_path, :slideshow => true + + assert_equal 2, assigns(:images).size + end + should 'display source from article' do profile.articles << TextileArticle.new(:name => "Article one", :profile => profile, :source => 'http://www.original-source.invalid') get :view_page, :profile => profile.identifier, :page => ['article-one'] -- libgit2 0.21.2