cleaned up accounts

This commit is contained in:
Mark Moser 2016-09-28 22:12:55 -05:00
parent 33f3be1c79
commit 81c667da0f
11 changed files with 34 additions and 35 deletions

View File

@ -52,6 +52,6 @@ class AccountsController < ApplicationController
end
def account_params
params.require(:account).permit(:username, :password, :home, :site)
params.require(:account).permit(:username, :password, :home_folder, :contact_email)
end
end

View File

@ -4,6 +4,6 @@ class Account < ApplicationRecord
validates :username, presence: true
validates :password, presence: true
validates :home, presence: true
validates :site, presence: true
validates :home_folder, presence: true
validates :contact_email, presence: true
end

View File

@ -1,3 +1,3 @@
# frozen_string_literal: true
json.extract! account, :id, :username, :password, :home, :site, :created_at, :updated_at
json.extract! account, :id, :username, :password, :home_folder, :contact_email, :created_at, :updated_at
json.url account_url(account, format: :json)

View File

@ -22,13 +22,13 @@
</div>
<div class="field">
<%= f.label :home %>
<%= f.text_field :home %>
<%= f.label :home_folder %>
<%= f.text_field :home_folder %>
</div>
<div class="field">
<%= f.label :site %>
<%= f.text_field :site %>
<%= f.label :contact_email %>
<%= f.text_field :contact_email %>
</div>
<div class="actions">

View File

@ -5,10 +5,10 @@
<table>
<thead>
<tr>
<th>Home Folder</th>
<th>Username</th>
<th>Password</th>
<th>Site</th>
<th>Home</th>
<th>Contact eMail</th>
<th colspan="3"></th>
</tr>
</thead>
@ -16,6 +16,7 @@
<tbody>
<% @accounts.each do |account| %>
<tr>
<td><%= account.home_folder %></td>
<td><%= account.username %></td>
<td class="passwd" data-id="passwd">
<%= link_to reveal_password_path(account.id), remote: true do %>
@ -23,8 +24,7 @@
<% end %>
<span>********</span>
</td>
<td><%= account.site %></td>
<td><%= account.home %></td>
<td><%= account.contact_email %></td>
<td><%= link_to 'Show', account %></td>
<td><%= link_to 'Edit', edit_account_path(account) %></td>
</tr>

View File

@ -16,13 +16,13 @@
</p>
<p>
<strong>Home:</strong>
<%= @account.home %>
<strong>Home Folder:</strong>
<%= @account.home_folder %>
</p>
<p>
<strong>Site:</strong>
<%= @account.site %>
<strong>Contact Email:</strong>
<%= @account.contact_email %>
</p>
<%= link_to 'Destroy', @account, method: :delete, data: { confirm: 'Are you sure?' } %>

View File

@ -2,11 +2,10 @@
class CreateAccounts < ActiveRecord::Migration[5.0]
def change
create_table :accounts do |t|
t.string :username
t.string :password
t.string :home
t.string :site
t.string :username, null: false
t.string :password, null: false
t.string :home_folder, null: false
t.string :contact_email, null: false
t.timestamps
end
add_index :accounts, :username, unique: true

View File

@ -10,15 +10,15 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20160828022337) do
ActiveRecord::Schema.define(version: 20160929022453) do
create_table "accounts", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.string "username"
t.string "password"
t.string "home"
t.string "site"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "username", null: false
t.string "password", null: false
t.string "home_folder"
t.string "contact_email", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["username"], name: "index_accounts_on_username", unique: true, using: :btree
end

View File

@ -12,9 +12,9 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest
test "should create account" do
assert_difference('Account.count') do
post accounts_url, params: { account: {
home: @account.home,
home_folder: @account.home_folder,
password: @account.password,
site: @account.site,
contact_email: @account.contact_email,
username: 'client-new'
} }
end
@ -36,9 +36,9 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest
test "should update account" do
patch account_url(@account), params: { account: {
home: @account.home,
home_folder: @account.home_folder,
password: @account.password,
site: @account.site,
contact_email: @account.contact_email,
username: @account.username
} }
assert_redirected_to account_url(@account)

View File

@ -3,5 +3,5 @@
account1:
username: client-one
password: <%= CryptSerializer.dump('1q2w3e4r5t6y7u') %>
home: client_one
site: dev
home_folder: client_one
contact_email: ftp-user@mailinator.com

View File

@ -20,7 +20,7 @@ WebMock.disable_net_connect!(allow_localhost: true)
Minitest::Reporters.use! [Minitest::Reporters::DefaultReporter.new(color: true)]
class ActiveSupport::TestCase
ActiveRecord::Migration.check_pending!
ActiveRecord::Migration.maintain_test_schema!
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all