completing test coverage
This commit is contained in:
@ -9,17 +9,6 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest
|
||||
@account = accounts(:account1)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
get accounts_url
|
||||
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
get new_account_url
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create account" do
|
||||
assert_difference('Account.count') do
|
||||
post accounts_url, params: { account: {
|
||||
@ -33,14 +22,16 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest
|
||||
assert_redirected_to account_url(Account.last)
|
||||
end
|
||||
|
||||
test "should show account" do
|
||||
get account_url(@account)
|
||||
assert_response :success
|
||||
end
|
||||
test "should FAIL to create account" do
|
||||
assert_difference('Account.count', 0) do
|
||||
post accounts_url, params: { account: {
|
||||
password: @account.password,
|
||||
username: 'client-new'
|
||||
} }
|
||||
end
|
||||
|
||||
test "should get edit" do
|
||||
get edit_account_url(@account)
|
||||
assert_response :success
|
||||
assert_match(/failed to create/i, flash[:error])
|
||||
end
|
||||
|
||||
test "should update account" do
|
||||
@ -53,6 +44,13 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest
|
||||
assert_redirected_to account_url(@account)
|
||||
end
|
||||
|
||||
test "should FAIL to update account" do
|
||||
patch account_url(@account.id), params: { account: { username: nil } }
|
||||
|
||||
assert_response :success
|
||||
assert_match(/failed to update/i, flash[:error])
|
||||
end
|
||||
|
||||
test "should destroy account" do
|
||||
assert_difference('Account.count', -1) do
|
||||
delete account_url(@account)
|
||||
@ -60,12 +58,4 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest
|
||||
|
||||
assert_redirected_to accounts_url
|
||||
end
|
||||
|
||||
test 'reveal should provide password' do
|
||||
get reveal_password_url(@account.to_i), xhr: true
|
||||
json = JSON.parse(response.body).to_hash
|
||||
|
||||
assert_response :success
|
||||
assert_match '1q2w3e4r5t6y7u', json['hash']
|
||||
end
|
||||
end
|
40
test/controllers/accounts_controller/view_test.rb
Normal file
40
test/controllers/accounts_controller/view_test.rb
Normal file
@ -0,0 +1,40 @@
|
||||
# frozen_string_literal: true
|
||||
require 'test_helper'
|
||||
|
||||
class AccountsControllerTest < ActionDispatch::IntegrationTest
|
||||
include TestAuthHelper
|
||||
|
||||
setup do
|
||||
get auth_path
|
||||
@account = accounts(:account1)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
get accounts_url
|
||||
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
get new_account_url
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should show account" do
|
||||
get account_url(@account)
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get edit" do
|
||||
get edit_account_url(@account)
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test 'reveal should provide password' do
|
||||
get reveal_password_url(@account.to_i), xhr: true
|
||||
json = JSON.parse(response.body).to_hash
|
||||
|
||||
assert_response :success
|
||||
assert_match '1q2w3e4r5t6y7u', json['hash']
|
||||
end
|
||||
end
|
@ -4,7 +4,7 @@ require 'test_helper'
|
||||
class AuthControllerTest < ActionDispatch::IntegrationTest
|
||||
include TestAuthHelper
|
||||
|
||||
test "should get auth" do
|
||||
test "Should fake login process" do
|
||||
# This is not a real test of AuthController!
|
||||
# We are really testing that the monkey path is correct
|
||||
#
|
||||
@ -26,4 +26,13 @@ class AuthControllerTest < ActionDispatch::IntegrationTest
|
||||
|
||||
assert_equal "redirect_to accounts_path", last_line_in_callback
|
||||
end
|
||||
|
||||
test 'should logout' do
|
||||
get auth_path
|
||||
assert session[:token]
|
||||
|
||||
get logout_path
|
||||
assert session[:token].nil?
|
||||
assert_redirected_to login_path
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user