Commit 44c42816d88e74fbd5c97265725a2eff3924127f

Authored by Rodrigo Souto
Committed by Antonio Terceiro
1 parent 3683ac99

Slideshow displays all images in gallery instead of only the ones in page

(ActionItem1351)
app/controllers/public/content_viewer_controller.rb
@@ -82,7 +82,8 @@ class ContentViewerController < ApplicationController @@ -82,7 +82,8 @@ class ContentViewerController < ApplicationController
82 end 82 end
83 83
84 if @page.folder? && @page.view_as == 'image_gallery' 84 if @page.folder? && @page.view_as == 'image_gallery'
85 - @images = @page.images.paginate(:per_page => 12, :page => params[:npage]) 85 + @images = @page.images
  86 + @images = @images.paginate(:per_page => per_page, :page => params[:npage]) unless params[:slideshow]
86 end 87 end
87 88
88 @comments = @page.comments(true) 89 @comments = @page.comments(true)
@@ -114,4 +115,7 @@ class ContentViewerController < ApplicationController @@ -114,4 +115,7 @@ class ContentViewerController < ApplicationController
114 redirect_to :action => 'view_page', :profile => params[:profile], :page => @page.explode_path, :view => params[:view] 115 redirect_to :action => 'view_page', :profile => params[:profile], :page => @page.explode_path, :view => params[:view]
115 end 116 end
116 117
  118 + def per_page
  119 + 12
  120 + end
117 end 121 end
test/functional/content_viewer_controller_test.rb
@@ -804,6 +804,21 @@ class ContentViewerControllerTest < Test::Unit::TestCase @@ -804,6 +804,21 @@ class ContentViewerControllerTest < Test::Unit::TestCase
804 assert_template 'slideshow' 804 assert_template 'slideshow'
805 end 805 end
806 806
  807 + should 'display all images from profile in the slideshow' do
  808 + @controller.stubs(:per_page).returns(1)
  809 + folder = Folder.create!(:name => 'gallery', :profile => profile, :view_as => 'image_gallery')
  810 +
  811 + fixture_filename = '/files/other-pic.jpg'
  812 + filename = RAILS_ROOT + '/test/fixtures' + fixture_filename
  813 + system('echo "image for test" | convert -background yellow -page 32x32 text:- %s' % filename)
  814 + image1 = UploadedFile.create!(:profile => profile, :parent => folder, :uploaded_data => fixture_file_upload(fixture_filename, 'image/jpg'))
  815 +
  816 + image2 = UploadedFile.create!(:profile => profile, :parent => folder, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'))
  817 + get :view_page, :profile => profile.identifier, :page => folder.explode_path, :slideshow => true
  818 +
  819 + assert_equal 2, assigns(:images).size
  820 + end
  821 +
807 should 'display source from article' do 822 should 'display source from article' do
808 profile.articles << TextileArticle.new(:name => "Article one", :profile => profile, :source => 'http://www.original-source.invalid') 823 profile.articles << TextileArticle.new(:name => "Article one", :profile => profile, :source => 'http://www.original-source.invalid')
809 get :view_page, :profile => profile.identifier, :page => ['article-one'] 824 get :view_page, :profile => profile.identifier, :page => ['article-one']