Commit 226e4e287669e2245d3a3fcd552f7460dcd495cc

Authored by Moises Machado
Committed by Antonio Terceiro
1 parent 7e5e9579

ActionItem905: avoid ssl in public articles

app/controllers/public/content_viewer_controller.rb
... ... @@ -44,6 +44,10 @@ class ContentViewerController < ApplicationController
44 44 return if redirect_to_ssl
45 45 end
46 46  
  47 + if @page.public?
  48 + return unless avoid_ssl
  49 + end
  50 +
47 51 if !@page.display_to?(user)
48 52 # FIXME find a nice "access denied" layout
49 53 render :action => 'access_denied', :status => 403, :layout => false
... ...
test/functional/content_viewer_controller_test.rb
... ... @@ -460,6 +460,13 @@ class ContentViewerControllerTest < Test::Unit::TestCase
460 460 assert_redirected_to :protocol => 'https://', :profile => 'testinguser', :page => [ 'myarticle' ]
461 461 end
462 462  
  463 + should 'avoid SSL for viewing public articles' do
  464 + @request.expects(:ssl?).returns(true).at_least_once
  465 + page = profile.articles.create!(:name => 'myarticle', :body => 'top secret', :public_article => true)
  466 + get :view_page, :profile => 'testinguser', :page => [ 'myarticle' ]
  467 + assert_redirected_to :protocol => 'http://', :profile => 'testinguser', :page => [ 'myarticle' ]
  468 + end
  469 +
463 470 should 'not redirect to SSL if already on SSL' do
464 471 @request.expects(:ssl?).returns(true).at_least_once
465 472 page = profile.articles.create!(:name => 'myarticle', :body => 'top secret', :public_article => false)
... ...