dining_charges
This commit is contained in:
3
app/assets/javascripts/dining_charges.coffee
Normal file
3
app/assets/javascripts/dining_charges.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/stylesheets/dining_charges.scss
Normal file
3
app/assets/stylesheets/dining_charges.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the dining_charges controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
74
app/controllers/dining_charges_controller.rb
Normal file
74
app/controllers/dining_charges_controller.rb
Normal file
@@ -0,0 +1,74 @@
|
||||
class DiningChargesController < ApplicationController
|
||||
before_action :set_dining_charge, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
# GET /dining_charges
|
||||
# GET /dining_charges.json
|
||||
def index
|
||||
@dining_charges = DiningCharge.all
|
||||
end
|
||||
|
||||
# GET /dining_charges/1
|
||||
# GET /dining_charges/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /dining_charges/new
|
||||
def new
|
||||
@dining_charge = DiningCharge.new
|
||||
end
|
||||
|
||||
# GET /dining_charges/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /dining_charges
|
||||
# POST /dining_charges.json
|
||||
def create
|
||||
@dining_charge = DiningCharge.new(dining_charge_params)
|
||||
|
||||
respond_to do |format|
|
||||
if @dining_charge.save
|
||||
format.html { redirect_to @dining_charge, notice: 'Dining charge was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @dining_charge }
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: @dining_charge.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /dining_charges/1
|
||||
# PATCH/PUT /dining_charges/1.json
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @dining_charge.update(dining_charge_params)
|
||||
format.html { redirect_to @dining_charge, notice: 'Dining charge was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @dining_charge }
|
||||
else
|
||||
format.html { render :edit }
|
||||
format.json { render json: @dining_charge.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /dining_charges/1
|
||||
# DELETE /dining_charges/1.json
|
||||
def destroy
|
||||
@dining_charge.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to dining_charges_url, notice: 'Dining charge was successfully destroyed.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_dining_charge
|
||||
@dining_charge = DiningCharge.find(params[:id])
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def dining_charge_params
|
||||
params.fetch(:dining_charge, {})
|
||||
end
|
||||
end
|
||||
2
app/helpers/dining_charges_helper.rb
Normal file
2
app/helpers/dining_charges_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module DiningChargesHelper
|
||||
end
|
||||
2
app/models/dining_charge.rb
Normal file
2
app/models/dining_charge.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
class DiningCharge < ApplicationRecord
|
||||
end
|
||||
2
app/views/dining_charges/_dining_charge.json.jbuilder
Normal file
2
app/views/dining_charges/_dining_charge.json.jbuilder
Normal file
@@ -0,0 +1,2 @@
|
||||
json.extract! dining_charge, :id, :created_at, :updated_at
|
||||
json.url dining_charge_url(dining_charge, format: :json)
|
||||
10
app/views/dining_charges/_form.html.erb
Normal file
10
app/views/dining_charges/_form.html.erb
Normal file
@@ -0,0 +1,10 @@
|
||||
<%= simple_form_for(@dining_charge) do |f| %>
|
||||
<%= f.error_notification %>
|
||||
|
||||
<div class="form-inputs">
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
<%= f.button :submit %>
|
||||
</div>
|
||||
<% end %>
|
||||
6
app/views/dining_charges/edit.html.erb
Normal file
6
app/views/dining_charges/edit.html.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
<h1>Editing Dining Charge</h1>
|
||||
|
||||
<%= render 'form', dining_charge: @dining_charge %>
|
||||
|
||||
<%= link_to 'Show', @dining_charge %> |
|
||||
<%= link_to 'Back', dining_charges_path %>
|
||||
25
app/views/dining_charges/index.html.erb
Normal file
25
app/views/dining_charges/index.html.erb
Normal file
@@ -0,0 +1,25 @@
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
<h1>Dining Charges</h1>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="3"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% @dining_charges.each do |dining_charge| %>
|
||||
<tr>
|
||||
<td><%= link_to 'Show', dining_charge %></td>
|
||||
<td><%= link_to 'Edit', edit_dining_charge_path(dining_charge) %></td>
|
||||
<td><%= link_to 'Destroy', dining_charge, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<br>
|
||||
|
||||
<%= link_to 'New Dining Charge', new_dining_charge_path %>
|
||||
1
app/views/dining_charges/index.json.jbuilder
Normal file
1
app/views/dining_charges/index.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.array! @dining_charges, partial: 'dining_charges/dining_charge', as: :dining_charge
|
||||
5
app/views/dining_charges/new.html.erb
Normal file
5
app/views/dining_charges/new.html.erb
Normal file
@@ -0,0 +1,5 @@
|
||||
<h1>New Dining Charge</h1>
|
||||
|
||||
<%= render 'form', dining_charge: @dining_charge %>
|
||||
|
||||
<%= link_to 'Back', dining_charges_path %>
|
||||
4
app/views/dining_charges/show.html.erb
Normal file
4
app/views/dining_charges/show.html.erb
Normal file
@@ -0,0 +1,4 @@
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
<%= link_to 'Edit', edit_dining_charge_path(@dining_charge) %> |
|
||||
<%= link_to 'Back', dining_charges_path %>
|
||||
1
app/views/dining_charges/show.json.jbuilder
Normal file
1
app/views/dining_charges/show.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.partial! "dining_charges/dining_charge", dining_charge: @dining_charge
|
||||
@@ -2,6 +2,7 @@ require 'sidekiq/web'
|
||||
|
||||
Rails.application.routes.draw do
|
||||
|
||||
resources :dining_charges
|
||||
root 'home#index'
|
||||
mount Sidekiq::Web => '/kiq'
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ class CreateCustomers < ActiveRecord::Migration[5.1]
|
||||
t.string :membership_id
|
||||
t.string :membership_type
|
||||
t.string :membership_authentication_code
|
||||
t.string :customer_type, default => "Dinein"
|
||||
t.string :customer_type, :default => "Dinein"
|
||||
t.json :tax_profiles
|
||||
end
|
||||
end
|
||||
|
||||
16
db/migrate/20170811052036_create_dining_charges.rb
Normal file
16
db/migrate/20170811052036_create_dining_charges.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
class CreateDiningCharges < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
create_table :dining_charges do |t|
|
||||
t.references :dining_facility
|
||||
t.string :item_code, :null => false
|
||||
t.integer :unit_price, :default => 0
|
||||
t.boolean :taxable, :default => true
|
||||
t.string :charge_type, :default => "hr"
|
||||
t.time :minimum_free_time
|
||||
t.time :charge_block
|
||||
t.string :time_rounding, :default => "down"
|
||||
t.time :time_rounding_block
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
141
spec/controllers/dining_charges_controller_spec.rb
Normal file
141
spec/controllers/dining_charges_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 DiningChargesController, type: :controller do
|
||||
|
||||
# This should return the minimal set of attributes required to create a valid
|
||||
# DiningCharge. As you add validations to DiningCharge, 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
|
||||
# DiningChargesController. Be sure to keep this updated too.
|
||||
let(:valid_session) { {} }
|
||||
|
||||
describe "GET #index" do
|
||||
it "returns a success response" do
|
||||
dining_charge = DiningCharge.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
|
||||
dining_charge = DiningCharge.create! valid_attributes
|
||||
get :show, params: {id: dining_charge.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
|
||||
dining_charge = DiningCharge.create! valid_attributes
|
||||
get :edit, params: {id: dining_charge.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 DiningCharge" do
|
||||
expect {
|
||||
post :create, params: {dining_charge: valid_attributes}, session: valid_session
|
||||
}.to change(DiningCharge, :count).by(1)
|
||||
end
|
||||
|
||||
it "redirects to the created dining_charge" do
|
||||
post :create, params: {dining_charge: valid_attributes}, session: valid_session
|
||||
expect(response).to redirect_to(DiningCharge.last)
|
||||
end
|
||||
end
|
||||
|
||||
context "with invalid params" do
|
||||
it "returns a success response (i.e. to display the 'new' template)" do
|
||||
post :create, params: {dining_charge: 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 dining_charge" do
|
||||
dining_charge = DiningCharge.create! valid_attributes
|
||||
put :update, params: {id: dining_charge.to_param, dining_charge: new_attributes}, session: valid_session
|
||||
dining_charge.reload
|
||||
skip("Add assertions for updated state")
|
||||
end
|
||||
|
||||
it "redirects to the dining_charge" do
|
||||
dining_charge = DiningCharge.create! valid_attributes
|
||||
put :update, params: {id: dining_charge.to_param, dining_charge: valid_attributes}, session: valid_session
|
||||
expect(response).to redirect_to(dining_charge)
|
||||
end
|
||||
end
|
||||
|
||||
context "with invalid params" do
|
||||
it "returns a success response (i.e. to display the 'edit' template)" do
|
||||
dining_charge = DiningCharge.create! valid_attributes
|
||||
put :update, params: {id: dining_charge.to_param, dining_charge: invalid_attributes}, session: valid_session
|
||||
expect(response).to be_success
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "DELETE #destroy" do
|
||||
it "destroys the requested dining_charge" do
|
||||
dining_charge = DiningCharge.create! valid_attributes
|
||||
expect {
|
||||
delete :destroy, params: {id: dining_charge.to_param}, session: valid_session
|
||||
}.to change(DiningCharge, :count).by(-1)
|
||||
end
|
||||
|
||||
it "redirects to the dining_charges list" do
|
||||
dining_charge = DiningCharge.create! valid_attributes
|
||||
delete :destroy, params: {id: dining_charge.to_param}, session: valid_session
|
||||
expect(response).to redirect_to(dining_charges_url)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
15
spec/helpers/dining_charges_helper_spec.rb
Normal file
15
spec/helpers/dining_charges_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 DiningChargesHelper. For example:
|
||||
#
|
||||
# describe DiningChargesHelper 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 DiningChargesHelper, type: :helper do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
5
spec/models/dining_charge_spec.rb
Normal file
5
spec/models/dining_charge_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe DiningCharge, type: :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
10
spec/requests/dining_charges_spec.rb
Normal file
10
spec/requests/dining_charges_spec.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "DiningCharges", type: :request do
|
||||
describe "GET /dining_charges" do
|
||||
it "works! (now write some real specs)" do
|
||||
get dining_charges_path
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
end
|
||||
39
spec/routing/dining_charges_routing_spec.rb
Normal file
39
spec/routing/dining_charges_routing_spec.rb
Normal file
@@ -0,0 +1,39 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe DiningChargesController, type: :routing do
|
||||
describe "routing" do
|
||||
|
||||
it "routes to #index" do
|
||||
expect(:get => "/dining_charges").to route_to("dining_charges#index")
|
||||
end
|
||||
|
||||
it "routes to #new" do
|
||||
expect(:get => "/dining_charges/new").to route_to("dining_charges#new")
|
||||
end
|
||||
|
||||
it "routes to #show" do
|
||||
expect(:get => "/dining_charges/1").to route_to("dining_charges#show", :id => "1")
|
||||
end
|
||||
|
||||
it "routes to #edit" do
|
||||
expect(:get => "/dining_charges/1/edit").to route_to("dining_charges#edit", :id => "1")
|
||||
end
|
||||
|
||||
it "routes to #create" do
|
||||
expect(:post => "/dining_charges").to route_to("dining_charges#create")
|
||||
end
|
||||
|
||||
it "routes to #update via PUT" do
|
||||
expect(:put => "/dining_charges/1").to route_to("dining_charges#update", :id => "1")
|
||||
end
|
||||
|
||||
it "routes to #update via PATCH" do
|
||||
expect(:patch => "/dining_charges/1").to route_to("dining_charges#update", :id => "1")
|
||||
end
|
||||
|
||||
it "routes to #destroy" do
|
||||
expect(:delete => "/dining_charges/1").to route_to("dining_charges#destroy", :id => "1")
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
14
spec/views/dining_charges/edit.html.erb_spec.rb
Normal file
14
spec/views/dining_charges/edit.html.erb_spec.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "dining_charges/edit", type: :view do
|
||||
before(:each) do
|
||||
@dining_charge = assign(:dining_charge, DiningCharge.create!())
|
||||
end
|
||||
|
||||
it "renders the edit dining_charge form" do
|
||||
render
|
||||
|
||||
assert_select "form[action=?][method=?]", dining_charge_path(@dining_charge), "post" do
|
||||
end
|
||||
end
|
||||
end
|
||||
14
spec/views/dining_charges/index.html.erb_spec.rb
Normal file
14
spec/views/dining_charges/index.html.erb_spec.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "dining_charges/index", type: :view do
|
||||
before(:each) do
|
||||
assign(:dining_charges, [
|
||||
DiningCharge.create!(),
|
||||
DiningCharge.create!()
|
||||
])
|
||||
end
|
||||
|
||||
it "renders a list of dining_charges" do
|
||||
render
|
||||
end
|
||||
end
|
||||
14
spec/views/dining_charges/new.html.erb_spec.rb
Normal file
14
spec/views/dining_charges/new.html.erb_spec.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "dining_charges/new", type: :view do
|
||||
before(:each) do
|
||||
assign(:dining_charge, DiningCharge.new())
|
||||
end
|
||||
|
||||
it "renders new dining_charge form" do
|
||||
render
|
||||
|
||||
assert_select "form[action=?][method=?]", dining_charges_path, "post" do
|
||||
end
|
||||
end
|
||||
end
|
||||
11
spec/views/dining_charges/show.html.erb_spec.rb
Normal file
11
spec/views/dining_charges/show.html.erb_spec.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "dining_charges/show", type: :view do
|
||||
before(:each) do
|
||||
@dining_charge = assign(:dining_charge, DiningCharge.create!())
|
||||
end
|
||||
|
||||
it "renders attributes in <p>" do
|
||||
render
|
||||
end
|
||||
end
|
||||
9
test/system/dining_charges_test.rb
Normal file
9
test/system/dining_charges_test.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
require "application_system_test_case"
|
||||
|
||||
class DiningChargesTest < ApplicationSystemTestCase
|
||||
# test "visiting the index" do
|
||||
# visit dining_charges_url
|
||||
#
|
||||
# assert_selector "h1", text: "DiningCharge"
|
||||
# end
|
||||
end
|
||||
Reference in New Issue
Block a user