Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2331b9a

Browse files
authored
Merge pull request #13 from dfelczak/employees
update seeds
2 parents 3132d60 + e3dfd54 commit 2331b9a

File tree

10 files changed

+137
-3
lines changed

10 files changed

+137
-3
lines changed

‎app/controllers/employees_controller.rb

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

‎app/models/employee.rb

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

‎app/resources/employee_resource.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class EmployeeResource < JSONAPI::Resource
2+
attributes :title, :created_at, :first_name
3+
end

‎config/routes.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
jsonapi_resources :products
77
jsonapi_resources :users
88
jsonapi_resources :roles
9+
jsonapi_resources :employees
910
jsonapi_resources :orders
1011
jsonapi_resources :customers
1112
jsonapi_resources :suppliers
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
class AddEmployeeTable < ActiveRecord::Migration[5.0]
2+
def change
3+
create_table :employees do |t|
4+
t.string :last_name
5+
t.string :first_name
6+
t.string :title
7+
t.string :title_of_courtesy
8+
t.date :birth_date
9+
t.date :hire_date
10+
t.string :address
11+
t.string :city
12+
t.string :region
13+
t.string :postal_code
14+
t.string :country
15+
t.string :home_phone
16+
t.string :extension
17+
t.string :photo
18+
t.text :notes
19+
t.integer :reports_to
20+
t.datetime :created_at
21+
t.datetime :updated_at
22+
end
23+
end
24+
end

‎db/seeds.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,7 @@
3232
20.times do |n|
3333
FactoryGirl.create(:product)
3434
end
35+
36+
20.times do |n|
37+
FactoryGirl.create(:employee)
38+
end

‎db/structure.sql

Lines changed: 65 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
-- PostgreSQL database dump
33
--
44

5-
-- Dumped from database version 9.6.2
6-
-- Dumped by pg_dump version 9.6.2
5+
-- Dumped from database version 9.6.3
6+
-- Dumped by pg_dump version 9.6.3
77

88
SET statement_timeout = 0;
99
SET lock_timeout = 0;
@@ -109,6 +109,52 @@ CREATE SEQUENCE comments_id_seq
109109
ALTER SEQUENCE comments_id_seq OWNED BY comments.id;
110110

111111

112+
--
113+
-- Name: employees; Type: TABLE; Schema: public; Owner: -
114+
--
115+
116+
CREATE TABLE employees (
117+
id integer NOT NULL,
118+
last_name character varying,
119+
first_name character varying,
120+
title character varying,
121+
title_of_courtesy character varying,
122+
birth_date date,
123+
hire_date date,
124+
address character varying,
125+
city character varying,
126+
region character varying,
127+
postal_code character varying,
128+
country character varying,
129+
home_phone character varying,
130+
extension character varying,
131+
photo character varying,
132+
notes text,
133+
reports_to integer,
134+
created_at timestamp without time zone,
135+
updated_at timestamp without time zone
136+
);
137+
138+
139+
--
140+
-- Name: employees_id_seq; Type: SEQUENCE; Schema: public; Owner: -
141+
--
142+
143+
CREATE SEQUENCE employees_id_seq
144+
START WITH 1
145+
INCREMENT BY 1
146+
NO MINVALUE
147+
NO MAXVALUE
148+
CACHE 1;
149+
150+
151+
--
152+
-- Name: employees_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
153+
--
154+
155+
ALTER SEQUENCE employees_id_seq OWNED BY employees.id;
156+
157+
112158
--
113159
-- Name: posts; Type: TABLE; Schema: public; Owner: -
114160
--
@@ -255,6 +301,13 @@ ALTER TABLE ONLY categories ALTER COLUMN id SET DEFAULT nextval('categories_id_s
255301
ALTER TABLE ONLY comments ALTER COLUMN id SET DEFAULT nextval('comments_id_seq'::regclass);
256302

257303

304+
--
305+
-- Name: employees id; Type: DEFAULT; Schema: public; Owner: -
306+
--
307+
308+
ALTER TABLE ONLY employees ALTER COLUMN id SET DEFAULT nextval('employees_id_seq'::regclass);
309+
310+
258311
--
259312
-- Name: posts id; Type: DEFAULT; Schema: public; Owner: -
260313
--
@@ -300,6 +353,14 @@ ALTER TABLE ONLY comments
300353
ADD CONSTRAINT comments_pkey PRIMARY KEY (id);
301354

302355

356+
--
357+
-- Name: employees employees_pkey; Type: CONSTRAINT; Schema: public; Owner: -
358+
--
359+
360+
ALTER TABLE ONLY employees
361+
ADD CONSTRAINT employees_pkey PRIMARY KEY (id);
362+
363+
303364
--
304365
-- Name: posts posts_pkey; Type: CONSTRAINT; Schema: public; Owner: -
305366
--
@@ -423,6 +484,7 @@ INSERT INTO "schema_migrations" (version) VALUES
423484
('20170328194726'),
424485
('20170418135338'),
425486
('20170504204400'),
426-
('20170508090812');
487+
('20170508090812'),
488+
('20170516130923');
427489

428490

‎spec/factories/employee.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FactoryGirl.define do
2+
factory :employee do
3+
last_name { Faker::Name.last_name }
4+
first_name { Faker::Name.first_name }
5+
title { Faker::Name.title }
6+
title_of_courtesy { Faker::Name.title }
7+
birth_date { Faker::Date.backward(720) }
8+
hire_date { Faker::Date.backward(10) }
9+
address { Faker::Address.street_address }
10+
city { Faker::Address.city }
11+
region { Faker::Address.state }
12+
postal_code { Faker::Address.postcode }
13+
country { Faker::Address.country }
14+
home_phone { Faker::PhoneNumber.phone_number }
15+
extension { 'jpg' }
16+
photo { Faker::Placeholdit.image("50x50") }
17+
notes { Faker::Lorem.paragraph }
18+
created_at { Faker::Date.backward(20) }
19+
updated_at { Faker::Date.backward(15) }
20+
end
21+
end
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
require 'test_helper'
2+
3+
class CategoryControllerTest < ActionDispatch::IntegrationTest
4+
# test "the truth" do
5+
# assert true
6+
# end
7+
end
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
require 'test_helper'
2+
3+
class EmployeeControllerTest < ActionDispatch::IntegrationTest
4+
# test "the truth" do
5+
# assert true
6+
# end
7+
end

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /