Skip to content

Commit 82146f6

Browse files
committed
Order initialize
1 parent f369b8a commit 82146f6

File tree

8 files changed

+51
-6
lines changed

8 files changed

+51
-6
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class CategoryController < ApplicationController
2+
end

app/controllers/orders_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class OrdersController < AuthorizedController
2+
end

app/models/order.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class Order < ApplicationRecord
2+
end

app/resources/order_resource.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class OrderResource < JSONAPI::Resource
2+
attributes :order_date, :required_date, :shipped_date, :ship_via, :freight, :ship_name, :ship_address, :ship_city,
3+
:ship_region, :ship_postal_code, :ship_country
4+
end

config/routes.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
jsonapi_resources :posts
66
jsonapi_resources :users
77
jsonapi_resources :roles
8+
jsonapi_resources :orders
89
end
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class CreateOrders < ActiveRecord::Migration[5.0]
2+
def change
3+
create_table :orders do |t|
4+
t.date :order_date
5+
t.date :required_date
6+
t.date :shipped_date
7+
t.integer :ship_via
8+
t.float :freight
9+
t.string :ship_name
10+
t.string :ship_address
11+
t.string :ship_city
12+
t.string :ship_region
13+
t.string :ship_postal_code
14+
t.string :ship_country
15+
t.timestamps
16+
end
17+
end
18+
end

db/seeds.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
end
1414

1515
25.times do |n|
16-
User.create!(
17-
email: "user#{n}@example.com",
18-
password: 'Secret123',
19-
confirmed_at: Time.now,
20-
tokens: nil
21-
).add_role n == 0 ? :admin : :user
16+
u = User.create!(email: "user#{n}@example.com", password: 'Secret123', confirmed_at: Time.now)
17+
u.add_role n == 0 ? :admin : :user
2218
end
19+
20+
25.times do |n|
21+
FactoryGirl.create(:order)
22+
end
23+

spec/factories/order.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FactoryGirl.define do
2+
factory :order do
3+
order_date { Faker::Date.between(10.days.ago, Date.today) }
4+
required_date { Faker::Date.between(10.days.ago, Date.today) }
5+
shipped_date { Faker::Date.between(10.days.ago, Date.today) }
6+
ship_via { 'DHL' }
7+
freight { rand(1000) }
8+
ship_name { 'Titanic' }
9+
ship_address { Faker::Address.street_name }
10+
ship_city { Faker::Address.city }
11+
ship_region { Faker::Address.state }
12+
ship_postal_code { Faker::Address.zip }
13+
ship_country { Faker::Address.country }
14+
end
15+
end

0 commit comments

Comments
 (0)