2016-08-27 21:40:21 -05:00
|
|
|
require 'test_helper'
|
|
|
|
|
|
|
|
class AccountsControllerTest < ActionDispatch::IntegrationTest
|
2016-09-17 21:53:41 -05:00
|
|
|
include TestAuthHelper
|
|
|
|
|
2016-08-27 21:40:21 -05:00
|
|
|
setup do
|
2016-09-17 21:53:41 -05:00
|
|
|
get auth_path
|
2016-08-28 10:32:26 -05:00
|
|
|
@account = accounts(:account1)
|
2016-08-27 21:40:21 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
test "should get index" do
|
|
|
|
get accounts_url
|
2016-09-17 21:53:41 -05:00
|
|
|
|
2016-08-27 21:40:21 -05:00
|
|
|
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: {
|
|
|
|
home: @account.home,
|
|
|
|
password: @account.password,
|
|
|
|
site: @account.site,
|
|
|
|
username: 'client-new'
|
|
|
|
} }
|
|
|
|
end
|
|
|
|
|
|
|
|
assert_redirected_to account_url(Account.last)
|
|
|
|
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 "should update account" do
|
|
|
|
patch account_url(@account), params: { account: {
|
|
|
|
home: @account.home,
|
|
|
|
password: @account.password,
|
|
|
|
site: @account.site,
|
|
|
|
username: @account.username
|
|
|
|
} }
|
|
|
|
assert_redirected_to account_url(@account)
|
|
|
|
end
|
|
|
|
|
|
|
|
test "should destroy account" do
|
|
|
|
assert_difference('Account.count', -1) do
|
|
|
|
delete account_url(@account)
|
|
|
|
end
|
|
|
|
|
|
|
|
assert_redirected_to accounts_url
|
|
|
|
end
|
2016-09-11 19:53:02 -05:00
|
|
|
|
|
|
|
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
|
2016-08-27 21:40:21 -05:00
|
|
|
end
|