Signed-off-by: ahinz <ahinz@voicetelecom.pl>
This commit is contained in:
parent
34d080a3ce
commit
87741bac31
|
|
@ -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/
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
// Place all the styles related to the GemCrafts controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
class GemCraftsController < ApplicationController
|
||||
before_action :set_gem_craft, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
# GET /gem_crafts
|
||||
# GET /gem_crafts.json
|
||||
def index
|
||||
@gem_crafts = GemCraft.all
|
||||
end
|
||||
|
||||
# GET /gem_crafts/1
|
||||
# GET /gem_crafts/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /gem_crafts/new
|
||||
def new
|
||||
@gem_craft = GemCraft.new
|
||||
end
|
||||
|
||||
# GET /gem_crafts/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /gem_crafts
|
||||
# POST /gem_crafts.json
|
||||
def create
|
||||
@gem_craft = GemCraft.new(gem_craft_params)
|
||||
|
||||
respond_to do |format|
|
||||
if @gem_craft.save
|
||||
format.html { redirect_to @gem_craft, notice: 'Gem craft was successfully created.' }
|
||||
format.json { render action: 'show', status: :created, location: @gem_craft }
|
||||
else
|
||||
format.html { render action: 'new' }
|
||||
format.json { render json: @gem_craft.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /gem_crafts/1
|
||||
# PATCH/PUT /gem_crafts/1.json
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @gem_craft.update(gem_craft_params)
|
||||
format.html { redirect_to @gem_craft, notice: 'Gem craft was successfully updated.' }
|
||||
format.json { head :no_content }
|
||||
else
|
||||
format.html { render action: 'edit' }
|
||||
format.json { render json: @gem_craft.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /gem_crafts/1
|
||||
# DELETE /gem_crafts/1.json
|
||||
def destroy
|
||||
@gem_craft.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to gem_crafts_url }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_gem_craft
|
||||
@gem_craft = GemCraft.find(params[:id])
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def gem_craft_params
|
||||
params.require(:gem_craft).permit(:name, :price, :books_type, :books_qnt, :previous_id, :previous_qnt)
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
module GemCraftsHelper
|
||||
end
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
class GemCraft < ActiveRecord::Base
|
||||
end
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
<%= form_for(@gem_craft) do |f| %>
|
||||
<% if @gem_craft.errors.any? %>
|
||||
<div id="error_explanation">
|
||||
<h2><%= pluralize(@gem_craft.errors.count, "error") %> prohibited this gem_craft from being saved:</h2>
|
||||
|
||||
<ul>
|
||||
<% @gem_craft.errors.full_messages.each do |msg| %>
|
||||
<li><%= msg %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :name %><br>
|
||||
<%= f.text_field :name %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :price %><br>
|
||||
<%= f.number_field :price %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :books_type %><br>
|
||||
<%= f.number_field :books_type %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :books_qnt %><br>
|
||||
<%= f.number_field :books_qnt %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :previous_id %><br>
|
||||
<%= f.number_field :previous_id %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :previous_qnt %><br>
|
||||
<%= f.number_field :previous_qnt %>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<%= f.submit %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
<h1>Editing gem_craft</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Show', @gem_craft %> |
|
||||
<%= link_to 'Back', gem_crafts_path %>
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
<h1>Listing gem_crafts</h1>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Price</th>
|
||||
<th>Books type</th>
|
||||
<th>Books qnt</th>
|
||||
<th>Previous</th>
|
||||
<th>Previous qnt</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% @gem_crafts.each do |gem_craft| %>
|
||||
<tr>
|
||||
<td><%= gem_craft.name %></td>
|
||||
<td><%= gem_craft.price %></td>
|
||||
<td><%= gem_craft.books_type %></td>
|
||||
<td><%= gem_craft.books_qnt %></td>
|
||||
<td><%= gem_craft.previous_id %></td>
|
||||
<td><%= gem_craft.previous_qnt %></td>
|
||||
<td><%= link_to 'Show', gem_craft %></td>
|
||||
<td><%= link_to 'Edit', edit_gem_craft_path(gem_craft) %></td>
|
||||
<td><%= link_to 'Destroy', gem_craft, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<br>
|
||||
|
||||
<%= link_to 'New Gem craft', new_gem_craft_path %>
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
json.array!(@gem_crafts) do |gem_craft|
|
||||
json.extract! gem_craft, :name, :price, :books_type, :books_qnt, :previous_id, :previous_qnt
|
||||
json.url gem_craft_url(gem_craft, format: :json)
|
||||
end
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
<h1>New gem_craft</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Back', gem_crafts_path %>
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<p id="notice"><%= notice %></p>
|
||||
|
||||
<p>
|
||||
<strong>Name:</strong>
|
||||
<%= @gem_craft.name %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Price:</strong>
|
||||
<%= @gem_craft.price %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Books type:</strong>
|
||||
<%= @gem_craft.books_type %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Books qnt:</strong>
|
||||
<%= @gem_craft.books_qnt %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Previous:</strong>
|
||||
<%= @gem_craft.previous_id %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Previous qnt:</strong>
|
||||
<%= @gem_craft.previous_qnt %>
|
||||
</p>
|
||||
|
||||
<%= link_to 'Edit', edit_gem_craft_path(@gem_craft) %> |
|
||||
<%= link_to 'Back', gem_crafts_path %>
|
||||
|
|
@ -0,0 +1 @@
|
|||
json.extract! @gem_craft, :name, :price, :books_type, :books_qnt, :previous_id, :previous_qnt, :created_at, :updated_at
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
class CreateGemCrafts < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :gem_crafts do |t|
|
||||
t.string :name
|
||||
t.integer :price
|
||||
t.integer :books_type
|
||||
t.integer :books_qnt
|
||||
t.integer :previous_id
|
||||
t.integer :previous_qnt
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
require 'test_helper'
|
||||
|
||||
class GemCraftsControllerTest < ActionController::TestCase
|
||||
setup do
|
||||
@gem_craft = gem_crafts(:one)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_not_nil assigns(:gem_crafts)
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
get :new
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create gem_craft" do
|
||||
assert_difference('GemCraft.count') do
|
||||
post :create, gem_craft: { books_qnt: @gem_craft.books_qnt, books_type: @gem_craft.books_type, name: @gem_craft.name, previous_id: @gem_craft.previous_id, previous_qnt: @gem_craft.previous_qnt, price: @gem_craft.price }
|
||||
end
|
||||
|
||||
assert_redirected_to gem_craft_path(assigns(:gem_craft))
|
||||
end
|
||||
|
||||
test "should show gem_craft" do
|
||||
get :show, id: @gem_craft
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get edit" do
|
||||
get :edit, id: @gem_craft
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should update gem_craft" do
|
||||
patch :update, id: @gem_craft, gem_craft: { books_qnt: @gem_craft.books_qnt, books_type: @gem_craft.books_type, name: @gem_craft.name, previous_id: @gem_craft.previous_id, previous_qnt: @gem_craft.previous_qnt, price: @gem_craft.price }
|
||||
assert_redirected_to gem_craft_path(assigns(:gem_craft))
|
||||
end
|
||||
|
||||
test "should destroy gem_craft" do
|
||||
assert_difference('GemCraft.count', -1) do
|
||||
delete :destroy, id: @gem_craft
|
||||
end
|
||||
|
||||
assert_redirected_to gem_crafts_path
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
||||
|
||||
one:
|
||||
name: MyString
|
||||
price: 1
|
||||
books_type: 1
|
||||
books_qnt: 1
|
||||
previous_id: 1
|
||||
previous_qnt: 1
|
||||
|
||||
two:
|
||||
name: MyString
|
||||
price: 1
|
||||
books_type: 1
|
||||
books_qnt: 1
|
||||
previous_id: 1
|
||||
previous_qnt: 1
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
require 'test_helper'
|
||||
|
||||
class GemCraftsHelperTest < ActionView::TestCase
|
||||
end
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
require 'test_helper'
|
||||
|
||||
class GemCraftTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
Loading…
Reference in New Issue