Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/controllers/suppliers_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class SuppliersController < AuthorizedController
end
2 changes: 2 additions & 0 deletions app/models/supplier.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Supplier < ApplicationRecord
end
13 changes: 13 additions & 0 deletions app/resources/supplier_resource.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class SupplierResource < JSONAPI::Resource
attributes :company_name,
:contact_name,
:contact_title,
:address,
:city,
:region,
:postal_code,
:country,
:phone,
:fax,
:home_page
end
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
jsonapi_resources :posts
jsonapi_resources :users
jsonapi_resources :roles
jsonapi_resources :suppliers
end
18 changes: 18 additions & 0 deletions db/migrate/20170516131023_create_suppliers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class CreateSuppliers < ActiveRecord::Migration[5.0]
def change
create_table(:suppliers) do |t|
t.string :company_name
t.string :contact_name
t.string :contact_title
t.string :address
t.string :city
t.string :region
t.string :postal_code
t.string :country
t.string :phone
t.string :fax
t.text :home_page
t.timestamps
end
end
end
4 changes: 4 additions & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@
tokens: nil
).add_role n == 0 ? :admin : :user
end

25.times do |n|
FactoryGirl.create(:supplier)
end
15 changes: 15 additions & 0 deletions spec/factories/supplier.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FactoryGirl.define do
factory :supplier do
company_name { Faker::Company.name }
contact_name { Faker::Name.name }
contact_title { Faker::Name.title }
address { Faker::Address.street_address }
city { Faker::Address.city }
region { Faker::Address.state }
postal_code { Faker::Address.postcode }
country { Faker::Address.country }
phone { Faker::PhoneNumber.cell_phone }
fax { Faker::PhoneNumber.cell_phone }
home_page { "http://#{Faker::Company.name}.com" }
end
end