Sha256: 44f6a4b67356ed7aa272c8771dd2564044d09cf836ff71eea6a47a9a4f283903

Contents?: true

Size: 1.83 KB

Versions: 9

Compression:

Stored size: 1.83 KB

Contents

require 'test_helper'

class AuthControllerTest < ActionController::TestCase
  [
   [:get,  "/auth",            "index"],
   [:get,  "/auth/logged_in",  "logged_in"],
   [:post, "/auth/logout",     "logout"],
   [:get,  "/auth/logged_out", "logged_out"]
  ].each do |method, path, action|
    test "routes #{method} #{path}" do
      base = {:controller => "auth"}
      assert_routing({ :method => method, :path => path }, base.merge(:action => action))
    end
  end

  test "GET index" do
    get :index

    assert_response(:success)
    assert_template("index")
  end

  test "GET logged_in" do
    return_path = "/return"

    get :logged_in, :return_path => return_path

    assert_response(:success)
    assert_template("logged_in")

    assert_equal(return_path, assigns(:return_path))
  end

  test "GET logged_in, without return path" do
    get :logged_in

    assert_response(:success)
    assert_template("logged_in")

    assert_equal(root_path, assigns(:return_path))
  end

  test "POST logout" do
    @request.session[:user_id] = 0

    post :logout

    assert_response(:redirect)
    assert_redirected_to(:controller => "auth", :action => "logged_out")

    assert_equal(nil, @request.session[:user_id])
  end

  test "GET logout, abnormal, method not allowed" do
    @request.session[:user_id] = 0

    get :logout

    assert_response(405)
    assert_template(nil)

    assert_equal(0, @request.session[:user_id])
  end

  test "GET logged_out" do
    return_path = "/return"

    get :logged_out, :return_path => return_path

    assert_response(:success)
    assert_template("logged_out")

    assert_equal(return_path, assigns(:return_path))
  end

  test "GET logged_out, without return path" do
    get :logged_out

    assert_response(:success)
    assert_template("logged_out")

    assert_equal(root_path, assigns(:return_path))
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
multi_auth-0.2.0 test/functional/auth_controller_test.rb
okkez-multi_auth-0.1.0 test/functional/auth_controller_test.rb
multi_auth-0.1.0 test/functional/auth_controller_test.rb
okkez-multi_auth-0.0.7 test/functional/auth_controller_test.rb
multi_auth-0.0.7 test/functional/auth_controller_test.rb
okkez-multi_auth-0.0.6 test/functional/auth_controller_test.rb
multi_auth-0.0.6 test/functional/auth_controller_test.rb
okkez-multi_auth-0.0.5 test/functional/auth_controller_test.rb
multi_auth-0.0.5 test/functional/auth_controller_test.rb