cleaned up accounts
This commit is contained in:
parent
33f3be1c79
commit
81c667da0f
@ -52,6 +52,6 @@ class AccountsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def account_params
|
def account_params
|
||||||
params.require(:account).permit(:username, :password, :home, :site)
|
params.require(:account).permit(:username, :password, :home_folder, :contact_email)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -4,6 +4,6 @@ class Account < ApplicationRecord
|
|||||||
|
|
||||||
validates :username, presence: true
|
validates :username, presence: true
|
||||||
validates :password, presence: true
|
validates :password, presence: true
|
||||||
validates :home, presence: true
|
validates :home_folder, presence: true
|
||||||
validates :site, presence: true
|
validates :contact_email, presence: true
|
||||||
end
|
end
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
# frozen_string_literal: true
|
# 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)
|
json.url account_url(account, format: :json)
|
||||||
|
@ -22,13 +22,13 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<%= f.label :home %>
|
<%= f.label :home_folder %>
|
||||||
<%= f.text_field :home %>
|
<%= f.text_field :home_folder %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<%= f.label :site %>
|
<%= f.label :contact_email %>
|
||||||
<%= f.text_field :site %>
|
<%= f.text_field :contact_email %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
|
@ -5,10 +5,10 @@
|
|||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th>Home Folder</th>
|
||||||
<th>Username</th>
|
<th>Username</th>
|
||||||
<th>Password</th>
|
<th>Password</th>
|
||||||
<th>Site</th>
|
<th>Contact eMail</th>
|
||||||
<th>Home</th>
|
|
||||||
<th colspan="3"></th>
|
<th colspan="3"></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@ -16,6 +16,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<% @accounts.each do |account| %>
|
<% @accounts.each do |account| %>
|
||||||
<tr>
|
<tr>
|
||||||
|
<td><%= account.home_folder %></td>
|
||||||
<td><%= account.username %></td>
|
<td><%= account.username %></td>
|
||||||
<td class="passwd" data-id="passwd">
|
<td class="passwd" data-id="passwd">
|
||||||
<%= link_to reveal_password_path(account.id), remote: true do %>
|
<%= link_to reveal_password_path(account.id), remote: true do %>
|
||||||
@ -23,8 +24,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
<span>********</span>
|
<span>********</span>
|
||||||
</td>
|
</td>
|
||||||
<td><%= account.site %></td>
|
<td><%= account.contact_email %></td>
|
||||||
<td><%= account.home %></td>
|
|
||||||
<td><%= link_to 'Show', account %></td>
|
<td><%= link_to 'Show', account %></td>
|
||||||
<td><%= link_to 'Edit', edit_account_path(account) %></td>
|
<td><%= link_to 'Edit', edit_account_path(account) %></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -16,13 +16,13 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<strong>Home:</strong>
|
<strong>Home Folder:</strong>
|
||||||
<%= @account.home %>
|
<%= @account.home_folder %>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<strong>Site:</strong>
|
<strong>Contact Email:</strong>
|
||||||
<%= @account.site %>
|
<%= @account.contact_email %>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<%= link_to 'Destroy', @account, method: :delete, data: { confirm: 'Are you sure?' } %>
|
<%= link_to 'Destroy', @account, method: :delete, data: { confirm: 'Are you sure?' } %>
|
||||||
|
@ -2,11 +2,10 @@
|
|||||||
class CreateAccounts < ActiveRecord::Migration[5.0]
|
class CreateAccounts < ActiveRecord::Migration[5.0]
|
||||||
def change
|
def change
|
||||||
create_table :accounts do |t|
|
create_table :accounts do |t|
|
||||||
t.string :username
|
t.string :username, null: false
|
||||||
t.string :password
|
t.string :password, null: false
|
||||||
t.string :home
|
t.string :home_folder, null: false
|
||||||
t.string :site
|
t.string :contact_email, null: false
|
||||||
|
|
||||||
t.timestamps
|
t.timestamps
|
||||||
end
|
end
|
||||||
add_index :accounts, :username, unique: true
|
add_index :accounts, :username, unique: true
|
||||||
|
14
db/schema.rb
14
db/schema.rb
@ -10,15 +10,15 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# 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|
|
create_table "accounts", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
|
||||||
t.string "username"
|
t.string "username", null: false
|
||||||
t.string "password"
|
t.string "password", null: false
|
||||||
t.string "home"
|
t.string "home_folder"
|
||||||
t.string "site"
|
t.string "contact_email", null: false
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.index ["username"], name: "index_accounts_on_username", unique: true, using: :btree
|
t.index ["username"], name: "index_accounts_on_username", unique: true, using: :btree
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -12,9 +12,9 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest
|
|||||||
test "should create account" do
|
test "should create account" do
|
||||||
assert_difference('Account.count') do
|
assert_difference('Account.count') do
|
||||||
post accounts_url, params: { account: {
|
post accounts_url, params: { account: {
|
||||||
home: @account.home,
|
home_folder: @account.home_folder,
|
||||||
password: @account.password,
|
password: @account.password,
|
||||||
site: @account.site,
|
contact_email: @account.contact_email,
|
||||||
username: 'client-new'
|
username: 'client-new'
|
||||||
} }
|
} }
|
||||||
end
|
end
|
||||||
@ -36,9 +36,9 @@ class AccountsControllerTest < ActionDispatch::IntegrationTest
|
|||||||
|
|
||||||
test "should update account" do
|
test "should update account" do
|
||||||
patch account_url(@account), params: { account: {
|
patch account_url(@account), params: { account: {
|
||||||
home: @account.home,
|
home_folder: @account.home_folder,
|
||||||
password: @account.password,
|
password: @account.password,
|
||||||
site: @account.site,
|
contact_email: @account.contact_email,
|
||||||
username: @account.username
|
username: @account.username
|
||||||
} }
|
} }
|
||||||
assert_redirected_to account_url(@account)
|
assert_redirected_to account_url(@account)
|
||||||
|
4
test/fixtures/accounts.yml
vendored
4
test/fixtures/accounts.yml
vendored
@ -3,5 +3,5 @@
|
|||||||
account1:
|
account1:
|
||||||
username: client-one
|
username: client-one
|
||||||
password: <%= CryptSerializer.dump('1q2w3e4r5t6y7u') %>
|
password: <%= CryptSerializer.dump('1q2w3e4r5t6y7u') %>
|
||||||
home: client_one
|
home_folder: client_one
|
||||||
site: dev
|
contact_email: ftp-user@mailinator.com
|
||||||
|
@ -20,7 +20,7 @@ WebMock.disable_net_connect!(allow_localhost: true)
|
|||||||
Minitest::Reporters.use! [Minitest::Reporters::DefaultReporter.new(color: true)]
|
Minitest::Reporters.use! [Minitest::Reporters::DefaultReporter.new(color: true)]
|
||||||
|
|
||||||
class ActiveSupport::TestCase
|
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.
|
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
|
||||||
fixtures :all
|
fixtures :all
|
||||||
|
Loading…
Reference in New Issue
Block a user