jobshop 0.0.167 → 0.0.179
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -2
- data/Rakefile +2 -1
- data/app/assets/javascripts/application.js +1 -0
- data/app/controllers/jobshop/application_controller.rb +3 -1
- data/app/controllers/jobshop/dashboards_controller.rb +11 -0
- data/app/controllers/jobshop/departments_controller.rb +52 -0
- data/app/controllers/jobshop/employees_controller.rb +77 -0
- data/app/controllers/jobshop/organizations_controller.rb +29 -0
- data/app/controllers/jobshop/rfqs_controller.rb +49 -0
- data/app/controllers/jobshop/roles_controller.rb +52 -0
- data/app/helpers/jobshop/application_helper.rb +10 -0
- data/app/listeners/jobshop/assignment_listener.rb +13 -0
- data/app/mailers/jobshop/rfq_responder_mailer.rb +1 -1
- data/app/models/jobshop/auditing.rb +20 -0
- data/app/models/jobshop/collection.rb +2 -7
- data/app/models/jobshop/customer.rb +6 -17
- data/app/models/jobshop/customer/category.rb +2 -8
- data/app/models/jobshop/customer/contact.rb +3 -8
- data/app/models/jobshop/department.rb +10 -0
- data/app/models/jobshop/department/assignment.rb +15 -0
- data/app/models/jobshop/employee.rb +13 -6
- data/app/models/jobshop/employment.rb +8 -8
- data/app/models/jobshop/inspection.rb +1 -1
- data/app/models/jobshop/inspection/boolean_criterion.rb +13 -17
- data/app/models/jobshop/inspection/criterion.rb +9 -10
- data/app/models/jobshop/inspection/deviation_criterion.rb +10 -12
- data/app/models/jobshop/inspection/limit_criterion.rb +12 -10
- data/app/models/jobshop/inspection/report.rb +22 -34
- data/app/models/jobshop/mailman.rb +2 -4
- data/app/models/jobshop/order.rb +3 -27
- data/app/models/jobshop/order_line.rb +4 -10
- data/app/models/jobshop/organization.rb +8 -15
- data/app/models/jobshop/organization_state.rb +10 -0
- data/app/models/jobshop/place.rb +3 -8
- data/app/models/jobshop/product.rb +4 -7
- data/app/models/jobshop/rfq.rb +32 -14
- data/app/models/jobshop/rfq/line.rb +28 -0
- data/app/models/jobshop/rfq/line/assignment.rb +25 -0
- data/app/models/jobshop/rfq/line/quantity.rb +23 -0
- data/app/models/jobshop/role.rb +3 -9
- data/app/models/jobshop/role_assignment.rb +10 -4
- data/app/models/jobshop/routing_process.rb +4 -10
- data/app/models/jobshop/routing_step.rb +3 -5
- data/app/models/jobshop/thing.rb +3 -8
- data/app/models/jobshop/user.rb +24 -11
- data/app/views/jobshop/dashboards/show.html.haml +35 -0
- data/app/views/jobshop/departments/_form.html.haml +12 -0
- data/app/views/jobshop/departments/edit.html.haml +7 -0
- data/app/views/jobshop/departments/index.html.haml +17 -0
- data/app/views/jobshop/departments/new.html.haml +5 -0
- data/app/views/jobshop/departments/show.html.haml +15 -0
- data/app/views/jobshop/employees/_form.html.haml +46 -0
- data/app/views/jobshop/employees/edit.html.haml +1 -0
- data/app/views/jobshop/employees/index.html.haml +12 -0
- data/app/views/jobshop/employees/new.html.haml +1 -0
- data/app/views/jobshop/employees/show.html.haml +16 -0
- data/app/views/jobshop/organizations/_form.html.haml +10 -0
- data/app/views/jobshop/organizations/edit.html.haml +7 -0
- data/app/views/jobshop/organizations/index.html.haml +19 -0
- data/app/views/jobshop/organizations/new.html.haml +5 -0
- data/app/views/jobshop/organizations/show.html.haml +16 -0
- data/app/views/jobshop/rfqs/_form.html.haml +60 -0
- data/app/views/jobshop/rfqs/edit.html.haml +4 -0
- data/app/views/jobshop/rfqs/index.html.haml +2 -0
- data/app/views/jobshop/roles/_form.html.haml +11 -0
- data/app/views/jobshop/roles/edit.html.haml +7 -0
- data/app/views/jobshop/roles/index.html.haml +21 -0
- data/app/views/jobshop/roles/new.html.haml +5 -0
- data/app/views/jobshop/roles/show.html.haml +3 -0
- data/app/views/layouts/jobshop/application.html.haml +50 -2
- data/config/initializers/devise.rb +2 -2
- data/config/routes.rb +18 -0
- data/db/migrate/20170311194758_initialize_jobshop.rb +4 -39
- data/db/migrate/20171216021339_create_organizations.rb +3 -8
- data/db/migrate/20171216021350_create_users.rb +28 -0
- data/db/migrate/20171216021400_create_employees.rb +27 -9
- data/db/migrate/20171216021853_create_customers.rb +29 -14
- data/db/migrate/20171216022020_create_places.rb +3 -4
- data/db/migrate/20171216022135_create_products.rb +4 -4
- data/db/migrate/20171216022605_create_orders.rb +27 -13
- data/db/migrate/20171216023018_create_roles.rb +30 -27
- data/db/migrate/20171216035357_create_things.rb +26 -23
- data/db/migrate/20171219022118_create_routing_processes.rb +28 -33
- data/db/migrate/20180107203241_create_inspections.rb +48 -115
- data/db/migrate/20181117023949_create_rfqs.rb +74 -15
- data/db/migrate/20181118014603_create_mailmen.rb +5 -6
- data/db/migrate/20190309163306_create_departments.rb +38 -0
- data/db/migrate/support/temporal_tables.sql +210 -0
- data/db/seeds.rb +92 -64
- data/exe/jobshop +1 -0
- data/lib/generators/jobshop/app/app_generator.rb +13 -3
- data/lib/generators/jobshop/app/templates/Procfile.tt +1 -1
- data/lib/generators/jobshop/app/templates/config/databases/postgresql.yml.tt +24 -0
- data/lib/generators/jobshop/app/templates/config/puma.rb.tt +44 -0
- data/lib/generators/jobshop/canary/canary_generator.rb +21 -9
- data/lib/generators/jobshop/dev_cert/dev_cert_generator.rb +124 -0
- data/lib/jobshop.rb +1 -1
- data/lib/jobshop/cli.rb +3 -3
- data/lib/jobshop/cli/app_generator.rb +15 -10
- data/lib/jobshop/cli/application.rb +7 -7
- data/lib/jobshop/cli/base.rb +65 -0
- data/lib/jobshop/cli/canary.rb +120 -22
- data/lib/jobshop/configuration.rb +1 -1
- data/lib/jobshop/engine.rb +8 -4
- data/lib/jobshop/helpers/migration.rb +27 -66
- data/lib/jobshop/mailroom/base_handler.rb +1 -1
- data/lib/jobshop/mailroom/null_handler.rb +1 -1
- data/lib/jobshop/mailroom/postmaster.rb +1 -1
- data/lib/jobshop/mailroom/rfq_handler.rb +1 -1
- data/lib/jobshop/version.rb +2 -2
- data/lib/tasks/jobshop_tasks.rake +15 -1
- metadata +114 -61
- data/app/controllers/jobshop/organizations/lookups_controller.rb +0 -18
- data/app/models/jobshop/employment_version.rb +0 -10
- data/app/models/jobshop/inspection/result.rb +0 -46
- data/app/models/jobshop/inspection/tuple.rb +0 -17
- data/app/models/jobshop/rfq_line.rb +0 -12
- data/db/migrate/20171216021554_create_people.rb +0 -43
- data/lib/generators/jobshop/app/templates/config/database.yml.tt +0 -19
@@ -0,0 +1,210 @@
|
|
1
|
+
/* The MIT License (MIT)
|
2
|
+
**
|
3
|
+
** Copyright (c) 2016-2017 Nearform and contributors
|
4
|
+
**
|
5
|
+
** Contributors listed at https://github.com/nearform/temporal_tables#the-team
|
6
|
+
** and in the README file.
|
7
|
+
**
|
8
|
+
** Permission is hereby granted, free of charge, to any person obtaining a copy
|
9
|
+
** of this software and associated documentation files (the "Software"), to deal
|
10
|
+
** in the Software without restriction, including without limitation the rights
|
11
|
+
** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
12
|
+
** copies of the Software, and to permit persons to whom the Software is
|
13
|
+
** furnished to do so, subject to the following conditions:
|
14
|
+
**
|
15
|
+
** The above copyright notice and this permission notice shall be included in
|
16
|
+
** all copies or substantial portions of the Software.
|
17
|
+
**
|
18
|
+
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
19
|
+
** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
20
|
+
** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
21
|
+
** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
22
|
+
** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
23
|
+
** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
24
|
+
** SOFTWARE.
|
25
|
+
*/
|
26
|
+
|
27
|
+
CREATE OR REPLACE FUNCTION versioning() RETURNS TRIGGER AS $$
|
28
|
+
DECLARE
|
29
|
+
sys_period text;
|
30
|
+
history_table text;
|
31
|
+
manipulate jsonb;
|
32
|
+
commonColumns text[];
|
33
|
+
time_stamp_to_use timestamptz := current_timestamp;
|
34
|
+
range_lower timestamptz;
|
35
|
+
transaction_info txid_snapshot;
|
36
|
+
existing_range tstzrange;
|
37
|
+
holder record;
|
38
|
+
holder2 record;
|
39
|
+
pg_version integer;
|
40
|
+
BEGIN
|
41
|
+
|
42
|
+
IF (TG_WHEN != 'BEFORE') OR (TG_LEVEL != 'ROW' ) THEN
|
43
|
+
RAISE TRIGGER_PROTOCOL_VIOLATED USING
|
44
|
+
MESSAGE = 'function "versioning" must be fired BEFORE ROW';
|
45
|
+
END IF;
|
46
|
+
|
47
|
+
IF TG_OP != 'INSERT' AND TG_OP != 'UPDATE' AND TG_OP != 'DELETE' THEN
|
48
|
+
RAISE TRIGGER_PROTOCOL_VIOLATED USING
|
49
|
+
MESSAGE = 'function "versioning" must be fired for INSERT or UPDATE or DELETE';
|
50
|
+
END IF;
|
51
|
+
|
52
|
+
IF TG_NARGS != 3 THEN
|
53
|
+
RAISE INVALID_PARAMETER_VALUE USING
|
54
|
+
MESSAGE = 'wrong number of parameters for function "versioning"',
|
55
|
+
HINT = 'expected 3 parameters but got ' || TG_NARGS;
|
56
|
+
END IF;
|
57
|
+
|
58
|
+
sys_period := TG_ARGV[0];
|
59
|
+
history_table := TG_ARGV[1];
|
60
|
+
|
61
|
+
-- check if sys_period exists on original table
|
62
|
+
SELECT atttypid, attndims INTO holder FROM pg_attribute WHERE attrelid = TG_RELID AND attname = sys_period AND NOT attisdropped;
|
63
|
+
IF NOT FOUND THEN
|
64
|
+
RAISE 'column "%" of relation "%" does not exist', sys_period, TG_TABLE_NAME USING
|
65
|
+
ERRCODE = 'undefined_column';
|
66
|
+
END IF;
|
67
|
+
IF holder.atttypid != to_regtype('tstzrange') THEN
|
68
|
+
IF holder.attndims > 0 THEN
|
69
|
+
RAISE 'system period column "%" of relation "%" is not a range but an array', sys_period, TG_TABLE_NAME USING
|
70
|
+
ERRCODE = 'datatype_mismatch';
|
71
|
+
END IF;
|
72
|
+
|
73
|
+
SELECT rngsubtype INTO holder2 FROM pg_range WHERE rngtypid = holder.atttypid;
|
74
|
+
IF FOUND THEN
|
75
|
+
RAISE 'system period column "%" of relation "%" is not a range of timestamp with timezone but of type %', sys_period, TG_TABLE_NAME, format_type(holder2.rngsubtype, null) USING
|
76
|
+
ERRCODE = 'datatype_mismatch';
|
77
|
+
END IF;
|
78
|
+
|
79
|
+
RAISE 'system period column "%" of relation "%" is not a range but type %', sys_period, TG_TABLE_NAME, format_type(holder.atttypid, null) USING
|
80
|
+
ERRCODE = 'datatype_mismatch';
|
81
|
+
END IF;
|
82
|
+
|
83
|
+
IF TG_OP = 'UPDATE' OR TG_OP = 'DELETE' THEN
|
84
|
+
-- Ignore rows already modified in this transaction
|
85
|
+
transaction_info := txid_current_snapshot();
|
86
|
+
IF OLD.xmin::text >= (txid_snapshot_xmin(transaction_info) % (2^32)::bigint)::text
|
87
|
+
AND OLD.xmin::text <= (txid_snapshot_xmax(transaction_info) % (2^32)::bigint)::text THEN
|
88
|
+
IF TG_OP = 'DELETE' THEN
|
89
|
+
RETURN OLD;
|
90
|
+
END IF;
|
91
|
+
|
92
|
+
RETURN NEW;
|
93
|
+
END IF;
|
94
|
+
|
95
|
+
SELECT current_setting('server_version_num')::integer
|
96
|
+
INTO pg_version;
|
97
|
+
|
98
|
+
-- to support postgres < 9.6
|
99
|
+
IF pg_version < 90600 THEN
|
100
|
+
-- check if history table exits
|
101
|
+
IF to_regclass(history_table::cstring) IS NULL THEN
|
102
|
+
RAISE 'relation "%" does not exist', history_table;
|
103
|
+
END IF;
|
104
|
+
ELSE
|
105
|
+
IF to_regclass(history_table) IS NULL THEN
|
106
|
+
RAISE 'relation "%" does not exist', history_table;
|
107
|
+
END IF;
|
108
|
+
END IF;
|
109
|
+
|
110
|
+
-- check if history table has sys_period
|
111
|
+
IF NOT EXISTS(SELECT * FROM pg_attribute WHERE attrelid = history_table::regclass AND attname = sys_period AND NOT attisdropped) THEN
|
112
|
+
RAISE 'history relation "%" does not contain system period column "%"', history_table, sys_period USING
|
113
|
+
HINT = 'history relation must contain system period column with the same name and data type as the versioned one';
|
114
|
+
END IF;
|
115
|
+
|
116
|
+
EXECUTE format('SELECT $1.%I', sys_period) USING OLD INTO existing_range;
|
117
|
+
|
118
|
+
IF existing_range IS NULL THEN
|
119
|
+
RAISE 'system period column "%" of relation "%" must not be null', sys_period, TG_TABLE_NAME USING
|
120
|
+
ERRCODE = 'null_value_not_allowed';
|
121
|
+
END IF;
|
122
|
+
|
123
|
+
IF isempty(existing_range) OR NOT upper_inf(existing_range) THEN
|
124
|
+
RAISE 'system period column "%" of relation "%" contains invalid value', sys_period, TG_TABLE_NAME USING
|
125
|
+
ERRCODE = 'data_exception',
|
126
|
+
DETAIL = 'valid ranges must be non-empty and unbounded on the high side';
|
127
|
+
END IF;
|
128
|
+
|
129
|
+
IF TG_ARGV[2] = 'true' THEN
|
130
|
+
-- mitigate update conflicts
|
131
|
+
range_lower := lower(existing_range);
|
132
|
+
IF range_lower >= time_stamp_to_use THEN
|
133
|
+
time_stamp_to_use := range_lower + interval '1 microseconds';
|
134
|
+
END IF;
|
135
|
+
END IF;
|
136
|
+
|
137
|
+
WITH history AS
|
138
|
+
(SELECT attname, atttypid
|
139
|
+
FROM pg_attribute
|
140
|
+
WHERE attrelid = history_table::regclass
|
141
|
+
AND attnum > 0
|
142
|
+
AND NOT attisdropped),
|
143
|
+
main AS
|
144
|
+
(SELECT attname, atttypid
|
145
|
+
FROM pg_attribute
|
146
|
+
WHERE attrelid = TG_RELID
|
147
|
+
AND attnum > 0
|
148
|
+
AND NOT attisdropped)
|
149
|
+
SELECT
|
150
|
+
history.attname AS history_name,
|
151
|
+
main.attname AS main_name,
|
152
|
+
history.atttypid AS history_type,
|
153
|
+
main.atttypid AS main_type
|
154
|
+
INTO holder
|
155
|
+
FROM history
|
156
|
+
INNER JOIN main
|
157
|
+
ON history.attname = main.attname
|
158
|
+
WHERE
|
159
|
+
history.atttypid != main.atttypid;
|
160
|
+
|
161
|
+
IF FOUND THEN
|
162
|
+
RAISE 'column "%" of relation "%" is of type % but column "%" of history relation "%" is of type %',
|
163
|
+
holder.main_name, TG_TABLE_NAME, format_type(holder.main_type, null), holder.history_name, history_table, format_type(holder.history_type, null)
|
164
|
+
USING ERRCODE = 'datatype_mismatch';
|
165
|
+
END IF;
|
166
|
+
|
167
|
+
WITH history AS
|
168
|
+
(SELECT attname
|
169
|
+
FROM pg_attribute
|
170
|
+
WHERE attrelid = history_table::regclass
|
171
|
+
AND attnum > 0
|
172
|
+
AND NOT attisdropped),
|
173
|
+
main AS
|
174
|
+
(SELECT attname
|
175
|
+
FROM pg_attribute
|
176
|
+
WHERE attrelid = TG_RELID
|
177
|
+
AND attnum > 0
|
178
|
+
AND NOT attisdropped)
|
179
|
+
SELECT array_agg(quote_ident(history.attname)) INTO commonColumns
|
180
|
+
FROM history
|
181
|
+
INNER JOIN main
|
182
|
+
ON history.attname = main.attname
|
183
|
+
AND history.attname != sys_period;
|
184
|
+
|
185
|
+
EXECUTE ('INSERT INTO ' ||
|
186
|
+
CASE split_part(history_table, '.', 2)
|
187
|
+
WHEN '' THEN
|
188
|
+
quote_ident(history_table)
|
189
|
+
ELSE
|
190
|
+
quote_ident(split_part(history_table, '.', 1)) || '.' || quote_ident(split_part(history_table, '.', 2))
|
191
|
+
END ||
|
192
|
+
'(' ||
|
193
|
+
array_to_string(commonColumns , ',') ||
|
194
|
+
',' ||
|
195
|
+
quote_ident(sys_period) ||
|
196
|
+
') VALUES ($1.' ||
|
197
|
+
array_to_string(commonColumns, ',$1.') ||
|
198
|
+
',tstzrange($2, $3, ''[)''))')
|
199
|
+
USING OLD, range_lower, time_stamp_to_use;
|
200
|
+
END IF;
|
201
|
+
|
202
|
+
IF TG_OP = 'UPDATE' OR TG_OP = 'INSERT' THEN
|
203
|
+
manipulate := jsonb_set('{}'::jsonb, ('{' || sys_period || '}')::text[], to_jsonb(tstzrange(time_stamp_to_use, null, '[)')));
|
204
|
+
|
205
|
+
RETURN jsonb_populate_record(NEW, manipulate);
|
206
|
+
END IF;
|
207
|
+
|
208
|
+
RETURN OLD;
|
209
|
+
END;
|
210
|
+
$$ LANGUAGE plpgsql;
|
data/db/seeds.rb
CHANGED
@@ -1,24 +1,22 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
ENV["RAILS_ENV"] ||= "development"
|
4
|
+
|
5
|
+
require "benchmark"
|
2
6
|
|
3
7
|
def factory_paths
|
4
8
|
[ Jobshop::Engine.root.join("spec/factories") ]
|
5
9
|
end
|
6
10
|
|
7
|
-
private def clean_database
|
8
|
-
require "database_cleaner"
|
9
|
-
DatabaseCleaner.strategy = :truncation
|
10
|
-
DatabaseCleaner.clean
|
11
|
-
end
|
12
|
-
|
13
11
|
def do_with_spinner(name, &block)
|
12
|
+
retval = nil
|
14
13
|
title = "[:spinner] #{name.ljust(40, '.')}"
|
15
14
|
spinner = TTY::Spinner.new(title, format: :dots)
|
16
15
|
spinner.auto_spin
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
spinner.success("done (#{delta}s)")
|
16
|
+
time = Benchmark.realtime do
|
17
|
+
retval = yield
|
18
|
+
end
|
19
|
+
spinner.success("done in #{(time * 1000).round(0)}ms")
|
22
20
|
retval
|
23
21
|
end
|
24
22
|
|
@@ -28,18 +26,51 @@ do_with_spinner("Loading factories") do
|
|
28
26
|
FactoryBot.find_definitions if Rails.env.development?
|
29
27
|
end
|
30
28
|
|
31
|
-
do_with_spinner("
|
32
|
-
|
29
|
+
@org = do_with_spinner("Creating Organization") do
|
30
|
+
FactoryBot.create(:organization)
|
33
31
|
end
|
34
32
|
|
35
|
-
|
36
|
-
FactoryBot.create(:
|
33
|
+
do_with_spinner("Creating Departments") do
|
34
|
+
@accounting = FactoryBot.create(:department, {
|
35
|
+
name: "Accounting", organization: @org
|
36
|
+
})
|
37
|
+
|
38
|
+
@engineering = FactoryBot.create(:department, {
|
39
|
+
name: "Engineering", organization: @org
|
40
|
+
})
|
41
|
+
|
42
|
+
@hr = FactoryBot.create(:department, {
|
43
|
+
name: "Human Resources", organization: @org
|
44
|
+
})
|
45
|
+
|
46
|
+
@manufacturing = FactoryBot.create(:department, {
|
47
|
+
name: "Manufacturing", organization: @org
|
48
|
+
})
|
49
|
+
|
50
|
+
@quality = FactoryBot.create(:department, {
|
51
|
+
name: "Quality", organization: @org
|
52
|
+
})
|
53
|
+
|
54
|
+
@sales = FactoryBot.create(:department, {
|
55
|
+
name: "Sales", organization: @org
|
56
|
+
})
|
57
|
+
|
58
|
+
@sr = FactoryBot.create(:department, {
|
59
|
+
name: "Sales", organization: @org
|
60
|
+
})
|
37
61
|
end
|
38
62
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
63
|
+
do_with_spinner("Creating Employees") do
|
64
|
+
@salesmen = { }
|
65
|
+
@salesmen[:thomas] = FactoryBot.create(:salesman, organization: @org, departments: [ @sales ])
|
66
|
+
@salesmen[:richard] = FactoryBot.create(:salesman, organization: @org, departments: [ @sales ])
|
67
|
+
@salesmen[:harold] = FactoryBot.create(:salesman, organization: @org, departments: [ @sales ])
|
68
|
+
|
69
|
+
@engineers = { }
|
70
|
+
@engineers[:joe] = FactoryBot.create(:engineer, organization: @org, departments: [ @engineering ])
|
71
|
+
@engineers[:jim] = FactoryBot.create(:engineer, organization: @org, departments: [ @engineering ])
|
72
|
+
|
73
|
+
@hr1 = FactoryBot.create(:hr_specialist, organization: @org, departments: [ @hr ])
|
43
74
|
end
|
44
75
|
|
45
76
|
@places = do_with_spinner("Creating test Places") do
|
@@ -47,80 +78,77 @@ end
|
|
47
78
|
end
|
48
79
|
|
49
80
|
@customers = do_with_spinner("Creating test customers") do
|
50
|
-
FactoryBot.create_list(:customer, 10, organization: @org)
|
51
|
-
#created_by: @ceo)
|
81
|
+
FactoryBot.create_list(:customer, 10, organization: @org)
|
52
82
|
end
|
53
83
|
|
54
84
|
@products = do_with_spinner("Creating test Products") do
|
55
|
-
FactoryBot.create_list(:product, 10,
|
56
|
-
organization: @org)#,
|
57
|
-
#created_by: @ceo)
|
85
|
+
FactoryBot.create_list(:product, 10, organization: @org)
|
58
86
|
end
|
59
87
|
|
60
88
|
do_with_spinner("Creating test Routers for Products") do
|
61
89
|
@products.each do |product|
|
62
|
-
rp = FactoryBot.create(:routing_process,
|
63
|
-
|
64
|
-
|
65
|
-
|
90
|
+
rp = FactoryBot.create(:routing_process, {
|
91
|
+
organization: @org, product: product
|
92
|
+
})
|
93
|
+
|
94
|
+
FactoryBot.create_list(:routing_step, rand(1..4), {
|
95
|
+
organization: @org, routing_process: rp
|
96
|
+
})
|
66
97
|
end
|
67
98
|
end
|
68
99
|
|
69
100
|
do_with_spinner("Creating sample Orders") do
|
70
|
-
|
71
|
-
ord = FactoryBot.create(:order,
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
101
|
+
10.times do
|
102
|
+
ord = FactoryBot.create(:order, {
|
103
|
+
organization: @org, customer: @customers.sample
|
104
|
+
})
|
105
|
+
|
106
|
+
FactoryBot.create_list(:order_line, rand(1..4), {
|
107
|
+
organization: @org, order: ord, product: @products.sample
|
108
|
+
})
|
78
109
|
end
|
79
110
|
end
|
80
111
|
|
81
112
|
@widgets = do_with_spinner("Creating Collection of widgets") do
|
82
|
-
wc = FactoryBot.create(:widget_collection,
|
83
|
-
|
84
|
-
FactoryBot.create_list(:widget_thing, 50, organization: @org,
|
85
|
-
collection: wc)
|
113
|
+
wc = FactoryBot.create(:widget_collection, organization: @org)
|
114
|
+
FactoryBot.create_list(:widget_thing, 50, organization: @org, collection: wc)
|
86
115
|
end
|
87
116
|
|
88
117
|
@widget_packs = do_with_spinner("Creating Collection of widget packs") do
|
89
|
-
wpc = FactoryBot.create(:widget_pack_collection,
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
widgets: @widgets)
|
118
|
+
wpc = FactoryBot.create(:widget_pack_collection, organization: @org)
|
119
|
+
FactoryBot.create_list(:widget_pack_thing, 50, {
|
120
|
+
organization: @org, collection: wpc, widgets: @widgets
|
121
|
+
})
|
94
122
|
end
|
95
123
|
|
96
124
|
do_with_spinner("Creating Inspection Reports") do
|
97
125
|
5.times do
|
98
126
|
report = FactoryBot.create(:inspection_report, organization: @org)
|
99
|
-
|
100
|
-
FactoryBot.create(
|
101
|
-
|
102
|
-
|
103
|
-
end
|
104
|
-
5.times do |index|
|
105
|
-
tuple = FactoryBot.create(:inspection_tuple, organization: @org,
|
106
|
-
report: report, position: (index + 1))
|
107
|
-
report.criteria.each do |criterion|
|
108
|
-
FactoryBot.create(:inspection_result, organization: @org,
|
109
|
-
report: report, criterion: criterion,
|
110
|
-
tuple: tuple)
|
111
|
-
end
|
127
|
+
Jobshop::Inspection::CRITERION_TYPES.each_with_index do |type, index|
|
128
|
+
FactoryBot.create(type, {
|
129
|
+
organization: @org, report: report, position: (index + 1)
|
130
|
+
})
|
112
131
|
end
|
113
132
|
end
|
114
133
|
end
|
115
134
|
|
116
135
|
do_with_spinner("Creating RFQ Mailman") do
|
117
|
-
@org.mailmen.create
|
118
|
-
|
136
|
+
@org.mailmen.create({
|
137
|
+
address: "rfq@jobshop.io", handler_type: "Jobshop::Mailroom::RFQHandler"
|
138
|
+
})
|
119
139
|
end
|
120
140
|
|
121
141
|
do_with_spinner("Creating sample RFQs") do
|
122
|
-
|
123
|
-
|
124
|
-
|
142
|
+
10.times do
|
143
|
+
case rand(0..100) % 3
|
144
|
+
when 0
|
145
|
+
FactoryBot.create :rfq, :verified, organization: @org,
|
146
|
+
customer: @customers.sample
|
147
|
+
when 1
|
148
|
+
FactoryBot.create :rfq, :verifiable, organization: @org,
|
149
|
+
customer: @customers.sample
|
150
|
+
when 2
|
151
|
+
FactoryBot.create :rfq, :unverifiable, organization: @org
|
152
|
+
end
|
125
153
|
end
|
126
154
|
end
|
data/exe/jobshop
CHANGED
@@ -29,6 +29,15 @@ module Jobshop
|
|
29
29
|
after: sentinel, verbose: true)
|
30
30
|
end
|
31
31
|
|
32
|
+
def config_force_ssl
|
33
|
+
return if options[:pretend]
|
34
|
+
|
35
|
+
data = "config.force_ssl = true"
|
36
|
+
sentinel = /class [a-z_:]+ < Rails::Application/i
|
37
|
+
inject_into_file("config/application.rb", "\n #{data}",
|
38
|
+
after: sentinel, verbose: true)
|
39
|
+
end
|
40
|
+
|
32
41
|
def mount_engine
|
33
42
|
return if options[:pretend]
|
34
43
|
|
@@ -43,8 +52,8 @@ module Jobshop
|
|
43
52
|
end
|
44
53
|
|
45
54
|
def self.source_paths
|
46
|
-
[
|
47
|
-
|
55
|
+
[ Jobshop::Generators::AppGenerator.source_root,
|
56
|
+
Rails::Generators::AppGenerator.source_root ]
|
48
57
|
end
|
49
58
|
|
50
59
|
hide!
|
@@ -52,7 +61,7 @@ module Jobshop
|
|
52
61
|
class_option :help, type: :boolean, aliases: "-h", group: :other,
|
53
62
|
desc: "Show this help message and quit"
|
54
63
|
class_option :version, type: :boolean, aliases: "-v", group: :other,
|
55
|
-
|
64
|
+
desc: "Show Jobshop version number and quit"
|
56
65
|
|
57
66
|
def initialize(*args)
|
58
67
|
super
|
@@ -73,6 +82,7 @@ module Jobshop
|
|
73
82
|
|
74
83
|
def finish_template
|
75
84
|
build :config_schema_format
|
85
|
+
build :config_force_ssl
|
76
86
|
build :mount_engine
|
77
87
|
super
|
78
88
|
end
|