basic layout template
This commit is contained in:
2
Gemfile
2
Gemfile
@@ -34,7 +34,7 @@ gem 'jbuilder', '~> 2.5'
|
||||
# Use Redis adapter to run Action Cable in production
|
||||
# gem 'redis', '~> 3.0'
|
||||
# Use ActiveModel has_secure_password
|
||||
# gem 'bcrypt', '~> 3.1.7'
|
||||
gem 'bcrypt', '~> 3.1.7'
|
||||
|
||||
# Use Capistrano for deployment
|
||||
# gem 'capistrano-rails', group: :development
|
||||
|
||||
@@ -41,6 +41,7 @@ GEM
|
||||
arel (7.1.4)
|
||||
autoprefixer-rails (6.7.7)
|
||||
execjs
|
||||
bcrypt (3.1.11)
|
||||
bootstrap (4.0.0.alpha6)
|
||||
autoprefixer-rails (>= 6.0.3)
|
||||
sass (>= 3.4.19)
|
||||
@@ -194,6 +195,7 @@ PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
bcrypt (~> 3.1.7)
|
||||
bootstrap (~> 4.0.0.alpha3)
|
||||
byebug
|
||||
coffee-rails (~> 4.2)
|
||||
|
||||
3
app/assets/javascripts/employees.coffee
Normal file
3
app/assets/javascripts/employees.coffee
Normal file
@@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
||||
3
app/assets/javascripts/install.coffee
Normal file
3
app/assets/javascripts/install.coffee
Normal file
@@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
||||
@@ -1,8 +1,9 @@
|
||||
@import "bootstrap";
|
||||
@import "font-awesome";
|
||||
@import "scaffolds";
|
||||
|
||||
/* Show it is fixed to the top */
|
||||
body {
|
||||
min-height: 75rem;
|
||||
padding-top: 4.5rem;
|
||||
}
|
||||
// body {
|
||||
// min-height: 75rem;
|
||||
// padding-top: 4.5rem;
|
||||
// }
|
||||
|
||||
3
app/assets/stylesheets/employees.scss
Normal file
3
app/assets/stylesheets/employees.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the Employees controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
3
app/assets/stylesheets/install.scss
Normal file
3
app/assets/stylesheets/install.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the install controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
6039
app/assets/stylesheets/scaffolds.scss
Normal file
6039
app/assets/stylesheets/scaffolds.scss
Normal file
File diff suppressed because it is too large
Load Diff
14
app/controllers/api/api_controller.rb
Normal file
14
app/controllers/api/api_controller.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
class Api::ApiController < ActionController::API
|
||||
include TokenVerification
|
||||
helper_method :current_token
|
||||
|
||||
#this is base api base controller to need to inherit.
|
||||
#all token authentication must be done here
|
||||
#response format must be set to JSON
|
||||
def current_token
|
||||
authenticate_with_http_token do |token, options|
|
||||
return token
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
12
app/controllers/api/customers_controller.rb
Normal file
12
app/controllers/api/customers_controller.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
class Api::CustomersController < ActionController::API
|
||||
|
||||
#List all active customers by name
|
||||
def index
|
||||
@customers = Customer.order("name asc")
|
||||
end
|
||||
|
||||
#Show customer by ID
|
||||
def show
|
||||
@customer = Customer.find_by(params[:id])
|
||||
end
|
||||
end
|
||||
63
app/controllers/api/restaurant/orders_controller.rb
Normal file
63
app/controllers/api/restaurant/orders_controller.rb
Normal file
@@ -0,0 +1,63 @@
|
||||
class Api::Restaurant::OrdersController < ActionController::API
|
||||
#before :authenticate_token
|
||||
|
||||
#Description
|
||||
# This API show current order details
|
||||
# Input Params - order_id
|
||||
def show
|
||||
order = Order.find(params[:order_id])
|
||||
order.order_items
|
||||
end
|
||||
|
||||
|
||||
# Description
|
||||
# This API allow new order creation
|
||||
# Input Params
|
||||
# order_source [* default - emenu] | table_id | booking_id [table_booking_id & Room_booking_id] (*require for Dine-In) | order_type [* Default - Dine-in]
|
||||
# | guest_info (optional) | customer_id (* Default assigned to WALK-IN)
|
||||
# order_items {[item_code, item_instance_code , qty, option, variants]}
|
||||
# Output Params
|
||||
# Status [Success | Error | System Error] , order_id, error_message (*)
|
||||
def create
|
||||
# begin
|
||||
@order = Order.new
|
||||
@order.source = params[:order_source]
|
||||
@order.order_type = params[:order_type]
|
||||
@order.customer_id = params[:customer_id]
|
||||
json_hash = params[:order_items]
|
||||
@order.items = json_hash
|
||||
@order.guest = params[:guest_info]
|
||||
@order.table_id = params[:table_id]
|
||||
@order.new_booking = true
|
||||
@order.employee_name = "Test User"
|
||||
|
||||
|
||||
#Create Table Booking or Room Booking
|
||||
if !params["booking_id"].nil?
|
||||
@order.new_booking = false
|
||||
@order.booking_id = params[:booking_id]
|
||||
end
|
||||
|
||||
@status = @order.generate
|
||||
# rescue Exception => error
|
||||
# @status = false
|
||||
# @error_messages = "Exception has occurs on System"
|
||||
#
|
||||
# logger.fatal("Exception Raise - " + error.message)
|
||||
# end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
# Description
|
||||
# This API - allow order to add new items to existing orders, does not allow you to remove confirm items
|
||||
# Update customer info, Guest Info
|
||||
# Input Params
|
||||
# order_id , order_items {[item_code, item_instance_code , qty, option, variants]}
|
||||
def update
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
@@ -8,7 +8,7 @@ class Api::Restaurant::SeatingsController < ActionController::API
|
||||
# Output
|
||||
# status: {available, cleaning, occupied, reserved}, order_id : <current_order_id>
|
||||
def show
|
||||
|
||||
|
||||
end
|
||||
|
||||
#Input Params
|
||||
|
||||
@@ -1,3 +1,25 @@
|
||||
class ApplicationController < ActionController::Base
|
||||
#before_action :check_installation
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
helper_method :current_company
|
||||
|
||||
#this is base api base controller to need to inherit.
|
||||
#all token authentication must be done here
|
||||
#response format must be set to JSON
|
||||
def current_company
|
||||
begin
|
||||
return Company.first
|
||||
rescue
|
||||
return nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
def check_installation
|
||||
if current_company.nil?
|
||||
redirect_to install_path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
4
app/controllers/base_controller.rb
Normal file
4
app/controllers/base_controller.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
class BaseController < ActionController::Base
|
||||
layout "installation"
|
||||
protect_from_forgery with: :exception
|
||||
end
|
||||
36
app/controllers/concerns/token_verification.rb
Normal file
36
app/controllers/concerns/token_verification.rb
Normal file
@@ -0,0 +1,36 @@
|
||||
module TokenVerification
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
before_action :authenticate
|
||||
end
|
||||
|
||||
|
||||
protected
|
||||
# Authenticate the user with token based authentication
|
||||
def authenticate
|
||||
authenticate_token || render_unauthorized
|
||||
end
|
||||
|
||||
def authenticate_token
|
||||
authenticate_with_http_token do |token, options|
|
||||
#@current_user = User.find_by(api_key: token)
|
||||
@device_access = DeviceAccess.find_by_token(token)
|
||||
if @device_access
|
||||
@log = DeviceAccessLog.new
|
||||
@log.device_access = @device_access
|
||||
@log.api_route = request.env['PATH_INFO']
|
||||
@log.remote_ip = request.remote_ip
|
||||
# @log.client_info =
|
||||
@log.save
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
def render_unauthorized(realm = "Application")
|
||||
self.headers["WWW-Authenticate"] = %(Token realm="#{realm.gsub(/"/, "")}")
|
||||
render json: 'Bad credentials', status: :unauthorized
|
||||
end
|
||||
|
||||
end
|
||||
8
app/controllers/install_controller.rb
Normal file
8
app/controllers/install_controller.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
class InstallController < BaseController
|
||||
|
||||
def index
|
||||
end
|
||||
|
||||
def create
|
||||
end
|
||||
end
|
||||
74
app/controllers/settings/employees_controller.rb
Normal file
74
app/controllers/settings/employees_controller.rb
Normal file
@@ -0,0 +1,74 @@
|
||||
class Settings::EmployeesController < ApplicationController
|
||||
before_action :set_employee, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
# GET /employees
|
||||
# GET /employees.json
|
||||
def index
|
||||
@employees = Employee.all
|
||||
end
|
||||
|
||||
# GET /employees/1
|
||||
# GET /employees/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /employees/new
|
||||
def new
|
||||
@employee = Employee.new
|
||||
end
|
||||
|
||||
# GET /employees/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /employees
|
||||
# POST /employees.json
|
||||
def create
|
||||
@employee = Employee.new(employee_params)
|
||||
|
||||
respond_to do |format|
|
||||
if @employee.save
|
||||
format.html { redirect_to @employee, notice: 'Employee was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @employee }
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: @employee.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /employees/1
|
||||
# PATCH/PUT /employees/1.json
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @employee.update(employee_params)
|
||||
format.html { redirect_to @employee, notice: 'Employee was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @employee }
|
||||
else
|
||||
format.html { render :edit }
|
||||
format.json { render json: @employee.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /employees/1
|
||||
# DELETE /employees/1.json
|
||||
def destroy
|
||||
@employee.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to employees_url, notice: 'Employee was successfully destroyed.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_employee
|
||||
@employee = Employee.find(params[:id])
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def employee_params
|
||||
params.require(:employee).permit(:name, :role, :password)
|
||||
end
|
||||
end
|
||||
2
app/helpers/employees_helper.rb
Normal file
2
app/helpers/employees_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module EmployeesHelper
|
||||
end
|
||||
2
app/helpers/install_helper.rb
Normal file
2
app/helpers/install_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module InstallHelper
|
||||
end
|
||||
14
app/jobs/order_queue_processor_job.rb
Normal file
14
app/jobs/order_queue_processor_job.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
class OrderQueueProcessorJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(:order_id)
|
||||
# Do something later
|
||||
#Order ID
|
||||
order = Order.find(order_id)
|
||||
|
||||
#Execute orders and send to order stations
|
||||
if order
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
7
app/models/booking.rb
Normal file
7
app/models/booking.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
class Booking < ApplicationRecord
|
||||
|
||||
belongs_to :dining_facility
|
||||
belongs_to :sale, :optional => true
|
||||
|
||||
|
||||
end
|
||||
@@ -1,2 +1,17 @@
|
||||
class Employee < ApplicationRecord
|
||||
include BCrypt
|
||||
|
||||
#attr_accessor :password
|
||||
|
||||
validates_presence_of :name, :role, :password
|
||||
|
||||
|
||||
def password
|
||||
@password ||= Password.new(password_hash)
|
||||
end
|
||||
|
||||
def password=(new_password)
|
||||
@password = Password.create(new_password)
|
||||
self.encrypted_access_code = @password
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Lookup < ApplicationRecord
|
||||
|
||||
|
||||
def available_types
|
||||
{'Employee Roles' => 'employee_roles',
|
||||
'Dining Facilities Status' => 'dining_facilities_status',
|
||||
@@ -12,4 +12,9 @@ class Lookup < ApplicationRecord
|
||||
'Payment Status' => 'payment_status',
|
||||
'Payment Methods' => 'payment_methods'}
|
||||
end
|
||||
|
||||
def self.collection_of(type)
|
||||
Lookup.select("name, value").where("lookup_type" => type ).map { |l| [l.name, l.value] }
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,11 +3,10 @@ class Order < ApplicationRecord
|
||||
before_save :update_products_and_quantity_count
|
||||
|
||||
belongs_to :customer
|
||||
has_many :order_items, inverse_of: :order
|
||||
has_many :dining_ins
|
||||
has_many :order_items, autosave: true , inverse_of: :order
|
||||
|
||||
#internal references attributes for business logic control
|
||||
attr_accessor :items, :guest, :table_id, :new_booking, :booking_type
|
||||
attr_accessor :items, :guest, :table_id, :new_booking, :booking_type, :employee_name
|
||||
|
||||
|
||||
#Main Controller method to create new order - validate all inputs and generate new order
|
||||
@@ -19,26 +18,40 @@ class Order < ApplicationRecord
|
||||
# sub_order_items : [],
|
||||
# }
|
||||
def generate
|
||||
booking = nil
|
||||
|
||||
if self.new_booking
|
||||
booking = Booking.create({:dining_facility_id => :table_id, })
|
||||
|
||||
self.adding_line_items
|
||||
self.save!
|
||||
booking = Booking.create({:dining_facility_id => self.table_id,:type => "TableBooking",
|
||||
:checkin_at => Time.now.utc, :checkin_by => self.employee_name,
|
||||
:booking_status => "new" })
|
||||
else
|
||||
|
||||
|
||||
booking = Booking.find(self.booking_id)
|
||||
#Add Order Table and Room relation afrer order creation
|
||||
if booking.type = "Table"
|
||||
#add to table_booking_order
|
||||
tbo = TableBookingOrder.create({:table_booking => booking, :order => self})
|
||||
elsif booking.type = "Room"
|
||||
#add to room_booking_order
|
||||
rbo = RoomBookingOrder.create({:table_booking => booking, :order => self})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
booking.save!
|
||||
|
||||
self.default_values
|
||||
|
||||
if self.save!
|
||||
|
||||
self.adding_line_items
|
||||
|
||||
#Add Order Table and Room relation afrer order creation
|
||||
if booking.type = "TableBooking"
|
||||
#add to table_booking_order
|
||||
tbo = TableBookingOrder.create({:table_booking_id => booking.id, :order => self})
|
||||
elsif booking.type = "RoomBooking"
|
||||
#add to room_booking_order
|
||||
rbo = RoomBookingOrder.create({:room_booking_id => booking.id, :order => self})
|
||||
end
|
||||
|
||||
return true
|
||||
|
||||
end
|
||||
|
||||
return false
|
||||
|
||||
end
|
||||
|
||||
#Main Method - to update order / add items
|
||||
@@ -46,24 +59,33 @@ class Order < ApplicationRecord
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
def validate_api_inputs
|
||||
|
||||
end
|
||||
|
||||
def adding_line_items
|
||||
|
||||
|
||||
if self.items
|
||||
#loop to add all items to order
|
||||
self.items.each do |item|
|
||||
self.order_items.add( OrderItem.processs_item(item) )
|
||||
self.order_items.add( OrderItem.processs_item(item, self.id, self.employee_name) )
|
||||
end
|
||||
return true
|
||||
else
|
||||
self.errors.add(:order_items, :blank, message: "Order items cannot be blank")
|
||||
return false
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def default_values
|
||||
self.customer = Customer.find(1) if self.customer_id.nil?
|
||||
self.source = "emenu" if self.source.nil?
|
||||
self.order_type = "dine-in" if self.order_type.nil?
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
def validate_api_inputs
|
||||
|
||||
end
|
||||
|
||||
def set_order_date
|
||||
self.date = Time.now.utc
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class OrderItem < ApplicationRecord
|
||||
#Associations
|
||||
belongs_to :order
|
||||
belongs_to :order, autosave: true
|
||||
|
||||
#Validation
|
||||
validates_presence_of :item_code, :item_name, :qty
|
||||
@@ -15,17 +15,19 @@ class OrderItem < ApplicationRecord
|
||||
# option_values : [],
|
||||
# sub_order_items : [],
|
||||
# }
|
||||
def processs_item (item, item_order_by)
|
||||
OrderItem.new do |oitem|
|
||||
oitem.item_code = item.item_code
|
||||
oitem.item_name = item.name
|
||||
oitem.qty = item.qty
|
||||
oitem.option = item.option
|
||||
oitem.variants = item.variants
|
||||
oitem.set_order_items = item.sub_order_items
|
||||
def self.processs_item (item, orde_id, item_order_by)
|
||||
orderitem = OrderItem.create do |oitem|
|
||||
oitem.item_code = item["item_code"]
|
||||
oitem.order_id = order_id
|
||||
oitem.item_name = item["name"]
|
||||
oitem.qty = item["qty"]
|
||||
oitem.option = item["option"]
|
||||
oitem.set_order_items = item["sub_order_items"]
|
||||
oitem.item_order_by = item_order_by
|
||||
|
||||
end
|
||||
logger.info orderitem.to_yml
|
||||
orderitem.save!
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
4
app/models/room_booking_order.rb
Normal file
4
app/models/room_booking_order.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
class RoomBookingOrder < ApplicationRecord
|
||||
belongs_to :room_booking
|
||||
belongs_to :order
|
||||
end
|
||||
3
app/models/table_booking.rb
Normal file
3
app/models/table_booking.rb
Normal file
@@ -0,0 +1,3 @@
|
||||
class TableBooking < Booking
|
||||
|
||||
end
|
||||
4
app/models/table_booking_order.rb
Normal file
4
app/models/table_booking_order.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
class TableBookingOrder < ApplicationRecord
|
||||
belongs_to :table_booking
|
||||
belongs_to :order
|
||||
end
|
||||
1
app/views/api/customers/index.json.jbuilder
Normal file
1
app/views/api/customers/index.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.array! @customers, :id, :name, :company, :contact_no, :email, :membership_id, :membership_type
|
||||
4
app/views/api/customers/show.json.jbuilder
Normal file
4
app/views/api/customers/show.json.jbuilder
Normal file
@@ -0,0 +1,4 @@
|
||||
json.extract! @customer, :id, :name, :company, :contact_no, :membership_type, :membership_id, :created_at
|
||||
json.invoices do
|
||||
json.array! @customer.lastest_invoices ,:id, :receipt_no, :receipt_date, :sale_status, :payment_status
|
||||
end
|
||||
14
app/views/api/restaurant/orders/create.json.jbuilder
Normal file
14
app/views/api/restaurant/orders/create.json.jbuilder
Normal file
@@ -0,0 +1,14 @@
|
||||
if @status == true
|
||||
json.status :success
|
||||
json.id @order.id
|
||||
json.order_items do
|
||||
json.array! @order.order_items, :item_code, :item_name, :qty, :options, :variants, :remarks
|
||||
end
|
||||
else
|
||||
json.status :error
|
||||
if @error_messages
|
||||
json.error_messages @error_messages
|
||||
else
|
||||
json.error_messages @order.errors
|
||||
end
|
||||
end
|
||||
0
app/views/api/restaurant/orders/show.json.jbuilder
Normal file
0
app/views/api/restaurant/orders/show.json.jbuilder
Normal file
7
app/views/api/restaurant/orders/update.json.jbuilder
Normal file
7
app/views/api/restaurant/orders/update.json.jbuilder
Normal file
@@ -0,0 +1,7 @@
|
||||
if @status == true
|
||||
json.status :success
|
||||
json.id @order.id
|
||||
else
|
||||
json.status :error
|
||||
json.error_messages @order.error_messages
|
||||
end
|
||||
17
app/views/install/_form.html.erb
Normal file
17
app/views/install/_form.html.erb
Normal file
@@ -0,0 +1,17 @@
|
||||
<form>
|
||||
<div class="form-group">
|
||||
<label for="exampleInputEmail1">Business Name</label>
|
||||
<input type="text" class="form-control" id="restaurant_name" aria-describedby="business_name" placeholder="Enter business name">
|
||||
<small id="business_name" class="form-text text-muted">Name of business this system is license to</small>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="lblAdministrator">Administrator Username</label>
|
||||
<input type="text" class="form-control" id="admin_user" aria-describedby="admin_user" placeholder="Administrator Username">
|
||||
<small id="admin_user" class="form-text text-muted">First Employee who will be assign as administrator</small>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="admin_password">Password</label>
|
||||
<input type="password" class="form-control" id="admin_password" placeholder="Password">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Install</button>
|
||||
</form>
|
||||
2
app/views/install/create.html.erb
Normal file
2
app/views/install/create.html.erb
Normal file
@@ -0,0 +1,2 @@
|
||||
<h1>Install#create</h1>
|
||||
<p>Find me in app/views/install/create.html.erb</p>
|
||||
17
app/views/install/index.html.erb
Normal file
17
app/views/install/index.html.erb
Normal file
@@ -0,0 +1,17 @@
|
||||
<div class="row">
|
||||
<div class="col-lg-3 col-md-3"></div>
|
||||
<div class="col-lg-6 col-md-6 ">
|
||||
<div class="card">
|
||||
|
||||
<div class="card-block">
|
||||
<h4 class="card-title text-center">New Restaurant Installation</h4>
|
||||
<br/>
|
||||
<h6 class="card-subtitle mb-2 text-muted">Welcome to new installation of SmartSales Restaurant Edition</h6>
|
||||
<p class="card-text">Please provide us with following details to setup necessary user account and base system settings.</p>
|
||||
<%= render "install/form" %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-3 col-md-3"></div>
|
||||
|
||||
</div>
|
||||
@@ -1,4 +1,4 @@
|
||||
<nav class="navbar navbar-toggleable-md navbar-inverse fixed-top bg-inverse">
|
||||
<nav class="navbar navbar-toggleable-md fixed-top navbar-light">
|
||||
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
|
||||
22
app/views/layouts/installation.html.erb
Normal file
22
app/views/layouts/installation.html.erb
Normal file
@@ -0,0 +1,22 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
|
||||
<meta name="description" content=""/>
|
||||
<meta name="author" content=""/>
|
||||
|
||||
<title>Film Buff</title>
|
||||
<%= csrf_meta_tags %>
|
||||
|
||||
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
|
||||
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<%= yield %>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
2
app/views/settings/employees/_employee.json.jbuilder
Normal file
2
app/views/settings/employees/_employee.json.jbuilder
Normal file
@@ -0,0 +1,2 @@
|
||||
json.extract! employee, :id, :name, :role, :encrypted_access_code, :created_at, :updated_at
|
||||
json.url employee_url(employee, format: :json)
|
||||
14
app/views/settings/employees/_form.html.erb
Normal file
14
app/views/settings/employees/_form.html.erb
Normal file
@@ -0,0 +1,14 @@
|
||||
<%= simple_form_for([:settings,@employee]) do |f| %>
|
||||
<%= f.error_notification %>
|
||||
|
||||
<div class="form-inputs">
|
||||
<%= f.input :name %>
|
||||
<%= f.input :role, :collection => Lookup.collection_of("employee_roles") %>
|
||||
<%= f.input :password %>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
<%= f.button :submit %>
|
||||
</div>
|
||||
<% end %>
|
||||
6
app/views/settings/employees/edit.html.erb
Normal file
6
app/views/settings/employees/edit.html.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
<h1>Editing Employee</h1>
|
||||
|
||||
<%= render 'form', employee: @employee %>
|
||||
|
||||
<%= link_to 'Show', @employee %> |
|
||||
<%= link_to 'Back', employees_path %>
|
||||
34
app/views/settings/employees/index.html.erb
Normal file
34
app/views/settings/employees/index.html.erb
Normal file
@@ -0,0 +1,34 @@
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= %>">Home</a></li>
|
||||
<li>Employee</li>
|
||||
<span style="float: right">
|
||||
<%= link_to t('.new', :default => t("helpers.links.new")),new_settings_employee_path,:class => 'btn btn-primary btn-sm' %>
|
||||
</span>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
<div class="card">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Role</th>
|
||||
<th colspan="3"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% @employees.each do |employee| %>
|
||||
<tr>
|
||||
<td><%= employee.name %></td>
|
||||
<td><%= employee.role %></td>
|
||||
<td><%= link_to 'Show', employee[:setting] %></td>
|
||||
<td><%= link_to 'Edit', edit_settings_employee_path(employee) %></td>
|
||||
<td><%= link_to 'Destroy', employee[:setting], method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
1
app/views/settings/employees/index.json.jbuilder
Normal file
1
app/views/settings/employees/index.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.array! @employees, partial: 'employees/employee', as: :employee
|
||||
11
app/views/settings/employees/new.html.erb
Normal file
11
app/views/settings/employees/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_employees_path %>">Employees</a></li>
|
||||
<li>New</li>
|
||||
</ul>
|
||||
</div>
|
||||
<%= render 'form', employee: @employee %>
|
||||
</div>
|
||||
11
app/views/settings/employees/show.html.erb
Normal file
11
app/views/settings/employees/show.html.erb
Normal file
@@ -0,0 +1,11 @@
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
<p>
|
||||
<strong>Name:</strong>
|
||||
<%= @employee.name %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Role:</strong>
|
||||
<%= @employee.role %>
|
||||
</p>
|
||||
1
app/views/settings/employees/show.json.jbuilder
Normal file
1
app/views/settings/employees/show.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.partial! "employees/employee", employee: @employee
|
||||
@@ -1,11 +1,17 @@
|
||||
Rails.application.routes.draw do
|
||||
root 'home#index'
|
||||
#Login for Web
|
||||
|
||||
#--------- SmartSales Installation ------------#
|
||||
get 'install' => 'install#index'
|
||||
post 'install' => 'install#create'
|
||||
|
||||
#--------- Login/Authentication ------------#
|
||||
post 'authenticate' => 'home#create'
|
||||
delete 'authenticate' => 'home/destroy'
|
||||
|
||||
namespace :api, :defaults => { :format => 'json' } do
|
||||
|
||||
#--------- API Routes ------------#
|
||||
namespace :api, :defaults => { :format => 'json' } do
|
||||
#Session Login and Logout
|
||||
post 'authenticate' => "autheticate#create"
|
||||
delete 'authenticate' => "autheticate#destroy"
|
||||
@@ -13,16 +19,64 @@ Rails.application.routes.draw do
|
||||
namespace :restaurant do
|
||||
get 'zones' => "zones#index"
|
||||
get 'tables' => "#index"
|
||||
|
||||
#Order Controller
|
||||
resources :orders, only: [:create, :show, :update]
|
||||
|
||||
|
||||
end
|
||||
|
||||
resources :customers, only: [:index, :show, :create]
|
||||
end
|
||||
|
||||
#--------- Cashier ------------#
|
||||
namespace :cashier do
|
||||
#orders
|
||||
#invoices
|
||||
#payment
|
||||
#receipt
|
||||
end
|
||||
|
||||
#--------- Waiter ------------#
|
||||
namespace :waiter do
|
||||
#zones
|
||||
#tables
|
||||
#orders
|
||||
end
|
||||
|
||||
#--------- Customer Relationship Management ------------#
|
||||
namespace :crm do
|
||||
#customers
|
||||
#membership
|
||||
#bookings
|
||||
#queue
|
||||
end
|
||||
|
||||
#--------- Order Queue Station ------------#
|
||||
namespace :oqs do
|
||||
#dashboard
|
||||
#
|
||||
end
|
||||
|
||||
#--------- System Settings ------------#
|
||||
namespace :settings do
|
||||
#employees
|
||||
resources :employees
|
||||
#menu
|
||||
#menu_categories
|
||||
#menu_items
|
||||
#payment_settings
|
||||
#tax_profiles
|
||||
#lookups
|
||||
#cashier_terminals
|
||||
#order_job_stations
|
||||
#zones
|
||||
#tables
|
||||
#rooms
|
||||
end
|
||||
|
||||
#--------- Reports ------------#
|
||||
namespace :reports do
|
||||
#dashboard
|
||||
#sales
|
||||
#orders
|
||||
#shifts
|
||||
end
|
||||
|
||||
|
||||
|
||||
18
db/migrate/20170404034234_create_bookings.rb
Normal file
18
db/migrate/20170404034234_create_bookings.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
class CreateBookings < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :bookings do |t|
|
||||
t.references :dining_facility, foreign_key: true
|
||||
t.string :type, :null => false, :default => "Table"
|
||||
t.datetime :checkin_at, :null => false
|
||||
t.string :checkin_by
|
||||
t.datetime :checkout_at
|
||||
t.string :checkout_by
|
||||
t.datetime :reserved_at
|
||||
t.string :reserved_by
|
||||
t.string :booking_status, :null => false, :default => "new"
|
||||
t.references :sale, foreign_key: true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
10
db/migrate/20170404041147_create_table_booking_orders.rb
Normal file
10
db/migrate/20170404041147_create_table_booking_orders.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class CreateTableBookingOrders < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :table_booking_orders do |t|
|
||||
t.references :table_booking
|
||||
t.references :order, foreign_key: true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
10
db/migrate/20170404041218_create_room_booking_orders.rb
Normal file
10
db/migrate/20170404041218_create_room_booking_orders.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class CreateRoomBookingOrders < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :room_booking_orders do |t|
|
||||
t.references :room_booking
|
||||
t.references :order, foreign_key: true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
159
spec/controllers/employees_controller_spec.rb
Normal file
159
spec/controllers/employees_controller_spec.rb
Normal file
@@ -0,0 +1,159 @@
|
||||
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.
|
||||
|
||||
RSpec.describe EmployeesController, type: :controller do
|
||||
|
||||
# This should return the minimal set of attributes required to create a valid
|
||||
# Employee. As you add validations to Employee, 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
|
||||
# EmployeesController. Be sure to keep this updated too.
|
||||
let(:valid_session) { {} }
|
||||
|
||||
describe "GET #index" do
|
||||
it "assigns all employees as @employees" do
|
||||
employee = Employee.create! valid_attributes
|
||||
get :index, params: {}, session: valid_session
|
||||
expect(assigns(:employees)).to eq([employee])
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #show" do
|
||||
it "assigns the requested employee as @employee" do
|
||||
employee = Employee.create! valid_attributes
|
||||
get :show, params: {id: employee.to_param}, session: valid_session
|
||||
expect(assigns(:employee)).to eq(employee)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #new" do
|
||||
it "assigns a new employee as @employee" do
|
||||
get :new, params: {}, session: valid_session
|
||||
expect(assigns(:employee)).to be_a_new(Employee)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #edit" do
|
||||
it "assigns the requested employee as @employee" do
|
||||
employee = Employee.create! valid_attributes
|
||||
get :edit, params: {id: employee.to_param}, session: valid_session
|
||||
expect(assigns(:employee)).to eq(employee)
|
||||
end
|
||||
end
|
||||
|
||||
describe "POST #create" do
|
||||
context "with valid params" do
|
||||
it "creates a new Employee" do
|
||||
expect {
|
||||
post :create, params: {employee: valid_attributes}, session: valid_session
|
||||
}.to change(Employee, :count).by(1)
|
||||
end
|
||||
|
||||
it "assigns a newly created employee as @employee" do
|
||||
post :create, params: {employee: valid_attributes}, session: valid_session
|
||||
expect(assigns(:employee)).to be_a(Employee)
|
||||
expect(assigns(:employee)).to be_persisted
|
||||
end
|
||||
|
||||
it "redirects to the created employee" do
|
||||
post :create, params: {employee: valid_attributes}, session: valid_session
|
||||
expect(response).to redirect_to(Employee.last)
|
||||
end
|
||||
end
|
||||
|
||||
context "with invalid params" do
|
||||
it "assigns a newly created but unsaved employee as @employee" do
|
||||
post :create, params: {employee: invalid_attributes}, session: valid_session
|
||||
expect(assigns(:employee)).to be_a_new(Employee)
|
||||
end
|
||||
|
||||
it "re-renders the 'new' template" do
|
||||
post :create, params: {employee: invalid_attributes}, session: valid_session
|
||||
expect(response).to render_template("new")
|
||||
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 employee" do
|
||||
employee = Employee.create! valid_attributes
|
||||
put :update, params: {id: employee.to_param, employee: new_attributes}, session: valid_session
|
||||
employee.reload
|
||||
skip("Add assertions for updated state")
|
||||
end
|
||||
|
||||
it "assigns the requested employee as @employee" do
|
||||
employee = Employee.create! valid_attributes
|
||||
put :update, params: {id: employee.to_param, employee: valid_attributes}, session: valid_session
|
||||
expect(assigns(:employee)).to eq(employee)
|
||||
end
|
||||
|
||||
it "redirects to the employee" do
|
||||
employee = Employee.create! valid_attributes
|
||||
put :update, params: {id: employee.to_param, employee: valid_attributes}, session: valid_session
|
||||
expect(response).to redirect_to(employee)
|
||||
end
|
||||
end
|
||||
|
||||
context "with invalid params" do
|
||||
it "assigns the employee as @employee" do
|
||||
employee = Employee.create! valid_attributes
|
||||
put :update, params: {id: employee.to_param, employee: invalid_attributes}, session: valid_session
|
||||
expect(assigns(:employee)).to eq(employee)
|
||||
end
|
||||
|
||||
it "re-renders the 'edit' template" do
|
||||
employee = Employee.create! valid_attributes
|
||||
put :update, params: {id: employee.to_param, employee: invalid_attributes}, session: valid_session
|
||||
expect(response).to render_template("edit")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "DELETE #destroy" do
|
||||
it "destroys the requested employee" do
|
||||
employee = Employee.create! valid_attributes
|
||||
expect {
|
||||
delete :destroy, params: {id: employee.to_param}, session: valid_session
|
||||
}.to change(Employee, :count).by(-1)
|
||||
end
|
||||
|
||||
it "redirects to the employees list" do
|
||||
employee = Employee.create! valid_attributes
|
||||
delete :destroy, params: {id: employee.to_param}, session: valid_session
|
||||
expect(response).to redirect_to(employees_url)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
19
spec/controllers/install_controller_spec.rb
Normal file
19
spec/controllers/install_controller_spec.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe InstallController, type: :controller do
|
||||
|
||||
describe "GET #index" do
|
||||
it "returns http success" do
|
||||
get :index
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #create" do
|
||||
it "returns http success" do
|
||||
get :create
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
15
spec/helpers/employees_helper_spec.rb
Normal file
15
spec/helpers/employees_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 EmployeesHelper. For example:
|
||||
#
|
||||
# describe EmployeesHelper 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 EmployeesHelper, type: :helper do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
15
spec/helpers/install_helper_spec.rb
Normal file
15
spec/helpers/install_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 InstallHelper. For example:
|
||||
#
|
||||
# describe InstallHelper 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 InstallHelper, type: :helper do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
5
spec/jobs/order_queue_processor_job_spec.rb
Normal file
5
spec/jobs/order_queue_processor_job_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe OrderQueueProcessorJob, type: :job do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
5
spec/models/booking_spec.rb
Normal file
5
spec/models/booking_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Booking, type: :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
5
spec/models/room_booking_order_spec.rb
Normal file
5
spec/models/room_booking_order_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe RoomBookingOrder, type: :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
5
spec/models/table_booking_order_spec.rb
Normal file
5
spec/models/table_booking_order_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe TableBookingOrder, type: :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
10
spec/requests/employees_spec.rb
Normal file
10
spec/requests/employees_spec.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "Employees", type: :request do
|
||||
describe "GET /employees" do
|
||||
it "works! (now write some real specs)" do
|
||||
get employees_path
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
end
|
||||
39
spec/routing/employees_routing_spec.rb
Normal file
39
spec/routing/employees_routing_spec.rb
Normal file
@@ -0,0 +1,39 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe EmployeesController, type: :routing do
|
||||
describe "routing" do
|
||||
|
||||
it "routes to #index" do
|
||||
expect(:get => "/employees").to route_to("employees#index")
|
||||
end
|
||||
|
||||
it "routes to #new" do
|
||||
expect(:get => "/employees/new").to route_to("employees#new")
|
||||
end
|
||||
|
||||
it "routes to #show" do
|
||||
expect(:get => "/employees/1").to route_to("employees#show", :id => "1")
|
||||
end
|
||||
|
||||
it "routes to #edit" do
|
||||
expect(:get => "/employees/1/edit").to route_to("employees#edit", :id => "1")
|
||||
end
|
||||
|
||||
it "routes to #create" do
|
||||
expect(:post => "/employees").to route_to("employees#create")
|
||||
end
|
||||
|
||||
it "routes to #update via PUT" do
|
||||
expect(:put => "/employees/1").to route_to("employees#update", :id => "1")
|
||||
end
|
||||
|
||||
it "routes to #update via PATCH" do
|
||||
expect(:patch => "/employees/1").to route_to("employees#update", :id => "1")
|
||||
end
|
||||
|
||||
it "routes to #destroy" do
|
||||
expect(:delete => "/employees/1").to route_to("employees#destroy", :id => "1")
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
24
spec/views/employees/edit.html.erb_spec.rb
Normal file
24
spec/views/employees/edit.html.erb_spec.rb
Normal file
@@ -0,0 +1,24 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "employees/edit", type: :view do
|
||||
before(:each) do
|
||||
@employee = assign(:employee, Employee.create!(
|
||||
:name => "MyString",
|
||||
:role => "MyString",
|
||||
:encrypted_access_code => "MyString"
|
||||
))
|
||||
end
|
||||
|
||||
it "renders the edit employee form" do
|
||||
render
|
||||
|
||||
assert_select "form[action=?][method=?]", employee_path(@employee), "post" do
|
||||
|
||||
assert_select "input#employee_name[name=?]", "employee[name]"
|
||||
|
||||
assert_select "input#employee_role[name=?]", "employee[role]"
|
||||
|
||||
assert_select "input#employee_encrypted_access_code[name=?]", "employee[encrypted_access_code]"
|
||||
end
|
||||
end
|
||||
end
|
||||
25
spec/views/employees/index.html.erb_spec.rb
Normal file
25
spec/views/employees/index.html.erb_spec.rb
Normal file
@@ -0,0 +1,25 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "employees/index", type: :view do
|
||||
before(:each) do
|
||||
assign(:employees, [
|
||||
Employee.create!(
|
||||
:name => "Name",
|
||||
:role => "Role",
|
||||
:encrypted_access_code => "Encrypted Access Code"
|
||||
),
|
||||
Employee.create!(
|
||||
:name => "Name",
|
||||
:role => "Role",
|
||||
:encrypted_access_code => "Encrypted Access Code"
|
||||
)
|
||||
])
|
||||
end
|
||||
|
||||
it "renders a list of employees" do
|
||||
render
|
||||
assert_select "tr>td", :text => "Name".to_s, :count => 2
|
||||
assert_select "tr>td", :text => "Role".to_s, :count => 2
|
||||
assert_select "tr>td", :text => "Encrypted Access Code".to_s, :count => 2
|
||||
end
|
||||
end
|
||||
24
spec/views/employees/new.html.erb_spec.rb
Normal file
24
spec/views/employees/new.html.erb_spec.rb
Normal file
@@ -0,0 +1,24 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "employees/new", type: :view do
|
||||
before(:each) do
|
||||
assign(:employee, Employee.new(
|
||||
:name => "MyString",
|
||||
:role => "MyString",
|
||||
:encrypted_access_code => "MyString"
|
||||
))
|
||||
end
|
||||
|
||||
it "renders new employee form" do
|
||||
render
|
||||
|
||||
assert_select "form[action=?][method=?]", employees_path, "post" do
|
||||
|
||||
assert_select "input#employee_name[name=?]", "employee[name]"
|
||||
|
||||
assert_select "input#employee_role[name=?]", "employee[role]"
|
||||
|
||||
assert_select "input#employee_encrypted_access_code[name=?]", "employee[encrypted_access_code]"
|
||||
end
|
||||
end
|
||||
end
|
||||
18
spec/views/employees/show.html.erb_spec.rb
Normal file
18
spec/views/employees/show.html.erb_spec.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "employees/show", type: :view do
|
||||
before(:each) do
|
||||
@employee = assign(:employee, Employee.create!(
|
||||
:name => "Name",
|
||||
:role => "Role",
|
||||
:encrypted_access_code => "Encrypted Access Code"
|
||||
))
|
||||
end
|
||||
|
||||
it "renders attributes in <p>" do
|
||||
render
|
||||
expect(rendered).to match(/Name/)
|
||||
expect(rendered).to match(/Role/)
|
||||
expect(rendered).to match(/Encrypted Access Code/)
|
||||
end
|
||||
end
|
||||
5
spec/views/install/create.html.erb_spec.rb
Normal file
5
spec/views/install/create.html.erb_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "install/create.html.erb", type: :view do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
5
spec/views/install/index.html.erb_spec.rb
Normal file
5
spec/views/install/index.html.erb_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "install/index.html.erb", type: :view do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
Reference in New Issue
Block a user