Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'test_helper'
- class UsersLoginTest < ActionDispatch::IntegrationTest
- def setup
- @user = users(:michael)
- end
- test "login with invalid information" do
- get login_path
- assert_template 'sessions/new'
- post login_path, params: { session: { email: "", password: "" } }
- assert_template 'sessions/new'
- assert_not flash.empty?
- get root_path
- assert flash.empty?
- end
- test "login with valid information" do
- get login_path
- post login_path, params: { session: { email: @user.email,
- password: 'password' } }
- assert_redirected_to @user
- follow_redirect!
- assert_template 'users/show'
- assert_select "a[href=?]", login_path, count: 0
- assert_select "a[href=?]", logout_path
- assert_select "a[href=?]", user_path(@user)
- end
- test "login with valid information followed by logout" do
- get login_path
- post login_path, params: { session: { email: @user.email,
- password: 'password' } }
- assert is_logged_in?
- assert_redirected_to @user
- follow_redirect!
- assert_template 'users/show'
- assert_select "a[href=?]", login_path, count: 0
- assert_select "a[href=?]", logout_path
- assert_select "a[gref=?]", user_path(@user)
- delete logout_path
- assert_not is_logged_in?
- assert_redirected_to root_url
- follow_redirect!
- assert_select "a[href=?]", login_path
- assert_select "a[href=?]", logout_path, count = 0
- assert_select "a[href=?]", user_path(@user), count = 0
- end
- end
- # i po rails test takie o
- FAIL["test_login_with_valid_information", UsersLoginTest, 0.6958769999910146]
- test_login_with_valid_information#UsersLoginTest (0.70s)
- Expected at least 1 element matching "a[href="/logout"]", found 0..
- Expected 0 to be >= 1.
- test/integration/users_login_test.rb:26:in `block in <class:UsersLoginTest>'
- FAIL["test_login_with_valid_information_followed_by_logout", UsersLoginTest, 0.7184420000121463]
- test_login_with_valid_information_followed_by_logout#UsersLoginTest (0.72s)
- Expected at least 1 element matching "a[href="/logout"]", found 0..
- Expected 0 to be >= 1.
- test/integration/users_login_test.rb:39:in `block in <class:UsersLoginTest>'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement