-
-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Robb Kidd <[email protected]> Co-authored-by: Mae Beale <[email protected]>
- Loading branch information
1 parent
ce90e0e
commit 902639d
Showing
19 changed files
with
397 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Place all the behaviors and hooks related to the matching controller here. | ||
// All this logic will automatically be available in application.js. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/* | ||
Place all the styles related to the matching controller here. | ||
They will automatically be included in application.css. | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
class BoxesController < ApplicationController | ||
before_action :set_box, only: [:show, :edit, :update, :destroy] | ||
|
||
# GET /boxes | ||
# GET /boxes.json | ||
def index | ||
@boxes = Box.all | ||
end | ||
|
||
# GET /boxes/1 | ||
# GET /boxes/1.json | ||
def show | ||
end | ||
|
||
# GET /boxes/new | ||
def new | ||
@box = Box.new | ||
end | ||
|
||
# GET /boxes/1/edit | ||
def edit | ||
end | ||
|
||
# POST /boxes | ||
# POST /boxes.json | ||
def create | ||
@box = Box.new(box_params) | ||
|
||
respond_to do |format| | ||
if @box.save | ||
format.html { redirect_to @box, notice: 'Box was successfully created.' } | ||
format.json { render :show, status: :created, location: @box } | ||
else | ||
format.html { render :new } | ||
format.json { render json: @box.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PATCH/PUT /boxes/1 | ||
# PATCH/PUT /boxes/1.json | ||
def update | ||
respond_to do |format| | ||
if @box.update(box_params) | ||
format.html { redirect_to @box, notice: 'Box was successfully updated.' } | ||
format.json { render :show, status: :ok, location: @box } | ||
else | ||
format.html { render :edit } | ||
format.json { render json: @box.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /boxes/1 | ||
# DELETE /boxes/1.json | ||
def destroy | ||
@box.destroy | ||
respond_to do |format| | ||
format.html { redirect_to boxes_url, notice: 'Box was successfully destroyed.' } | ||
format.json { head :no_content } | ||
end | ||
end | ||
|
||
private | ||
# Use callbacks to share common setup or constraints between actions. | ||
def set_box | ||
@box = Box.find(params[:id]) | ||
end | ||
|
||
# Never trust parameters from the scary internet, only allow the white list through. | ||
def box_params | ||
params.require(:box).permit(:box_request_id, :designed_by_id, :design_reviewed_by_id, :assembled_by_id, :shipped_by_id, :shipping_payment_id, :shipped_at, :shipment_tracking_number) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module BoxesHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class Box < ApplicationRecord | ||
belongs_to :box_request | ||
belongs_to :designed_by | ||
belongs_to :design_reviewed_by | ||
belongs_to :assembled_by | ||
belongs_to :shipped_by | ||
belongs_to :shipping_payment | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
json.extract! box, :id, :box_request_id, :designed_by_id, :design_reviewed_by_id, :assembled_by_id, :shipped_by_id, :shipping_payment_id, :shipped_at, :shipment_tracking_number, :created_at, :updated_at | ||
json.url box_url(box, format: :json) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<%= form_with(model: box, local: true) do |form| %> | ||
<% if box.errors.any? %> | ||
<div id="error_explanation"> | ||
<h2><%= pluralize(box.errors.count, "error") %> prohibited this box from being saved:</h2> | ||
|
||
<ul> | ||
<% box.errors.full_messages.each do |message| %> | ||
<li><%= message %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<div class="field"> | ||
<%= form.label :box_request_id %> | ||
<%= form.text_field :box_request_id %> | ||
</div> | ||
|
||
<div class="field"> | ||
<%= form.label :designed_by_id %> | ||
<%= form.text_field :designed_by_id %> | ||
</div> | ||
|
||
<div class="field"> | ||
<%= form.label :design_reviewed_by_id %> | ||
<%= form.text_field :design_reviewed_by_id %> | ||
</div> | ||
|
||
<div class="field"> | ||
<%= form.label :assembled_by_id %> | ||
<%= form.text_field :assembled_by_id %> | ||
</div> | ||
|
||
<div class="field"> | ||
<%= form.label :shipped_by_id %> | ||
<%= form.text_field :shipped_by_id %> | ||
</div> | ||
|
||
<div class="field"> | ||
<%= form.label :shipping_payment_id %> | ||
<%= form.text_field :shipping_payment_id %> | ||
</div> | ||
|
||
<div class="field"> | ||
<%= form.label :shipped_at %> | ||
<%= form.datetime_select :shipped_at %> | ||
</div> | ||
|
||
<div class="field"> | ||
<%= form.label :shipment_tracking_number %> | ||
<%= form.text_field :shipment_tracking_number %> | ||
</div> | ||
|
||
<div class="actions"> | ||
<%= form.submit %> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<h1>Editing Box</h1> | ||
|
||
<%= render 'form', box: @box %> | ||
<%= link_to 'Show', @box %> | | ||
<%= link_to 'Back', boxes_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<p id="notice"><%= notice %></p> | ||
|
||
<h1>Boxes</h1> | ||
|
||
<table> | ||
<thead> | ||
<tr> | ||
<th>Box request</th> | ||
<th>Designed by</th> | ||
<th>Design reviewed by</th> | ||
<th>Assembled by</th> | ||
<th>Shipped by</th> | ||
<th>Shipping payment</th> | ||
<th>Shipped at</th> | ||
<th>Shipment tracking number</th> | ||
<th colspan="3"></th> | ||
</tr> | ||
</thead> | ||
|
||
<tbody> | ||
<% @boxes.each do |box| %> | ||
<tr> | ||
<td><%= box.box_request %></td> | ||
<td><%= box.designed_by %></td> | ||
<td><%= box.design_reviewed_by %></td> | ||
<td><%= box.assembled_by %></td> | ||
<td><%= box.shipped_by %></td> | ||
<td><%= box.shipping_payment %></td> | ||
<td><%= box.shipped_at %></td> | ||
<td><%= box.shipment_tracking_number %></td> | ||
<td><%= link_to 'Show', box %></td> | ||
<td><%= link_to 'Edit', edit_box_path(box) %></td> | ||
<td><%= link_to 'Destroy', box, method: :delete, data: { confirm: 'Are you sure?' } %></td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
|
||
<br> | ||
|
||
<%= link_to 'New Box', new_box_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
json.array! @boxes, partial: "boxes/box", as: :box |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<h1>New Box</h1> | ||
|
||
<%= render 'form', box: @box %> | ||
<%= link_to 'Back', boxes_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<p id="notice"><%= notice %></p> | ||
|
||
<p> | ||
<strong>Box request:</strong> | ||
<%= @box.box_request %> | ||
</p> | ||
|
||
<p> | ||
<strong>Designed by:</strong> | ||
<%= @box.designed_by %> | ||
</p> | ||
|
||
<p> | ||
<strong>Design reviewed by:</strong> | ||
<%= @box.design_reviewed_by %> | ||
</p> | ||
|
||
<p> | ||
<strong>Assembled by:</strong> | ||
<%= @box.assembled_by %> | ||
</p> | ||
|
||
<p> | ||
<strong>Shipped by:</strong> | ||
<%= @box.shipped_by %> | ||
</p> | ||
|
||
<p> | ||
<strong>Shipping payment:</strong> | ||
<%= @box.shipping_payment %> | ||
</p> | ||
|
||
<p> | ||
<strong>Shipped at:</strong> | ||
<%= @box.shipped_at %> | ||
</p> | ||
|
||
<p> | ||
<strong>Shipment tracking number:</strong> | ||
<%= @box.shipment_tracking_number %> | ||
</p> | ||
|
||
<%= link_to 'Edit', edit_box_path(@box) %> | | ||
<%= link_to 'Back', boxes_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
json.partial! "boxes/box", box: @box |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class CreateBoxes < ActiveRecord::Migration[5.2] | ||
def change | ||
create_table :boxes do |t| | ||
t.references :box_request, foreign_key: true, null: false, index: true | ||
t.references :designed_by, foreign_table_name: :user, null: true, index: true | ||
t.references :design_reviewed_by, foreign_table_name: :user, null: true, index: true | ||
t.references :assembled_by, foreign_table_name: :user, null: true, index: true | ||
t.references :shipped_by, foreign_table_name: :user, null: true, index: true | ||
t.references :shipping_payment, foreign_table_name: :purchase, null: true, index: true | ||
t.datetime :shipped_at | ||
t.string :shipment_tracking_number | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
require 'test_helper' | ||
|
||
class BoxesControllerTest < ActionDispatch::IntegrationTest | ||
setup do | ||
@box = boxes(:one) | ||
end | ||
|
||
test "should get index" do | ||
get boxes_url | ||
assert_response :success | ||
end | ||
|
||
test "should get new" do | ||
get new_box_url | ||
assert_response :success | ||
end | ||
|
||
test "should create box" do | ||
assert_difference('Box.count') do | ||
post boxes_url, params: { box: { assembled_by_id: @box.assembled_by_id, box_request_id: @box.box_request_id, design_reviewed_by_id: @box.design_reviewed_by_id, designed_by_id: @box.designed_by_id, shipment_tracking_number: @box.shipment_tracking_number, shipped_at: @box.shipped_at, shipped_by_id: @box.shipped_by_id, shipping_payment_id: @box.shipping_payment_id } } | ||
end | ||
|
||
assert_redirected_to box_url(Box.last) | ||
end | ||
|
||
test "should show box" do | ||
get box_url(@box) | ||
assert_response :success | ||
end | ||
|
||
test "should get edit" do | ||
get edit_box_url(@box) | ||
assert_response :success | ||
end | ||
|
||
test "should update box" do | ||
patch box_url(@box), params: { box: { assembled_by_id: @box.assembled_by_id, box_request_id: @box.box_request_id, design_reviewed_by_id: @box.design_reviewed_by_id, designed_by_id: @box.designed_by_id, shipment_tracking_number: @box.shipment_tracking_number, shipped_at: @box.shipped_at, shipped_by_id: @box.shipped_by_id, shipping_payment_id: @box.shipping_payment_id } } | ||
assert_redirected_to box_url(@box) | ||
end | ||
|
||
test "should destroy box" do | ||
assert_difference('Box.count', -1) do | ||
delete box_url(@box) | ||
end | ||
|
||
assert_redirected_to boxes_url | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html | ||
|
||
one: | ||
box_request: one | ||
designed_by: one | ||
design_reviewed_by: one | ||
assembled_by: one | ||
shipped_by: one | ||
shipping_payment: one | ||
shipped_at: 2019-07-26 16:05:25 | ||
shipment_tracking_number: MyString | ||
|
||
two: | ||
box_request: two | ||
designed_by: two | ||
design_reviewed_by: two | ||
assembled_by: two | ||
shipped_by: two | ||
shipping_payment: two | ||
shipped_at: 2019-07-26 16:05:25 | ||
shipment_tracking_number: MyString |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require 'test_helper' | ||
|
||
class BoxTest < ActiveSupport::TestCase | ||
# test "the truth" do | ||
# assert true | ||
# end | ||
end |
Oops, something went wrong.