account working
This commit is contained in:
@@ -0,0 +1,84 @@
|
|||||||
|
body {
|
||||||
|
background-color: #fff;
|
||||||
|
color: #333;
|
||||||
|
margin: 33px;
|
||||||
|
font-family: verdana, arial, helvetica, sans-serif;
|
||||||
|
font-size: 13px;
|
||||||
|
line-height: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
p, ol, ul, td {
|
||||||
|
font-family: verdana, arial, helvetica, sans-serif;
|
||||||
|
font-size: 13px;
|
||||||
|
line-height: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
pre {
|
||||||
|
background-color: #eee;
|
||||||
|
padding: 10px;
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: #000;
|
||||||
|
|
||||||
|
&:visited {
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: #fff;
|
||||||
|
background-color: #000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
th {
|
||||||
|
padding-bottom: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
td {
|
||||||
|
padding: 0 5px 7px;
|
||||||
|
}
|
||||||
|
|
||||||
|
div {
|
||||||
|
&.field, &.actions {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#notice {
|
||||||
|
color: green;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field_with_errors {
|
||||||
|
padding: 2px;
|
||||||
|
background-color: red;
|
||||||
|
display: table;
|
||||||
|
}
|
||||||
|
|
||||||
|
#error_explanation {
|
||||||
|
width: 450px;
|
||||||
|
border: 2px solid red;
|
||||||
|
padding: 7px 7px 0;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
background-color: #f0f0f0;
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
text-align: left;
|
||||||
|
font-weight: bold;
|
||||||
|
padding: 5px 5px 5px 15px;
|
||||||
|
font-size: 12px;
|
||||||
|
margin: -7px -7px 0;
|
||||||
|
background-color: #c00;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul li {
|
||||||
|
font-size: 12px;
|
||||||
|
list-style: square;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
label {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|||||||
73
app/controllers/settings/accounts_controller.rb
Normal file
73
app/controllers/settings/accounts_controller.rb
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
class Settings::AccountsController < ApplicationController
|
||||||
|
before_action :set_account, only: [:show, :edit, :update, :destroy]
|
||||||
|
|
||||||
|
# GET /settings/accounts
|
||||||
|
# GET /settings/accounts.json
|
||||||
|
def index
|
||||||
|
@settings_accounts = Account.all
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /settings/accounts/1
|
||||||
|
# GET /settings/accounts/1.json
|
||||||
|
def show
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /settings/accounts/new
|
||||||
|
def new
|
||||||
|
@settings_account = Account.new
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /settings/accounts/1/edit
|
||||||
|
def edit
|
||||||
|
end
|
||||||
|
|
||||||
|
# POST /settings/accounts
|
||||||
|
# POST /settings/accounts.json
|
||||||
|
def create
|
||||||
|
@settings_account = Account.new(account_params)
|
||||||
|
respond_to do |format|
|
||||||
|
if @settings_account.save!
|
||||||
|
format.html { redirect_to settings_accounts_url, notice: 'Account was successfully created.' }
|
||||||
|
format.json { render :index, status: :created, location: @settings_account }
|
||||||
|
else
|
||||||
|
format.html { render :new }
|
||||||
|
format.json { render json: settings_accounts_url.errors, status: :unprocessable_entity }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# PATCH/PUT /settings/accounts/1
|
||||||
|
# PATCH/PUT /settings/accounts/1.json
|
||||||
|
def update
|
||||||
|
respond_to do |format|
|
||||||
|
if @settings_account.update(account_params)
|
||||||
|
format.html { redirect_to settings_accounts_url, notice: 'Account was successfully updated.' }
|
||||||
|
format.json { render :index, status: :ok, location: @settings_account }
|
||||||
|
else
|
||||||
|
format.html { render :edit }
|
||||||
|
format.json { render json: settings_accounts_url.errors, status: :unprocessable_entity }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# DELETE /settings/accounts/1
|
||||||
|
# DELETE /settings/accounts/1.json
|
||||||
|
def destroy
|
||||||
|
@settings_account.destroy
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { redirect_to settings_accounts_url, notice: 'Account was successfully destroyed.' }
|
||||||
|
format.json { head :no_content }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
# Use callbacks to share common setup or constraints between actions.
|
||||||
|
def set_account
|
||||||
|
@settings_account = Account.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
# Never trust parameters from the scary internet, only allow the white list through.
|
||||||
|
def account_params
|
||||||
|
params.require(:account).permit(:title, :account_type)
|
||||||
|
end
|
||||||
|
end
|
||||||
2
app/helpers/settings/accounts_helper.rb
Normal file
2
app/helpers/settings/accounts_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
module Settings::AccountsHelper
|
||||||
|
end
|
||||||
7
app/models/account.rb
Normal file
7
app/models/account.rb
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
class Account < ApplicationRecord
|
||||||
|
validates_presence_of :title, :account_type
|
||||||
|
|
||||||
|
has_many :menu_items
|
||||||
|
# belongs_to :lookup , :class_name => "Lookup" ,:foreign_key => :tax_type
|
||||||
|
|
||||||
|
end
|
||||||
5
app/models/crm.rb
Normal file
5
app/models/crm.rb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
module Crm
|
||||||
|
def self.table_name_prefix
|
||||||
|
'crm_'
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
class Lookup < ApplicationRecord
|
class Lookup < ApplicationRecord
|
||||||
|
|
||||||
|
has_many :accounts
|
||||||
|
|
||||||
def available_types
|
def available_types
|
||||||
{'Employee Roles' => 'employee_roles',
|
{'Employee Roles' => 'employee_roles',
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ class MenuItem < ApplicationRecord
|
|||||||
has_many :menu_item_instances
|
has_many :menu_item_instances
|
||||||
belongs_to :parent, :class_name => "MenuItem", foreign_key: "menu_item_id", :optional => true
|
belongs_to :parent, :class_name => "MenuItem", foreign_key: "menu_item_id", :optional => true
|
||||||
has_many :children, :class_name => "MenuItem", foreign_key: "menu_item_id"
|
has_many :children, :class_name => "MenuItem", foreign_key: "menu_item_id"
|
||||||
|
belongs_to :account
|
||||||
|
|
||||||
default_scope { order('item_code asc') }
|
default_scope { order('item_code asc') }
|
||||||
|
|
||||||
def self.collection
|
def self.collection
|
||||||
|
|||||||
14
app/views/settings/accounts/_form.html.erb
Normal file
14
app/views/settings/accounts/_form.html.erb
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<%= simple_form_for([:settings,@settings_account]) do |f| %>
|
||||||
|
<%= f.error_notification %>
|
||||||
|
|
||||||
|
<div class="form-inputs">
|
||||||
|
<%= f.input :title %>
|
||||||
|
<%= f.input :account_type, :collection => Lookup.collection_of("account_type") %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-actions">
|
||||||
|
<%= f.button :submit %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<% end %>
|
||||||
|
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
json.extract! settings_account, :id, :title, :account_type, :created_at, :updated_at
|
||||||
|
json.url settings_account_url(settings_account, format: :json)
|
||||||
10
app/views/settings/accounts/edit.html.erb
Normal file
10
app/views/settings/accounts/edit.html.erb
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<div class="span12">
|
||||||
|
<div class="page-header">
|
||||||
|
<ul class="breadcrumb">
|
||||||
|
<li><a href="<%= root_path %>">Home</a></li>
|
||||||
|
<li><a href="<%= settings_accounts_path %>">Account</a></li>
|
||||||
|
<li>Edit</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<%= render 'form', settings_account: @settings_account %>
|
||||||
|
</div>
|
||||||
40
app/views/settings/accounts/index.html.erb
Normal file
40
app/views/settings/accounts/index.html.erb
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
|
||||||
|
|
||||||
|
<%= link_to 'New Settings Account', new_settings_account_path %>
|
||||||
|
|
||||||
|
<div class="page-header">
|
||||||
|
<ul class="breadcrumb">
|
||||||
|
<li><a href="<%= %>">Home</a></li>
|
||||||
|
<li>Account</li>
|
||||||
|
<span style="float: right">
|
||||||
|
<%= link_to t('.new', :default => t("helpers.links.new")),new_settings_account_path,:class => 'btn btn-primary btn-sm' %>
|
||||||
|
</span>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<div class="card">
|
||||||
|
<table class="table table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th style="width:40%">Title</th>
|
||||||
|
<th style="width:40%">Account Type</th>
|
||||||
|
<th style="width:20%">Action</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
<% @settings_accounts.each do |account| %>
|
||||||
|
<tr>
|
||||||
|
<td><%= account.title %></td>
|
||||||
|
<td><%= account.account_type %></td>
|
||||||
|
<td>
|
||||||
|
<%= link_to 'Edit', edit_settings_account_path(account) %> |
|
||||||
|
<%= link_to 'Destroy', settings_account_path(account), method: :delete, data: { confirm: 'Are you sure?' } %>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
1
app/views/settings/accounts/index.json.jbuilder
Normal file
1
app/views/settings/accounts/index.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
|||||||
|
json.array! @settings_accounts, partial: 'settings_accounts/settings_account', as: :settings_account
|
||||||
11
app/views/settings/accounts/new.html.erb
Normal file
11
app/views/settings/accounts/new.html.erb
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<div class="span12">
|
||||||
|
<div class="page-header">
|
||||||
|
<ul class="breadcrumb">
|
||||||
|
<li><a href="<%= root_path %>">Home</a></li>
|
||||||
|
<li><a href="<%= settings_accounts_path %>">Account</a></li>
|
||||||
|
<li>New</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<%= render 'form', settings_account: @settings_account %>
|
||||||
|
</div>
|
||||||
|
|
||||||
36
app/views/settings/accounts/show.html.erb
Normal file
36
app/views/settings/accounts/show.html.erb
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="page-header">
|
||||||
|
<ul class="breadcrumb">
|
||||||
|
<li><a href="<%= %>">Home</a></li>
|
||||||
|
<li>Account</li>
|
||||||
|
<span style="float: right">
|
||||||
|
</span>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-block">
|
||||||
|
<h4 class="card-title">Account</h4>
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Title</th>
|
||||||
|
<th>Account type</th>
|
||||||
|
<th>Action</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td><%= @settings_account.title %></td>
|
||||||
|
<td><%= @settings_account.account_type %></td>
|
||||||
|
|
||||||
|
<td><%= link_to 'Edit', edit_settings_account_path(@settings_account) %></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
1
app/views/settings/accounts/show.json.jbuilder
Normal file
1
app/views/settings/accounts/show.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
|||||||
|
json.partial! "settings_accounts/settings_account", settings_account: @settings_account
|
||||||
@@ -2,6 +2,9 @@ require 'sidekiq/web'
|
|||||||
|
|
||||||
Rails.application.routes.draw do
|
Rails.application.routes.draw do
|
||||||
|
|
||||||
|
namespace :settings do
|
||||||
|
resources :accounts
|
||||||
|
end
|
||||||
root 'home#index'
|
root 'home#index'
|
||||||
mount Sidekiq::Web => '/kiq'
|
mount Sidekiq::Web => '/kiq'
|
||||||
|
|
||||||
@@ -108,6 +111,9 @@ Rails.application.routes.draw do
|
|||||||
resources :menu_categories, only: [:new, :create, :edit]
|
resources :menu_categories, only: [:new, :create, :edit]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#accounts
|
||||||
|
resources :accounts
|
||||||
|
|
||||||
resources :menu_categories do
|
resources :menu_categories do
|
||||||
#menu_items
|
#menu_items
|
||||||
#resources :menu_items
|
#resources :menu_items
|
||||||
|
|||||||
10
db/migrate/20170602101727_create_accounts.rb
Normal file
10
db/migrate/20170602101727_create_accounts.rb
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
class CreateAccounts < ActiveRecord::Migration[5.1]
|
||||||
|
def change
|
||||||
|
create_table :accounts do |t|
|
||||||
|
t.string :title
|
||||||
|
t.string :account_type
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -70,6 +70,10 @@ booking_status = Lookup.create([{lookup_type:'booking_status', name: 'Available'
|
|||||||
{lookup_type:'booking_status', name: 'Cleaning', value: 'cleaning'},
|
{lookup_type:'booking_status', name: 'Cleaning', value: 'cleaning'},
|
||||||
{lookup_type:'booking_status', name: 'Moved', value: 'moved'}])
|
{lookup_type:'booking_status', name: 'Moved', value: 'moved'}])
|
||||||
|
|
||||||
|
#booking_status
|
||||||
|
account_type = Lookup.create([{lookup_type:'account_type', name: 'Income', value: 'income'},
|
||||||
|
{lookup_type:'account_type', name: 'Expense', value: 'expense'}])
|
||||||
|
|
||||||
#WALK CUSTOMER - Default CUSTOMER (take key 1)
|
#WALK CUSTOMER - Default CUSTOMER (take key 1)
|
||||||
customer = Customer.create({id:1, name:"WALK-IN", contact_no:"000000000"})
|
customer = Customer.create({id:1, name:"WALK-IN", contact_no:"000000000"})
|
||||||
customer = Customer.create({id:2, name:"TAKEAWAY", contact_no:"000000000"})
|
customer = Customer.create({id:2, name:"TAKEAWAY", contact_no:"000000000"})
|
||||||
|
|||||||
141
spec/controllers/settings/accounts_controller_spec.rb
Normal file
141
spec/controllers/settings/accounts_controller_spec.rb
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
||||||
|
# It demonstrates how one might use RSpec to specify the controller code that
|
||||||
|
# was generated by Rails when you ran the scaffold generator.
|
||||||
|
#
|
||||||
|
# It assumes that the implementation code is generated by the rails scaffold
|
||||||
|
# generator. If you are using any extension libraries to generate different
|
||||||
|
# controller code, this generated spec may or may not pass.
|
||||||
|
#
|
||||||
|
# It only uses APIs available in rails and/or rspec-rails. There are a number
|
||||||
|
# of tools you can use to make these specs even more expressive, but we're
|
||||||
|
# sticking to rails and rspec-rails APIs to keep things simple and stable.
|
||||||
|
#
|
||||||
|
# Compared to earlier versions of this generator, there is very limited use of
|
||||||
|
# stubs and message expectations in this spec. Stubs are only used when there
|
||||||
|
# is no simpler way to get a handle on the object needed for the example.
|
||||||
|
# Message expectations are only used when there is no simpler way to specify
|
||||||
|
# that an instance is receiving a specific message.
|
||||||
|
#
|
||||||
|
# Also compared to earlier versions of this generator, there are no longer any
|
||||||
|
# expectations of assigns and templates rendered. These features have been
|
||||||
|
# removed from Rails core in Rails 5, but can be added back in via the
|
||||||
|
# `rails-controller-testing` gem.
|
||||||
|
|
||||||
|
RSpec.describe Settings::AccountsController, type: :controller do
|
||||||
|
|
||||||
|
# This should return the minimal set of attributes required to create a valid
|
||||||
|
# Settings::Account. As you add validations to Settings::Account, be sure to
|
||||||
|
# adjust the attributes here as well.
|
||||||
|
let(:valid_attributes) {
|
||||||
|
skip("Add a hash of attributes valid for your model")
|
||||||
|
}
|
||||||
|
|
||||||
|
let(:invalid_attributes) {
|
||||||
|
skip("Add a hash of attributes invalid for your model")
|
||||||
|
}
|
||||||
|
|
||||||
|
# This should return the minimal set of values that should be in the session
|
||||||
|
# in order to pass any filters (e.g. authentication) defined in
|
||||||
|
# Settings::AccountsController. Be sure to keep this updated too.
|
||||||
|
let(:valid_session) { {} }
|
||||||
|
|
||||||
|
describe "GET #index" do
|
||||||
|
it "returns a success response" do
|
||||||
|
account = Settings::Account.create! valid_attributes
|
||||||
|
get :index, params: {}, session: valid_session
|
||||||
|
expect(response).to be_success
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "GET #show" do
|
||||||
|
it "returns a success response" do
|
||||||
|
account = Settings::Account.create! valid_attributes
|
||||||
|
get :show, params: {id: account.to_param}, session: valid_session
|
||||||
|
expect(response).to be_success
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "GET #new" do
|
||||||
|
it "returns a success response" do
|
||||||
|
get :new, params: {}, session: valid_session
|
||||||
|
expect(response).to be_success
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "GET #edit" do
|
||||||
|
it "returns a success response" do
|
||||||
|
account = Settings::Account.create! valid_attributes
|
||||||
|
get :edit, params: {id: account.to_param}, session: valid_session
|
||||||
|
expect(response).to be_success
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "POST #create" do
|
||||||
|
context "with valid params" do
|
||||||
|
it "creates a new Settings::Account" do
|
||||||
|
expect {
|
||||||
|
post :create, params: {settings_account: valid_attributes}, session: valid_session
|
||||||
|
}.to change(Settings::Account, :count).by(1)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "redirects to the created settings_account" do
|
||||||
|
post :create, params: {settings_account: valid_attributes}, session: valid_session
|
||||||
|
expect(response).to redirect_to(Settings::Account.last)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "with invalid params" do
|
||||||
|
it "returns a success response (i.e. to display the 'new' template)" do
|
||||||
|
post :create, params: {settings_account: invalid_attributes}, session: valid_session
|
||||||
|
expect(response).to be_success
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "PUT #update" do
|
||||||
|
context "with valid params" do
|
||||||
|
let(:new_attributes) {
|
||||||
|
skip("Add a hash of attributes valid for your model")
|
||||||
|
}
|
||||||
|
|
||||||
|
it "updates the requested settings_account" do
|
||||||
|
account = Settings::Account.create! valid_attributes
|
||||||
|
put :update, params: {id: account.to_param, settings_account: new_attributes}, session: valid_session
|
||||||
|
account.reload
|
||||||
|
skip("Add assertions for updated state")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "redirects to the settings_account" do
|
||||||
|
account = Settings::Account.create! valid_attributes
|
||||||
|
put :update, params: {id: account.to_param, settings_account: valid_attributes}, session: valid_session
|
||||||
|
expect(response).to redirect_to(account)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "with invalid params" do
|
||||||
|
it "returns a success response (i.e. to display the 'edit' template)" do
|
||||||
|
account = Settings::Account.create! valid_attributes
|
||||||
|
put :update, params: {id: account.to_param, settings_account: invalid_attributes}, session: valid_session
|
||||||
|
expect(response).to be_success
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "DELETE #destroy" do
|
||||||
|
it "destroys the requested settings_account" do
|
||||||
|
account = Settings::Account.create! valid_attributes
|
||||||
|
expect {
|
||||||
|
delete :destroy, params: {id: account.to_param}, session: valid_session
|
||||||
|
}.to change(Settings::Account, :count).by(-1)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "redirects to the settings_accounts list" do
|
||||||
|
account = Settings::Account.create! valid_attributes
|
||||||
|
delete :destroy, params: {id: account.to_param}, session: valid_session
|
||||||
|
expect(response).to redirect_to(settings_accounts_url)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
15
spec/helpers/settings/accounts_helper_spec.rb
Normal file
15
spec/helpers/settings/accounts_helper_spec.rb
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
# Specs in this file have access to a helper object that includes
|
||||||
|
# the Settings::AccountsHelper. For example:
|
||||||
|
#
|
||||||
|
# describe Settings::AccountsHelper do
|
||||||
|
# describe "string concat" do
|
||||||
|
# it "concats two strings with spaces" do
|
||||||
|
# expect(helper.concat_strings("this","that")).to eq("this that")
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
RSpec.describe Settings::AccountsHelper, type: :helper do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
||||||
5
spec/models/account_spec.rb
Normal file
5
spec/models/account_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe Account, type: :model do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
||||||
5
spec/models/settings/account_spec.rb
Normal file
5
spec/models/settings/account_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe Settings::Account, type: :model do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
||||||
10
spec/requests/settings/settings_accounts_spec.rb
Normal file
10
spec/requests/settings/settings_accounts_spec.rb
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe "Settings::Accounts", type: :request do
|
||||||
|
describe "GET /settings_accounts" do
|
||||||
|
it "works! (now write some real specs)" do
|
||||||
|
get settings_accounts_path
|
||||||
|
expect(response).to have_http_status(200)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
39
spec/routing/settings/accounts_routing_spec.rb
Normal file
39
spec/routing/settings/accounts_routing_spec.rb
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
require "rails_helper"
|
||||||
|
|
||||||
|
RSpec.describe Settings::AccountsController, type: :routing do
|
||||||
|
describe "routing" do
|
||||||
|
|
||||||
|
it "routes to #index" do
|
||||||
|
expect(:get => "/settings/accounts").to route_to("settings/accounts#index")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "routes to #new" do
|
||||||
|
expect(:get => "/settings/accounts/new").to route_to("settings/accounts#new")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "routes to #show" do
|
||||||
|
expect(:get => "/settings/accounts/1").to route_to("settings/accounts#show", :id => "1")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "routes to #edit" do
|
||||||
|
expect(:get => "/settings/accounts/1/edit").to route_to("settings/accounts#edit", :id => "1")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "routes to #create" do
|
||||||
|
expect(:post => "/settings/accounts").to route_to("settings/accounts#create")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "routes to #update via PUT" do
|
||||||
|
expect(:put => "/settings/accounts/1").to route_to("settings/accounts#update", :id => "1")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "routes to #update via PATCH" do
|
||||||
|
expect(:patch => "/settings/accounts/1").to route_to("settings/accounts#update", :id => "1")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "routes to #destroy" do
|
||||||
|
expect(:delete => "/settings/accounts/1").to route_to("settings/accounts#destroy", :id => "1")
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
21
spec/views/settings/accounts/edit.html.erb_spec.rb
Normal file
21
spec/views/settings/accounts/edit.html.erb_spec.rb
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe "settings/accounts/edit", type: :view do
|
||||||
|
before(:each) do
|
||||||
|
@settings_account = assign(:settings_account, Settings::Account.create!(
|
||||||
|
:title => "MyString",
|
||||||
|
:account_type => "MyString"
|
||||||
|
))
|
||||||
|
end
|
||||||
|
|
||||||
|
it "renders the edit settings_account form" do
|
||||||
|
render
|
||||||
|
|
||||||
|
assert_select "form[action=?][method=?]", settings_account_path(@settings_account), "post" do
|
||||||
|
|
||||||
|
assert_select "input[name=?]", "settings_account[title]"
|
||||||
|
|
||||||
|
assert_select "input[name=?]", "settings_account[account_type]"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
22
spec/views/settings/accounts/index.html.erb_spec.rb
Normal file
22
spec/views/settings/accounts/index.html.erb_spec.rb
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe "settings/accounts/index", type: :view do
|
||||||
|
before(:each) do
|
||||||
|
assign(:settings_accounts, [
|
||||||
|
Settings::Account.create!(
|
||||||
|
:title => "Title",
|
||||||
|
:account_type => "Account Type"
|
||||||
|
),
|
||||||
|
Settings::Account.create!(
|
||||||
|
:title => "Title",
|
||||||
|
:account_type => "Account Type"
|
||||||
|
)
|
||||||
|
])
|
||||||
|
end
|
||||||
|
|
||||||
|
it "renders a list of settings/accounts" do
|
||||||
|
render
|
||||||
|
assert_select "tr>td", :text => "Title".to_s, :count => 2
|
||||||
|
assert_select "tr>td", :text => "Account Type".to_s, :count => 2
|
||||||
|
end
|
||||||
|
end
|
||||||
21
spec/views/settings/accounts/new.html.erb_spec.rb
Normal file
21
spec/views/settings/accounts/new.html.erb_spec.rb
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe "settings/accounts/new", type: :view do
|
||||||
|
before(:each) do
|
||||||
|
assign(:settings_account, Settings::Account.new(
|
||||||
|
:title => "MyString",
|
||||||
|
:account_type => "MyString"
|
||||||
|
))
|
||||||
|
end
|
||||||
|
|
||||||
|
it "renders new settings_account form" do
|
||||||
|
render
|
||||||
|
|
||||||
|
assert_select "form[action=?][method=?]", settings_accounts_path, "post" do
|
||||||
|
|
||||||
|
assert_select "input[name=?]", "settings_account[title]"
|
||||||
|
|
||||||
|
assert_select "input[name=?]", "settings_account[account_type]"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
16
spec/views/settings/accounts/show.html.erb_spec.rb
Normal file
16
spec/views/settings/accounts/show.html.erb_spec.rb
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe "settings/accounts/show", type: :view do
|
||||||
|
before(:each) do
|
||||||
|
@settings_account = assign(:settings_account, Settings::Account.create!(
|
||||||
|
:title => "Title",
|
||||||
|
:account_type => "Account Type"
|
||||||
|
))
|
||||||
|
end
|
||||||
|
|
||||||
|
it "renders attributes in <p>" do
|
||||||
|
render
|
||||||
|
expect(rendered).to match(/Title/)
|
||||||
|
expect(rendered).to match(/Account Type/)
|
||||||
|
end
|
||||||
|
end
|
||||||
5
test/application_system_test_case.rb
Normal file
5
test/application_system_test_case.rb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
require "test_helper"
|
||||||
|
|
||||||
|
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
|
||||||
|
driven_by :selenium, using: :chrome, screen_size: [1400, 1400]
|
||||||
|
end
|
||||||
9
test/system/accounts_test.rb
Normal file
9
test/system/accounts_test.rb
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
require "application_system_test_case"
|
||||||
|
|
||||||
|
class Settings::AccountsTest < ApplicationSystemTestCase
|
||||||
|
# test "visiting the index" do
|
||||||
|
# visit settings_accounts_url
|
||||||
|
#
|
||||||
|
# assert_selector "h1", text: "Settings::Account"
|
||||||
|
# end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user