shoulda_matchmakers 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/controller/action_controller/action_controller_controller_sm_model_helper.rb +0 -7
- data/lib/controller/action_controller/matchmakers/permit.rb +14 -14
- data/lib/controller/action_controller/matchmakers/route.rb +0 -383
- data/lib/model/active_record/matchmakers/have_db_index.rb +1 -1
- data/lib/model/active_record/matchmakers/validations.rb +0 -14
- data/lib/shoulda_matchmakers/version.rb +1 -1
- data/lib/support/controller_generator.rb +2 -54
- data/lib/templates/shoulda_matchmakers.rb +2 -2
- metadata +1 -25
- data/lib/support/indefinite_article.rb +0 -70
- data/lib/support/to_discard/belong_to.rb +0 -94
- data/lib/support/to_discard/have_and_belong_to_many.rb +0 -83
- data/lib/support/to_discard/have_many.rb +0 -96
- data/lib/support/to_discard/have_one.rb +0 -98
- data/lib/support/to_discard/permit_refactor.rb +0 -270
- data/lib/support/to_discard/render_template_new.rb +0 -204
- data/lib/support/to_discard/render_template_reconstruction.rb +0 -188
- data/lib/support/to_discard/use_around_action.rb +0 -20
- data/lib/support/to_discard/use_before_action.rb +0 -20
- data/lib/support/to_discard/validate_absence_of.rb +0 -16
- data/lib/support/to_discard/validate_acceptance_of.rb +0 -16
- data/lib/support/to_discard/validate_confirmation_of.rb +0 -16
- data/lib/support/to_discard/validate_exclusion_of.rb +0 -145
- data/lib/support/to_discard/validate_inclusion_of.rb +0 -94
- data/lib/support/to_discard/validate_length_of.rb +0 -16
- data/lib/support/to_discard/validate_numericality_of.rb +0 -16
- data/lib/support/to_discard/validate_presence_of.rb +0 -16
- data/lib/support/to_discard/validate_uniqueness_of.rb +0 -16
- data/lib/support/to_discard/validation_old.rb +0 -37
- data/lib/support/to_discard/validations.rb +0 -41
- data/lib/support/to_discard/validations_conditional.rb +0 -146
- data/lib/support/trace_debug_lines.txt +0 -319
- data/lib/support/util.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd3a9140db13b85f889956fc07054a4d3dc273bd
|
4
|
+
data.tar.gz: f4c9a4744856800bebaf0fba6ba8fec9576014db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce1e5b634a33f8096ae66441260886eef59e51cf8b52fbd8cb501c899fca638b7626ed37c5e45fdc1491955b6aa0ec6920542ef9d1157ed0ea64ed1791e933b2
|
7
|
+
data.tar.gz: c75c145f7f7db6c2159f940b1474bb172c0c80c33a9923656ce7ca75c7b1faa71d03b696cd5df0b7b7f83ece21ec0c64b3da9dea017d96678aa105aa7a7fd33b
|
@@ -64,10 +64,3 @@ module ShouldaMatchmakers
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
67
|
-
|
68
|
-
# Reject procs
|
69
|
-
# # TRACE.debug "ALL ACTIONS:"
|
70
|
-
# # TRACE.debug all_actions.inspect
|
71
|
-
# selected_actions.map(&:raw_filter).reject{ |action| action.class == Proc }
|
72
|
-
# all_actions.map { |action| action.is_a?(Symbol) ? ":#{ action }" : action.to_s }
|
73
|
-
|
@@ -1,17 +1,3 @@
|
|
1
|
-
# IMPLEMENTATION TODO: Determine if the variables used in this matcher generator represent the appropriate values, as shown here:
|
2
|
-
#
|
3
|
-
# it do
|
4
|
-
# params = {
|
5
|
-
# <params_class>: {
|
6
|
-
# <permitted_params_def.permitted_params.each>: <sample_value>
|
7
|
-
# }
|
8
|
-
# }
|
9
|
-
# should permit(:<permitted_params_def.permitted_params.each>).
|
10
|
-
# for(:<calling_class_method>, params: params).
|
11
|
-
# on(:<calling_class>)
|
12
|
-
# end
|
13
|
-
#
|
14
|
-
|
15
1
|
require 'controller/action_controller/permitted_params_definition'
|
16
2
|
|
17
3
|
module ShouldaMatchmakers
|
@@ -341,6 +327,20 @@ module ShouldaMatchmakers
|
|
341
327
|
end
|
342
328
|
|
343
329
|
|
330
|
+
# IMPLEMENTATION TODO: Determine if the variables used in this matcher generator represent the appropriate values, as shown here:
|
331
|
+
#
|
332
|
+
# it do
|
333
|
+
# params = {
|
334
|
+
# <params_class>: {
|
335
|
+
# <permitted_params_def.permitted_params.each>: <sample_value>
|
336
|
+
# }
|
337
|
+
# }
|
338
|
+
# should permit(:<permitted_params_def.permitted_params.each>).
|
339
|
+
# for(:<calling_class_method>, params: params).
|
340
|
+
# on(:<calling_class>)
|
341
|
+
# end
|
342
|
+
#
|
343
|
+
|
344
344
|
# TODO: Nested Attributes
|
345
345
|
# def protected_branch_params
|
346
346
|
# params.require(:protected_branch).permit(:name,
|
@@ -201,386 +201,3 @@ module ShouldaMatchmakers
|
|
201
201
|
end
|
202
202
|
end
|
203
203
|
end
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
# module ShouldaMatchmakers
|
208
|
-
# module Controller
|
209
|
-
# module ActionController
|
210
|
-
# module Matchmaker
|
211
|
-
# module Route
|
212
|
-
#
|
213
|
-
#
|
214
|
-
# def route_matcher_tests
|
215
|
-
# if journey_routes_present(@sm_model_action_controller_controller)
|
216
|
-
# generate_route_matcher_tests(@sm_model_action_controller_controller)
|
217
|
-
# else
|
218
|
-
# []
|
219
|
-
# end
|
220
|
-
# end
|
221
|
-
#
|
222
|
-
#
|
223
|
-
# private
|
224
|
-
#
|
225
|
-
# def generate_route_matcher_tests(controller)
|
226
|
-
# route_tests = []
|
227
|
-
# controller_path = get_app_controller_file_path(controller)
|
228
|
-
# controller.constantize.action_methods.sort.each do |action_method|
|
229
|
-
# journey_routes = extract_journey_routes(controller_path, action_method)
|
230
|
-
# journey_routes.each do |journey_route|
|
231
|
-
# single_route_tests = generate_single_route_tests(journey_route)
|
232
|
-
# route_tests = route_tests + single_route_tests
|
233
|
-
# end
|
234
|
-
# end
|
235
|
-
# format_tests(route_tests)
|
236
|
-
# end
|
237
|
-
#
|
238
|
-
# def generate_single_route_tests(journey_route)
|
239
|
-
# single_route_tests = []
|
240
|
-
# route_parameters_hash = generate_route_parameters_hash(journey_route)
|
241
|
-
# test_comment = route_parameters_hash.extract!(:test_comment)[:test_comment]
|
242
|
-
# url_options_hash = { controller: journey_route.defaults[:controller], action: journey_route.defaults[:action], only_path: true }
|
243
|
-
# url_options_hash = url_options_hash.merge(route_parameters_hash)
|
244
|
-
#
|
245
|
-
# ## TRACE.debug " ROUTE PARAMETERS HASH:"
|
246
|
-
# ## TRACE.debug route_parameters_hash.inspect
|
247
|
-
# ## TRACE.debug " URL OPTIONS HASH:"
|
248
|
-
# ## TRACE.debug url_options_hash.inspect
|
249
|
-
#
|
250
|
-
# if test_comment.present?
|
251
|
-
# url = "<url required>"
|
252
|
-
# else
|
253
|
-
# url = url_for(url_options_hash)
|
254
|
-
# end
|
255
|
-
#
|
256
|
-
# # TRACE.debug " URL:"
|
257
|
-
# # TRACE.debug url.inspect
|
258
|
-
#
|
259
|
-
# request_methods = get_request_methods(journey_route)
|
260
|
-
# # CONFIRMATION TODO: Determine if this is the proper way to handle controller actions with multiple HTTP verbs
|
261
|
-
# request_methods.each do |request_method|
|
262
|
-
# single_route_test = generate_route_test_single_line(journey_route, url, request_method, route_parameters_hash, test_comment)
|
263
|
-
# if single_route_test.length > @working_generated_code_line_length
|
264
|
-
# single_route_test = generate_route_test_multiple_line(single_route_test)
|
265
|
-
# end
|
266
|
-
# single_route_tests << single_route_test
|
267
|
-
# end
|
268
|
-
# single_route_tests
|
269
|
-
# end
|
270
|
-
#
|
271
|
-
# def generate_route_test_single_line(journey_route, url, request_method, route_parameters_hash, test_comment)
|
272
|
-
# route_test = " it { is_expected.to route(#{ request_method }, '#{ url }').to(action: #{ journey_route.defaults[:action] }"
|
273
|
-
# route_parameters_hash.each do |param_key, param_value|
|
274
|
-
#
|
275
|
-
# ## TRACE.debug ""
|
276
|
-
# ## TRACE.debug " ROUTE PARAMETERS HASH KEY: " + param_key.inspect
|
277
|
-
# ## TRACE.debug " ROUTE PARAMETERS HASH VALUE: " + param_value.inspect
|
278
|
-
# ## TRACE.debug " ROUTE PARAMETERS HASH VALUE CLASS: " + param_value.class.name.to_s
|
279
|
-
#
|
280
|
-
# route_test.concat(", " + param_key.to_s + ": " + param_value.to_s )
|
281
|
-
# end
|
282
|
-
# # "#{ route_parameters_hash.to_s.gsub("{", "{ ").gsub("{ ", "{ ").gsub("}", " }").gsub(" }", " }") }")
|
283
|
-
# route_test.concat(") }")
|
284
|
-
# if test_comment.present?
|
285
|
-
# route_test.prepend(test_comment)
|
286
|
-
# route_test.sub!(" it { ", " xit { ")
|
287
|
-
# end
|
288
|
-
# route_test
|
289
|
-
# end
|
290
|
-
#
|
291
|
-
# def generate_route_test_multiple_line(route_test)
|
292
|
-
#
|
293
|
-
# ## TRACE.debug ""
|
294
|
-
# ## TRACE.debug " ROUTE TEST:"
|
295
|
-
# ## TRACE.debug route_test.to_s
|
296
|
-
#
|
297
|
-
# route_test.sub("it { ", "it do\n ").gsub(").to(", ").\n to(").gsub(/\)\s\}$/, ")\n end")
|
298
|
-
# end
|
299
|
-
#
|
300
|
-
# def get_request_methods(journey_route)
|
301
|
-
# request_method_regex = journey_route.constraints[:request_method]
|
302
|
-
# request_method_regex.to_s.scan(/[A-Z]+/)
|
303
|
-
# end
|
304
|
-
#
|
305
|
-
# def generate_route_parameters_hash(journey_route)
|
306
|
-
#
|
307
|
-
# # if journey_route.required_keys.size > 2
|
308
|
-
# ## TRACE.debug ""
|
309
|
-
# ## TRACE.debug ""
|
310
|
-
# ## TRACE.debug ""
|
311
|
-
# # ## TRACE.debug " ROUTE APP:"
|
312
|
-
# # ## TRACE.debug journey_route.app.inspect
|
313
|
-
# ## TRACE.debug " ROUTE CONSTRAINTS:"
|
314
|
-
# ## TRACE.debug journey_route.defaults.inspect
|
315
|
-
# # ## TRACE.debug " ROUTE DEFAULTS:"
|
316
|
-
# # ## TRACE.debug journey_route.defaults.inspect
|
317
|
-
# # ## TRACE.debug " ROUTE NAME:"
|
318
|
-
# # ## TRACE.debug journey_route.name.inspect
|
319
|
-
# # ## TRACE.debug " ROUTE PATH:"
|
320
|
-
# # ## TRACE.debug journey_route.path.inspect
|
321
|
-
# # ## TRACE.debug " ROUTE PRECENDENCE:"
|
322
|
-
# # ## TRACE.debug journey_route.precedence.inspect
|
323
|
-
# # ## TRACE.debug " ROUTE OPTIONAL PARTS:"
|
324
|
-
# # ## TRACE.debug journey_route.optional_parts.inspect
|
325
|
-
# # ## TRACE.debug " ROUTE PARTS:"
|
326
|
-
# # ## TRACE.debug journey_route.parts.inspect
|
327
|
-
# # ## TRACE.debug " ROUTE REQUIRED DEFAULTS:"
|
328
|
-
# # ## TRACE.debug journey_route.required_defaults.inspect
|
329
|
-
# ## TRACE.debug " ROUTE REQUIRED KEYS: " + journey_route.required_keys.inspect
|
330
|
-
# # ## TRACE.debug " ROUTE REQUIRED PARTS:"
|
331
|
-
# # ## TRACE.debug journey_route.required_parts.inspect
|
332
|
-
# # # journey_route.required_parts.each do |rp|
|
333
|
-
# # # # TRACE.debug " ROUTE REQUIRED PART: " + rp.to_s
|
334
|
-
# # # # TRACE.debug " ROUTE REQUIRED PART CLASS: " + rp.class.name.to_s
|
335
|
-
# # # end
|
336
|
-
# ## TRACE.debug " ROUTE REQUIREMENTS:"
|
337
|
-
# ## TRACE.debug journey_route.requirements.inspect
|
338
|
-
# # ## TRACE.debug " ROUTE REQUIREMENTS KEYS:"
|
339
|
-
# # ## TRACE.debug journey_route.requirements.keys.inspect
|
340
|
-
# # ## TRACE.debug " ROUTE SEGMENTS:"
|
341
|
-
# # ## TRACE.debug journey_route.segments.inspect
|
342
|
-
# # ## TRACE.debug " ROUTE VERB:"
|
343
|
-
# # ## TRACE.debug journey_route.verb.inspect
|
344
|
-
# #
|
345
|
-
# ## TRACE.debug ""
|
346
|
-
# ## TRACE.debug " ROUTE REQUIRED KEYS WITHOUT VALUES:"
|
347
|
-
# # require_keys_with_missing_values = journey_route.required_keys - journey_route.requirements.keys
|
348
|
-
# ## TRACE.debug require_keys_with_missing_values.inspect
|
349
|
-
# # end
|
350
|
-
#
|
351
|
-
# route_parameters_hash = journey_route.requirements.select { |key, value| journey_route.parts.include? key } || {}
|
352
|
-
# route_required_keys_with_missing_values = journey_route.required_keys - journey_route.requirements.keys
|
353
|
-
# # CONFIRMATION TODO: Determine if this is the proper way to handle route required ':id' parameter when value not provided
|
354
|
-
# if route_required_keys_with_missing_values.include? :id
|
355
|
-
# route_parameters_hash[:id] = 1
|
356
|
-
# route_required_keys_with_missing_values.delete(:id)
|
357
|
-
# end
|
358
|
-
# # CONFIRMATION TODO: Determine if this is the proper way to handle route required parameters that either have a regex or no value provided
|
359
|
-
# route_parameters_hash[:test_comment] = ""
|
360
|
-
# if route_required_keys_with_missing_values.present?
|
361
|
-
# route_required_keys_with_missing_values.each do |key_without_value|
|
362
|
-
# route_parameters_hash[key_without_value] = "'<value required>'"
|
363
|
-
# end
|
364
|
-
# if route_required_keys_with_missing_values.size == 1
|
365
|
-
# route_parameters_hash[:test_comment].concat("# A required value for route parameter ':#{ route_required_keys_with_missing_values[0] }' needs to be provided.\n")
|
366
|
-
# else
|
367
|
-
# route_parameters_hash[:test_comment].concat("# Required values for route parameters '#{ route_required_keys_with_missing_values.to_s }' need to be provided.\n")
|
368
|
-
# end
|
369
|
-
# end
|
370
|
-
# if route_parameters_hash.values.any? { |route_parameter_value| route_parameter_value.is_a?(Regexp) }
|
371
|
-
# route_parameters_hash.each do |param_key, param_value|
|
372
|
-
# if param_value.is_a? Regexp
|
373
|
-
# param_regex_string = param_value.to_s.sub("(?-mix:","").gsub(/\)$/,"")
|
374
|
-
# route_parameters_hash[:test_comment].concat("# A required value for route parameter ':#{ param_key }' matching regexp '#{ param_regex_string }' needs to be provided.\n")
|
375
|
-
# route_parameters_hash[param_key] = "'<value matching regex required>'"
|
376
|
-
# end
|
377
|
-
# end
|
378
|
-
# end
|
379
|
-
# if route_parameters_hash[:test_comment].present?
|
380
|
-
# # if route_parameters_hash[:test_comment].scan("values").count > 0 || route_parameters_hash[:test_comment].scan("# ").count > 1
|
381
|
-
# route_parameters_hash[:test_comment].concat("# Unable to determine URL without values to be provided.\n" +
|
382
|
-
# "# Remove the 'x' from 'xit' once you have supplied the appropriate values.\n")
|
383
|
-
# # else
|
384
|
-
# # route_parameters_hash[:test_comment].concat("# Remove the 'x' from 'xit' once you have supplied the appropriate value.\n")
|
385
|
-
# # end
|
386
|
-
# end
|
387
|
-
#
|
388
|
-
# ## TRACE.debug " ROUTE REQUIREMENTS HASH:"
|
389
|
-
# ## TRACE.debug route_parameters_hash.inspect
|
390
|
-
#
|
391
|
-
# route_parameters_hash
|
392
|
-
# end
|
393
|
-
#
|
394
|
-
# def extract_journey_routes(controller_path, action_method)
|
395
|
-
# Rails.application.routes.routes.routes.select do |route|
|
396
|
-
# if route.defaults.present?
|
397
|
-
# route.defaults[:controller].to_sym == controller_path.to_sym && route.defaults[:action].to_sym == action_method.to_sym
|
398
|
-
# else
|
399
|
-
# false
|
400
|
-
# end
|
401
|
-
# end
|
402
|
-
# end
|
403
|
-
#
|
404
|
-
# def journey_routes_present(controller)
|
405
|
-
# journey_routes_are_present = false
|
406
|
-
# controller_path = get_app_controller_file_path(controller)
|
407
|
-
# controller.constantize.action_methods.map do |action_method|
|
408
|
-
# journey_routes = extract_journey_routes(controller_path, action_method)
|
409
|
-
# journey_routes_are_present = true if journey_routes.present?
|
410
|
-
# end
|
411
|
-
# journey_routes_are_present
|
412
|
-
# end
|
413
|
-
#
|
414
|
-
# end
|
415
|
-
# end
|
416
|
-
# end
|
417
|
-
# end
|
418
|
-
# end
|
419
|
-
|
420
|
-
|
421
|
-
# def route_matcher_tests
|
422
|
-
# if journey_routes_present(@sm_model_action_controller_controller)
|
423
|
-
# generate_route_matcher_tests(@sm_model_action_controller_controller)
|
424
|
-
# else
|
425
|
-
# []
|
426
|
-
# end
|
427
|
-
# end
|
428
|
-
#
|
429
|
-
#
|
430
|
-
# private
|
431
|
-
#
|
432
|
-
# def generate_route_matcher_tests(controller)
|
433
|
-
# route_tests = []
|
434
|
-
# controller_path = get_app_controller_file_path(controller)
|
435
|
-
# controller.constantize.action_methods.map do |action_method|
|
436
|
-
# journey_routes = extract_journey_routes(controller_path, action_method)
|
437
|
-
# journey_routes.each do |journey_route|
|
438
|
-
# single_route_tests = generate_single_route_tests(journey_route, controller_path, action_method)
|
439
|
-
# route_tests = route_tests + single_route_tests
|
440
|
-
# end
|
441
|
-
# end
|
442
|
-
# format_tests(route_tests)
|
443
|
-
# end
|
444
|
-
#
|
445
|
-
# def generate_single_route_tests(journey_route, controller_path, action_method)
|
446
|
-
# single_route_tests = []
|
447
|
-
# route_parameters_hash = generate_route_parameters_hash(journey_route)
|
448
|
-
# url = url_for({controller: controller_path, action: action_method, only_path: true}.merge(route_parameters_hash.except(:test_comment)))
|
449
|
-
# if url.present?
|
450
|
-
# request_methods = get_request_methods(journey_route)
|
451
|
-
# # CONFIRMATION TODO: Determine if this is the proper way to handle controller actions with multiple HTTP verbs
|
452
|
-
# request_methods.each do |request_method|
|
453
|
-
# single_route_test = generate_route_test_single_line(journey_route, url, controller_path, action_method, request_method)
|
454
|
-
# if single_route_test.length > @working_generated_code_line_length
|
455
|
-
# single_route_test = generate_route_test_multiple_line(single_route_test)
|
456
|
-
# end
|
457
|
-
# single_route_tests << single_route_test
|
458
|
-
# end
|
459
|
-
# end
|
460
|
-
# single_route_tests
|
461
|
-
# end
|
462
|
-
#
|
463
|
-
# def generate_route_test_single_line(journey_route, url, controller_path, action_method, request_method)
|
464
|
-
# route_parameters_hash = generate_route_parameters_hash(journey_route)
|
465
|
-
# route_test = " it { is_expected.to route(#{ request_method }, '#{ url }').to('#{ controller_path }##{ action_method }'"
|
466
|
-
# if route_parameters_hash.present?
|
467
|
-
# route_test.concat(", #{ route_parameters_hash.except(:test_comment).to_s.gsub("{", "{ ").gsub("{ ", "{ ").gsub("}", " }").gsub(" }", " }") }")
|
468
|
-
# end
|
469
|
-
# route_test.concat(") }")
|
470
|
-
# if route_parameters_hash[:test_comment] =~ /#\s/
|
471
|
-
# route_test.prepend(route_parameters_hash[:test_comment])
|
472
|
-
# end
|
473
|
-
# route_test
|
474
|
-
# end
|
475
|
-
#
|
476
|
-
# def generate_route_test_multiple_line(route_test)
|
477
|
-
# route_test.gsub!(" it { ", " it do\n ").gsub!(").to(", ").\n to(").gsub!(/\)\s\}$/, ")\n end")
|
478
|
-
# end
|
479
|
-
#
|
480
|
-
# def get_request_methods(journey_route)
|
481
|
-
# request_method_regex = journey_route.constraints[:request_method]
|
482
|
-
# request_method_regex.to_s.scan(/[A-Z]+/)
|
483
|
-
# end
|
484
|
-
#
|
485
|
-
# def generate_route_parameters_hash(journey_route)
|
486
|
-
#
|
487
|
-
# if journey_route.required_keys.size > 2
|
488
|
-
# # TRACE.debug ""
|
489
|
-
# # TRACE.debug ""
|
490
|
-
# # TRACE.debug ""
|
491
|
-
# ## TRACE.debug " ROUTE APP:"
|
492
|
-
# ## TRACE.debug journey_route.app.inspect
|
493
|
-
# # TRACE.debug " ROUTE CONSTRAINTS:"
|
494
|
-
# # TRACE.debug journey_route.defaults.inspect
|
495
|
-
# ## TRACE.debug " ROUTE DEFAULTS:"
|
496
|
-
# ## TRACE.debug journey_route.defaults.inspect
|
497
|
-
# ## TRACE.debug " ROUTE NAME:"
|
498
|
-
# ## TRACE.debug journey_route.name.inspect
|
499
|
-
# ## TRACE.debug " ROUTE PATH:"
|
500
|
-
# ## TRACE.debug journey_route.path.inspect
|
501
|
-
# ## TRACE.debug " ROUTE PRECENDENCE:"
|
502
|
-
# ## TRACE.debug journey_route.precedence.inspect
|
503
|
-
# ## TRACE.debug " ROUTE OPTIONAL PARTS:"
|
504
|
-
# ## TRACE.debug journey_route.optional_parts.inspect
|
505
|
-
# ## TRACE.debug " ROUTE PARTS:"
|
506
|
-
# ## TRACE.debug journey_route.parts.inspect
|
507
|
-
# ## TRACE.debug " ROUTE REQUIRED DEFAULTS:"
|
508
|
-
# ## TRACE.debug journey_route.required_defaults.inspect
|
509
|
-
# # TRACE.debug " ROUTE REQUIRED KEYS: " + journey_route.required_keys.inspect
|
510
|
-
# ## TRACE.debug " ROUTE REQUIRED PARTS:"
|
511
|
-
# ## TRACE.debug journey_route.required_parts.inspect
|
512
|
-
# # journey_route.required_parts.each do |rp|
|
513
|
-
# # # TRACE.debug " ROUTE REQUIRED PART: " + rp.to_s
|
514
|
-
# # # TRACE.debug " ROUTE REQUIRED PART CLASS: " + rp.class.name.to_s
|
515
|
-
# # end
|
516
|
-
# # TRACE.debug " ROUTE REQUIREMENTS:"
|
517
|
-
# # TRACE.debug journey_route.requirements.inspect
|
518
|
-
# ## TRACE.debug " ROUTE REQUIREMENTS KEYS:"
|
519
|
-
# ## TRACE.debug journey_route.requirements.keys.inspect
|
520
|
-
# ## TRACE.debug " ROUTE SEGMENTS:"
|
521
|
-
# ## TRACE.debug journey_route.segments.inspect
|
522
|
-
# ## TRACE.debug " ROUTE VERB:"
|
523
|
-
# ## TRACE.debug journey_route.verb.inspect
|
524
|
-
#
|
525
|
-
# # TRACE.debug ""
|
526
|
-
# # TRACE.debug " ROUTE REQUIRED KEYS WITHOUT VALUES:"
|
527
|
-
# require_keys_with_missing_values = journey_route.required_keys - journey_route.requirements.keys
|
528
|
-
# # TRACE.debug require_keys_with_missing_values.inspect
|
529
|
-
#
|
530
|
-
#
|
531
|
-
# end
|
532
|
-
#
|
533
|
-
# route_parameters_hash = journey_route.requirements.select { |key, value| journey_route.parts.include? key }
|
534
|
-
# route_required_keys_with_missing_values = journey_route.required_keys - journey_route.requirements.keys
|
535
|
-
# if route_required_keys_with_missing_values.include? :id
|
536
|
-
# route_parameters_hash[:id] = 1
|
537
|
-
# route_required_keys_with_missing_values.delete(:id)
|
538
|
-
# end
|
539
|
-
# # CONFIRMATION TODO: Determine if this is the proper way to handle route parts that do no have a required value provided
|
540
|
-
# if route_required_keys_with_missing_values.present?
|
541
|
-
# route_required_keys_with_missing_values.each do |key_without_value|
|
542
|
-
# route_parameters_hash[key_without_value] = "<value required>"
|
543
|
-
# end
|
544
|
-
# if route_required_keys_with_missing_values.size == 1
|
545
|
-
# route_parameters_hash[:test_comment] = "# A required value needs to be provided for route part '#{ route_required_keys_with_missing_values[0] }'.\n" +
|
546
|
-
# "# Remove the 'x' from 'xit' once you have supplied an appropriate value.\n"
|
547
|
-
# else
|
548
|
-
# route_parameters_hash[:test_comment] = "# Required values need to be provided for route parts '#{ route_required_keys_with_missing_values.to_s }'.\n" +
|
549
|
-
# "# Remove the 'x' from 'xit' once you have supplied the appropriate values.\n"
|
550
|
-
# end
|
551
|
-
# else
|
552
|
-
# route_parameters_hash[:test_comment] = ""
|
553
|
-
# end
|
554
|
-
#
|
555
|
-
# # journey_route.requirements.each do |req_key, req_value |
|
556
|
-
# # route_parameters_hash[req_key] = req_value
|
557
|
-
# # end
|
558
|
-
# # if journey_route.defaults[:format]
|
559
|
-
# # route_parameters_hash.reverse_merge!({ format: journey_route.defaults[:format] })
|
560
|
-
# # end
|
561
|
-
#
|
562
|
-
# # TRACE.debug " ROUTE REQUIREMENTS HASH:"
|
563
|
-
# # TRACE.debug route_parameters_hash.inspect
|
564
|
-
#
|
565
|
-
# route_parameters_hash
|
566
|
-
# end
|
567
|
-
#
|
568
|
-
# def extract_journey_routes(controller_path, action_method)
|
569
|
-
# Rails.application.routes.routes.routes.select do |route|
|
570
|
-
# if route.defaults.present?
|
571
|
-
# route.defaults[:controller].to_sym == controller_path.to_sym && route.defaults[:action].to_sym == action_method.to_sym
|
572
|
-
# else
|
573
|
-
# false
|
574
|
-
# end
|
575
|
-
# end
|
576
|
-
# end
|
577
|
-
#
|
578
|
-
# def journey_routes_present(controller)
|
579
|
-
# journey_routes_are_present = false
|
580
|
-
# controller_path = get_app_controller_file_path(controller)
|
581
|
-
# controller.constantize.action_methods.map do |action_method|
|
582
|
-
# journey_routes = extract_journey_routes(controller_path, action_method)
|
583
|
-
# journey_routes_are_present = true if journey_routes.present?
|
584
|
-
# end
|
585
|
-
# journey_routes_are_present
|
586
|
-
# end
|
@@ -5,7 +5,7 @@ module ShouldaMatchmakers
|
|
5
5
|
module HaveDbIndex
|
6
6
|
|
7
7
|
def have_db_index_matcher_tests
|
8
|
-
# IMPLEMENTATION TODO: Determine if it is possible to indexes where 'using=:gin' (or anything not :btree)
|
8
|
+
# IMPLEMENTATION TODO: Determine if it is possible to handle indexes where 'using=:gin' (or anything not :btree)
|
9
9
|
db_indexes = ::ActiveRecord::Base.connection.indexes(@app_class_name.tableize.gsub("/", "_")).select{ |ndx| ndx.using == :btree }
|
10
10
|
if db_indexes.present?
|
11
11
|
generate_have_db_index_matcher_tests(db_indexes)
|