Sha256: 4862c01cc22805a0bf6c6937eade35cbb0d82b08c5eb900578cf2de0d5ea30fc

Contents?: true

Size: 1.93 KB

Versions: 19

Compression:

Stored size: 1.93 KB

Contents

require File.join(File.dirname(__FILE__), '/../../test_helper')

class Cms::SessionsControllerTest < ActionController::TestCase
  include Cms::ControllerTestHelper
  def teardown
    User.current = nil
  end
  
  def test_not_redirected_to_cms_site_if_public_site
    @request.host = "foo.com"
    @request.request_uri = "/cms/login"
    get :new
    assert_response :success
  end

  def test_not_redirected_if_cms_site
    @request.host = "cms.foo.com"
    @request.request_uri = "/cms/login"
    get :new
    assert_response :success
    log @response.body
    assert_select "title", "CMS Login"
  end
  
  def test_return_to
    user = Factory(:user)
    expected_url = "/expected_url"

    post :create, {:success_url => "", :login => user.login, :password => "password"}, {:return_to => expected_url }
    assert_redirected_to(expected_url)
  end
  def test_success_url_overrides_return_to
    user = Factory(:user)
    expected_url = "/expected_url"

    post :create, {:success_url => expected_url, :login => user.login, :password => "password"}, {:return_to => "/somewhere_else" }

    assert_redirected_to(expected_url)
  end
  
end

class Cms::SessionsControllerCacheEnabledTest < ActionController::TestCase
  include Cms::ControllerTestHelper
  tests Cms::SessionsController
  
  def setup
    @controller.perform_caching = true
  end
  
  def teardown
    @controller.perform_caching = false
  end
  
  def test_redirected_to_cms_site_if_public_site
    @request.host = "foo.com"
    @request.request_uri = "/cms/login"
    get :new
    assert_redirected_to "http://cms.foo.com/cms/login"
  end

  def test_not_redirected_if_cms_site
    @request.host = "cms.foo.com"
    @request.request_uri = "/cms/login"
    get :new
    assert_response :success
    log @response.body
    assert_select "title", "CMS Login"
  end

  test "destroy" do
    Cms::SessionsController.any_instance.expects(:logout_user)
    delete :destroy
    assert_redirected_to "/" 
  end
end

Version data entries

19 entries across 19 versions & 6 rubygems

Version Path
browsercms-3.1.5 test/functional/cms/sessions_controller_test.rb
browsercms-3.1.4 test/functional/cms/sessions_controller_test.rb
browsercms-3.1.3 test/functional/cms/sessions_controller_test.rb
bf4-browsercms-3.1.0 test/functional/cms/sessions_controller_test.rb
drujensen-browsercms-3.2.0 test/functional/cms/sessions_controller_test.rb
browsercmsi-3.1.2 test/functional/cms/sessions_controller_test.rb
browsercms-3.1.2 test/functional/cms/sessions_controller_test.rb
browsercms-3.1.1 test/functional/cms/sessions_controller_test.rb
browsercmsi-3.1.1 test/functional/cms/sessions_controller_test.rb
browsercmsi-3.1.0 test/functional/cms/sessions_controller_test.rb
browsercms-3.1.0 test/functional/cms/sessions_controller_test.rb
we5-browsercms-3.1.0 test/functional/cms/sessions_controller_test.rb
browsercms-3.0.6 test/functional/cms/sessions_controller_test.rb
browsercms-3.0.5 test/functional/cms/sessions_controller_test.rb
we5-browsercms-3.0.5.1 test/functional/cms/sessions_controller_test.rb
we5-browsercms-3.0.5 test/functional/cms/sessions_controller_test.rb
browsercms_s3-3.0.5 test/functional/cms/sessions_controller_test.rb
browsercms-3.0.4 test/functional/cms/sessions_controller_test.rb
browsercms-3.0.3 test/functional/cms/sessions_controller_test.rb