ftp-manager/test/controllers/accounts_controller/edit_test.rb

54 lines
1.4 KiB
Ruby
Raw Normal View History

2016-09-18 09:41:51 -05:00
# frozen_string_literal: true
2016-08-27 21:40:21 -05:00
require 'test_helper'
class AccountsControllerTest < ActionDispatch::IntegrationTest
include TestAuthHelper
2016-08-27 21:40:21 -05:00
setup do
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 create account" do
assert_difference('Account.count') do
post accounts_url, params: { account: {
2016-09-28 22:12:55 -05:00
home_folder: @account.home_folder,
2016-08-27 21:40:21 -05:00
password: @account.password,
2016-09-28 22:12:55 -05:00
contact_email: @account.contact_email,
2016-08-27 21:40:21 -05:00
username: 'client-new'
} }
end
assert_redirected_to account_url(Account.last)
end
2016-09-18 11:16:35 -05:00
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
2016-08-27 21:40:21 -05:00
assert_response :success
2016-09-18 11:16:35 -05:00
assert_match(/failed to create/i, flash[:error])
2016-08-27 21:40:21 -05:00
end
test "should update account" do
patch account_url(@account), params: { account: {
2016-09-28 22:12:55 -05:00
home_folder: @account.home_folder,
2016-08-27 21:40:21 -05:00
password: @account.password,
2016-09-28 22:12:55 -05:00
contact_email: @account.contact_email,
2016-08-27 21:40:21 -05:00
username: @account.username
} }
assert_redirected_to account_url(@account)
end
2016-09-18 11:16:35 -05:00
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
2016-08-27 21:40:21 -05:00
end