Sha256: 5d84ecd2d4ee1a921e9a2a03acca05dd960e53199dabc89fdc232a803e7c17e9

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

require 'test_helper'

module AsUser
  class SessionsControllerTest < ActionController::TestCase
    setup do
    end

    teardown do
    end
  
    test "should get new" do
      get :new
      assert_response :success
      assert_select "form"
      assert_select "[name=?]","utf8"
      assert_select "[name=?]","commit"
      assert_select "[name=?]","user[email]",false
      assert_select "[name=?]","session[email]"
      assert_select "[name=?]","session[password]"
    end

    test "sign in then sign out" do
      user = FactoryGirl.create(:user)
      post :create, session: {email: user.email, password: user.password}
      assert_redirected_to user

      delete :destroy
      assert_nil session[:user_id]
      assert_redirected_to root_path
      assert_equal "signed out.", flash[:notice]
    end

    test "sign in with invalid user" do
      post :create, session: {email: "a", password: "xxx"}
      assert_template :new
      assert_equal "Invalid email/password combination", flash[:error]
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
as_user-0.0.3 test/functional/as_user/sessions_controller_test.rb