Sha256: 47da6b2cadf669e02cbd48130c024ab7c91e3c0f734813d71a176835f853bc88

Contents?: true

Size: 1.33 KB

Versions: 9

Compression:

Stored size: 1.33 KB

Contents

require 'test_helper'

class CredentialsControllerTest < ActionController::TestCase
  def setup
    @yuya = users(:yuya)

    session_login(@yuya)
  end

  test "routes" do
    base = {:controller => "credentials"}

    assert_routing("/credentials", base.merge(:action => "index"))
  end

  test "GET index" do
    get :index

    assert_response(:success)
    assert_template("index")
    assert_flash_empty
    assert_logged_in(@yuya)

    open_id_credentials = assigns(:open_id_credentials)
    assert_equal(@yuya.open_id_credentials.size, open_id_credentials.size)
    assert_equal(true, open_id_credentials.all? { |o| o.user == @yuya })
    assert_equal(
      open_id_credentials.sort_by(&:identity_url),
      open_id_credentials)

    email_credentials = assigns(:email_credentials)
    assert_equal(@yuya.email_credentials.size, email_credentials.size)
    assert_equal(true, email_credentials.all? { |e| e.user == @yuya})
    assert_equal(
      email_credentials.sort_by(&:email),
      email_credentials)
  end

  test "GET index, abnormal, no login" do
    session_logout

    get :index

    assert_response(:redirect)
    assert_redirected_to(root_path)
    assert_flash_error
  end

  test "GET index, session expired" do
    session[:expires_at] = Time.now - 1

    get :index

    assert_response(:success)
    assert_flash_error
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

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