create InJuty

This commit is contained in:
Zin Lin Phyo
2017-08-23 15:02:27 +06:30
parent d6b8e8bdee
commit 874a9b60be
25 changed files with 692 additions and 636 deletions

2
.idea/.generators generated
View File

@@ -5,4 +5,4 @@ You are allowed to:
2. Remove generators
3. Add installed generators
To add new installed generators automatically delete this file and reload the project.
--><GeneratorsGroup><Generator name="assets" /><Generator name="cancan:ability" /><Generator name="channel" /><Generator name="coffee:assets" /><Generator name="controller" /><Generator name="factory_girl:model" /><Generator name="generator" /><Generator name="helper" /><Generator name="integration_test" /><Generator name="jbuilder" /><Generator name="job" /><Generator name="js:assets" /><Generator name="kaminari:config" /><Generator name="kaminari:views" /><Generator name="mailer" /><Generator name="migration" /><Generator name="model" /><Generator name="nested_form:install" /><Generator name="resource" /><Generator name="rspec:controller" /><Generator name="rspec:feature" /><Generator name="rspec:helper" /><Generator name="rspec:install" /><Generator name="rspec:integration" /><Generator name="rspec:job" /><Generator name="rspec:mailer" /><Generator name="rspec:model" /><Generator name="rspec:observer" /><Generator name="rspec:request" /><Generator name="rspec:scaffold" /><Generator name="rspec:view" /><Generator name="scaffold" /><Generator name="scaffold_controller" /><Generator name="sidekiq:worker" /><Generator name="simple_form:install" /><Generator name="system_test" /><Generator name="task" /><Generator name="test_unit:controller" /><Generator name="test_unit:generator" /><Generator name="test_unit:helper" /><Generator name="test_unit:integration" /><Generator name="test_unit:job" /><Generator name="test_unit:mailer" /><Generator name="test_unit:model" /><Generator name="test_unit:plugin" /><Generator name="test_unit:scaffold" /><Generator name="test_unit:system" /><Generator name="uploader" /></GeneratorsGroup></Settings>
--><GeneratorsGroup><Generator name="active_record:migration" /><Generator name="active_record:model" /><Generator name="active_record:observer" /><Generator name="active_record:session_migration" /><Generator name="controller" /><Generator name="erb:controller" /><Generator name="erb:mailer" /><Generator name="erb:scaffold" /><Generator name="generator" /><Generator name="helper" /><Generator name="integration_test" /><Generator name="mailer" /><Generator name="metal" /><Generator name="migration" /><Generator name="model" /><Generator name="model_subclass" /><Generator name="observer" /><Generator name="performance_test" /><Generator name="plugin" /><Generator name="resource" /><Generator name="scaffold" /><Generator name="scaffold_controller" /><Generator name="session_migration" /><Generator name="stylesheets" /><Generator name="test_unit:controller" /><Generator name="test_unit:helper" /><Generator name="test_unit:integration" /><Generator name="test_unit:mailer" /><Generator name="test_unit:model" /><Generator name="test_unit:observer" /><Generator name="test_unit:performance" /><Generator name="test_unit:plugin" /><Generator name="test_unit:scaffold" /></GeneratorsGroup></Settings>

828
.idea/workspace.xml generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,91 +0,0 @@
class Origami::CommissionsController < BaseOrigamiController
before_action :set_commission, only: [:show, :edit, :update, :destroy]
# GET /commissions
# GET /commissions.json
def index
@commissions = Commission.all
end
# GET /commissions/1
# GET /commissions/1.json
def show
end
# GET /commissions/new
def new
@commission = Commission.new
@products = MenuItem.all
end
# GET /commissions/1/edit
def edit
@products = MenuItem.all
end
# POST /commissions
# POST /commissions.json
def create
@commission = Commission.new(commission_params)
respond_to do |format|
if @commission.save
format.html { redirect_to origami_commissions_path , notice: 'Commission was successfully created.' }
format.json { render :show, status: :created, location: @commission }
else
format.html { render :new }
format.json { render json: @commission.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /commissions/1
# PATCH/PUT /commissions/1.json
def update
respond_to do |format|
if @commission.update(commission_params)
format.html { redirect_to origami_commission_path(@commission), notice: 'Commission was successfully updated.' }
format.json { render :show, status: :ok, location: @commission }
else
format.html { render :edit }
format.json { render json: @commission.errors, status: :unprocessable_entity }
end
end
end
# DELETE /commissions/1
# DELETE /commissions/1.json
def destroy
@commission.destroy
respond_to do |format|
format.html { redirect_to origami_commissions_path, notice: 'Commission was successfully destroyed.' }
format.json { head :no_content }
end
end
def load_commissioners
sale_id = params[:sale_id]
@table_id = params[:table_id]
@saleobj = Sale.find(sale_id)
@commissioners = []
end
def select_sale_item
byebug
sale_item_id = params[:sale_item_id]
@sale_item = SaleItem.find_by_sale_item_id(sale_item_id)
@commissioners = Commissioner.active.all
end
private
# Use callbacks to share common setup or constraints between actions.
def set_commission
@commission = Commission.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def commission_params
params.require(:commission).permit(:product_id,:amount,:commission_type, :is_active)
end
end

View File

@@ -0,0 +1,74 @@
class Origami::InJutiesController < BaseOrigamiController
before_action :set_in_juty, only: [:show, :edit, :update, :destroy]
# GET /in_juties
# GET /in_juties.json
def index
@in_juties = InJuty.all
end
# GET /in_juties/1
# GET /in_juties/1.json
def show
end
# GET /in_juties/new
def new
@in_juty = InJuty.new
end
# GET /in_juties/1/edit
def edit
end
# POST /in_juties
# POST /in_juties.json
def create
@in_juty = InJuty.new(in_juty_params)
respond_to do |format|
if @in_juty.save
format.html { redirect_to @in_juty, notice: 'In juty was successfully created.' }
format.json { render :show, status: :created, location: @in_juty }
else
format.html { render :new }
format.json { render json: @in_juty.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /in_juties/1
# PATCH/PUT /in_juties/1.json
def update
respond_to do |format|
if @in_juty.update(in_juty_params)
format.html { redirect_to @in_juty, notice: 'In juty was successfully updated.' }
format.json { render :show, status: :ok, location: @in_juty }
else
format.html { render :edit }
format.json { render json: @in_juty.errors, status: :unprocessable_entity }
end
end
end
# DELETE /in_juties/1
# DELETE /in_juties/1.json
def destroy
@in_juty.destroy
respond_to do |format|
format.html { redirect_to in_juties_url, notice: 'In juty was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_in_juty
@in_juty = InJuty.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def in_juty_params
params.fetch(:in_juty, {})
end
end

View File

@@ -0,0 +1,2 @@
module Origami::InJutiesHelper
end

2
app/models/in_juty.rb Normal file
View File

@@ -0,0 +1,2 @@
class InJuty < ApplicationRecord
end

View File

@@ -0,0 +1,10 @@
<%= simple_form_for(@in_juty) do |f| %>
<%= f.error_notification %>
<div class="form-inputs">
</div>
<div class="form-actions">
<%= f.button :submit %>
</div>
<% end %>

View File

@@ -0,0 +1,2 @@
json.extract! in_juty, :id, :created_at, :updated_at
json.url in_juty_url(in_juty, format: :json)

View File

@@ -0,0 +1,6 @@
<h1>Editing In Juty</h1>
<%= render 'form', in_juty: @in_juty %>
<%= link_to 'Show', @in_juty %> |
<%= link_to 'Back', in_juties_path %>

View File

@@ -0,0 +1,25 @@
<p id="notice"><%= notice %></p>
<h1>In Juties</h1>
<table>
<thead>
<tr>
<th colspan="3"></th>
</tr>
</thead>
<tbody>
<% @in_juties.each do |in_juty| %>
<tr>
<td><%= link_to 'Show', in_juty %></td>
<td><%= link_to 'Edit', edit_in_juty_path(in_juty) %></td>
<td><%= link_to 'Destroy', in_juty, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
</table>
<br>
<%= link_to 'New In Juty', new_in_juty_path %>

View File

@@ -0,0 +1 @@
json.array! @in_juties, partial: 'in_juties/in_juty', as: :in_juty

View File

@@ -0,0 +1,5 @@
<h1>New In Juty</h1>
<%= render 'form', in_juty: @in_juty %>
<%= link_to 'Back', in_juties_path %>

View File

@@ -0,0 +1,4 @@
<p id="notice"><%= notice %></p>
<%= link_to 'Edit', edit_in_juty_path(@in_juty) %> |
<%= link_to 'Back', in_juties_path %>

View File

@@ -0,0 +1 @@
json.partial! "in_juties/in_juty", in_juty: @in_juty

View File

@@ -174,6 +174,7 @@ Rails.application.routes.draw do
resources :addorders
resources :commissions
resources :commissioners
resources :in_juties
end
#--------- Waiter/Ordering Station ------------#

View File

@@ -0,0 +1,11 @@
class CreateInJuties < ActiveRecord::Migration[5.1]
def change
create_table :in_juties do |t|
t.integer :dinning_id
t.json :commissioner_ids
t.datetime :in_time
t.datetime :out_time
t.timestamps
end
end
end

View 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 Origami::InJutiesController, type: :controller do
# This should return the minimal set of attributes required to create a valid
# InJuty. As you add validations to InJuty, 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
# Origami::InJutiesController. Be sure to keep this updated too.
let(:valid_session) { {} }
describe "GET #index" do
it "returns a success response" do
in_juty = InJuty.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
in_juty = InJuty.create! valid_attributes
get :show, params: {id: in_juty.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
in_juty = InJuty.create! valid_attributes
get :edit, params: {id: in_juty.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 InJuty" do
expect {
post :create, params: {origami_in_juty: valid_attributes}, session: valid_session
}.to change(InJuty, :count).by(1)
end
it "redirects to the created origami_in_juty" do
post :create, params: {origami_in_juty: valid_attributes}, session: valid_session
expect(response).to redirect_to(InJuty.last)
end
end
context "with invalid params" do
it "returns a success response (i.e. to display the 'new' template)" do
post :create, params: {origami_in_juty: 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 origami_in_juty" do
in_juty = InJuty.create! valid_attributes
put :update, params: {id: in_juty.to_param, origami_in_juty: new_attributes}, session: valid_session
in_juty.reload
skip("Add assertions for updated state")
end
it "redirects to the origami_in_juty" do
in_juty = InJuty.create! valid_attributes
put :update, params: {id: in_juty.to_param, origami_in_juty: valid_attributes}, session: valid_session
expect(response).to redirect_to(in_juty)
end
end
context "with invalid params" do
it "returns a success response (i.e. to display the 'edit' template)" do
in_juty = InJuty.create! valid_attributes
put :update, params: {id: in_juty.to_param, origami_in_juty: invalid_attributes}, session: valid_session
expect(response).to be_success
end
end
end
describe "DELETE #destroy" do
it "destroys the requested origami_in_juty" do
in_juty = InJuty.create! valid_attributes
expect {
delete :destroy, params: {id: in_juty.to_param}, session: valid_session
}.to change(InJuty, :count).by(-1)
end
it "redirects to the in_juties list" do
in_juty = InJuty.create! valid_attributes
delete :destroy, params: {id: in_juty.to_param}, session: valid_session
expect(response).to redirect_to(in_juties_url)
end
end
end

View File

@@ -0,0 +1,15 @@
require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the Origami::InJutiesHelper. For example:
#
# describe Origami::InJutiesHelper 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 Origami::InJutiesHelper, type: :helper do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe InJuty, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@@ -0,0 +1,10 @@
require 'rails_helper'
RSpec.describe "Origami::InJuties", type: :request do
describe "GET /origami_in_juties" do
it "works! (now write some real specs)" do
get origami_in_juties_path
expect(response).to have_http_status(200)
end
end
end

View File

@@ -0,0 +1,39 @@
require "rails_helper"
RSpec.describe Origami::InJutiesController, type: :routing do
describe "routing" do
it "routes to #index" do
expect(:get => "/origami/in_juties").to route_to("origami/in_juties#index")
end
it "routes to #new" do
expect(:get => "/origami/in_juties/new").to route_to("origami/in_juties#new")
end
it "routes to #show" do
expect(:get => "/origami/in_juties/1").to route_to("origami/in_juties#show", :id => "1")
end
it "routes to #edit" do
expect(:get => "/origami/in_juties/1/edit").to route_to("origami/in_juties#edit", :id => "1")
end
it "routes to #create" do
expect(:post => "/origami/in_juties").to route_to("origami/in_juties#create")
end
it "routes to #update via PUT" do
expect(:put => "/origami/in_juties/1").to route_to("origami/in_juties#update", :id => "1")
end
it "routes to #update via PATCH" do
expect(:patch => "/origami/in_juties/1").to route_to("origami/in_juties#update", :id => "1")
end
it "routes to #destroy" do
expect(:delete => "/origami/in_juties/1").to route_to("origami/in_juties#destroy", :id => "1")
end
end
end

View File

@@ -0,0 +1,14 @@
require 'rails_helper'
RSpec.describe "origami/in_juties/edit", type: :view do
before(:each) do
@origami_in_juty = assign(:origami_in_juty, InJuty.create!())
end
it "renders the edit origami_in_juty form" do
render
assert_select "form[action=?][method=?]", origami_in_juty_path(@origami_in_juty), "post" do
end
end
end

View File

@@ -0,0 +1,14 @@
require 'rails_helper'
RSpec.describe "origami/in_juties/index", type: :view do
before(:each) do
assign(:in_juties, [
InJuty.create!(),
InJuty.create!()
])
end
it "renders a list of origami/in_juties" do
render
end
end

View File

@@ -0,0 +1,14 @@
require 'rails_helper'
RSpec.describe "origami/in_juties/new", type: :view do
before(:each) do
assign(:origami_in_juty, InJuty.new())
end
it "renders new origami_in_juty form" do
render
assert_select "form[action=?][method=?]", in_juties_path, "post" do
end
end
end

View File

@@ -0,0 +1,11 @@
require 'rails_helper'
RSpec.describe "origami/in_juties/show", type: :view do
before(:each) do
@origami_in_juty = assign(:origami_in_juty, InJuty.create!())
end
it "renders attributes in <p>" do
render
end
end