rider-kick 0.0.14 → 0.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/generators/rider_kick/clean_arch_generator.rb +17 -18
- data/lib/generators/rider_kick/init_generator.rb +15 -0
- data/lib/generators/rider_kick/scaffold_generator.rb +32 -30
- data/lib/generators/rider_kick/scaffold_generator_contracts_with_scope_spec.rb +3 -4
- data/lib/generators/rider_kick/scaffold_generator_list_spec_format_spec.rb +17 -11
- data/lib/generators/rider_kick/scaffold_generator_rspec_spec.rb +2 -11
- data/lib/generators/rider_kick/scaffold_generator_with_scope_spec.rb +2 -2
- data/lib/generators/rider_kick/structure_generator.rb +2 -0
- data/lib/generators/rider_kick/templates/config/initializers/pagy.rb.tt +45 -10
- data/lib/generators/rider_kick/templates/config/initializers/rider_kick.rb.tt +29 -0
- data/lib/generators/rider_kick/templates/db/structures/example.yaml.tt +1 -0
- data/lib/generators/rider_kick/templates/domains/core/builders/builder_spec.rb.tt +51 -38
- data/lib/generators/rider_kick/templates/domains/core/repositories/abstract_repository.rb.tt +7 -5
- data/lib/generators/rider_kick/templates/domains/core/repositories/create_spec.rb.tt +131 -40
- data/lib/generators/rider_kick/templates/domains/core/repositories/destroy.rb.tt +4 -5
- data/lib/generators/rider_kick/templates/domains/core/repositories/destroy_spec.rb.tt +102 -57
- data/lib/generators/rider_kick/templates/domains/core/repositories/fetch_by_id.rb.tt +1 -1
- data/lib/generators/rider_kick/templates/domains/core/repositories/fetch_by_id_spec.rb.tt +89 -37
- data/lib/generators/rider_kick/templates/domains/core/repositories/list.rb.tt +8 -3
- data/lib/generators/rider_kick/templates/domains/core/repositories/list_spec.rb.tt +141 -131
- data/lib/generators/rider_kick/templates/domains/core/repositories/update.rb.tt +2 -2
- data/lib/generators/rider_kick/templates/domains/core/repositories/update_spec.rb.tt +171 -80
- data/lib/generators/rider_kick/templates/domains/core/use_cases/create_spec.rb.tt +25 -5
- data/lib/generators/rider_kick/templates/domains/core/use_cases/destroy_spec.rb.tt +4 -4
- data/lib/generators/rider_kick/templates/domains/core/use_cases/fetch_by_id_spec.rb.tt +4 -4
- data/lib/generators/rider_kick/templates/domains/core/use_cases/list_spec.rb.tt +1 -1
- data/lib/generators/rider_kick/templates/domains/core/use_cases/update_spec.rb.tt +28 -8
- data/lib/generators/rider_kick/templates/spec/rails_helper.rb +1 -0
- data/lib/generators/rider_kick/templates/spec/support/use_case_stubber.rb +14 -0
- data/lib/rider_kick/configuration.rb +32 -12
- data/lib/rider_kick/matchers/use_case_result.rb +1 -1
- data/lib/rider_kick/use_cases/abstract_use_case_spec.rb +3 -3
- data/lib/rider_kick/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3c933ba32d84ebd605729faf5dddd9ee0392e2954b160c0e2ef0a23570f5c636
|
|
4
|
+
data.tar.gz: fab65284c253086df7acb0b40e89f078f20d436f241b63c3a0352e36d96127f2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e1dc64862b3707c35dd437dd9f2ce1af940d20fcf9f8c99f0160c65bc77c99f0aba9af9046a8ccc2ea8309ce56fff57cd6fada35afa46b996ff36f6462b645e5
|
|
7
|
+
data.tar.gz: 908f66d02665cac5897adb37cfc215a34cccee066bf009b111037a82f0a58ad905ac327d54e77bcbb0c67da65d8b3d75eae6aaa4479b65902e4581d6e1be61ff
|
|
@@ -117,30 +117,30 @@ module RiderKick
|
|
|
117
117
|
end
|
|
118
118
|
|
|
119
119
|
def setup_domain_structure
|
|
120
|
-
empty_directory File.join(RiderKick.configuration.domains_path,
|
|
121
|
-
empty_directory File.join(RiderKick.configuration.domains_path,
|
|
122
|
-
empty_directory File.join(RiderKick.configuration.domains_path,
|
|
123
|
-
empty_directory File.join(RiderKick.configuration.domains_path,
|
|
124
|
-
empty_directory File.join(RiderKick.configuration.domains_path,
|
|
120
|
+
empty_directory File.join(RiderKick.configuration.domains_path, "#{RiderKick.configuration.use_cases_dir}/contract")
|
|
121
|
+
empty_directory File.join(RiderKick.configuration.domains_path, RiderKick.configuration.repositories_dir)
|
|
122
|
+
empty_directory File.join(RiderKick.configuration.domains_path, RiderKick.configuration.builders_dir)
|
|
123
|
+
empty_directory File.join(RiderKick.configuration.domains_path, RiderKick.configuration.entities_dir)
|
|
124
|
+
empty_directory File.join(RiderKick.configuration.domains_path, RiderKick.configuration.utils_dir)
|
|
125
125
|
|
|
126
126
|
# then
|
|
127
127
|
copy_domain_file
|
|
128
128
|
end
|
|
129
129
|
|
|
130
130
|
def copy_domain_file
|
|
131
|
-
template 'domains/core/use_cases/contract/pagination.rb.tt', File.join(RiderKick.configuration.domains_path,
|
|
132
|
-
template 'domains/core/use_cases/contract/default.rb.tt', File.join(RiderKick.configuration.domains_path,
|
|
133
|
-
template 'domains/core/use_cases/get_version.rb.tt', File.join(RiderKick.configuration.domains_path,
|
|
131
|
+
template 'domains/core/use_cases/contract/pagination.rb.tt', File.join(RiderKick.configuration.domains_path, "#{RiderKick.configuration.use_cases_dir}/contract", 'pagination.rb')
|
|
132
|
+
template 'domains/core/use_cases/contract/default.rb.tt', File.join(RiderKick.configuration.domains_path, "#{RiderKick.configuration.use_cases_dir}/contract", 'default.rb')
|
|
133
|
+
template 'domains/core/use_cases/get_version.rb.tt', File.join(RiderKick.configuration.domains_path, RiderKick.configuration.use_cases_dir, 'get_version.rb')
|
|
134
134
|
|
|
135
|
-
template 'domains/core/builders/error.rb.tt', File.join(RiderKick.configuration.domains_path,
|
|
136
|
-
template 'domains/core/builders/pagination.rb.tt', File.join(RiderKick.configuration.domains_path,
|
|
135
|
+
template 'domains/core/builders/error.rb.tt', File.join(RiderKick.configuration.domains_path, RiderKick.configuration.builders_dir, 'error.rb')
|
|
136
|
+
template 'domains/core/builders/pagination.rb.tt', File.join(RiderKick.configuration.domains_path, RiderKick.configuration.builders_dir, 'pagination.rb')
|
|
137
137
|
|
|
138
|
-
template 'domains/core/entities/error.rb.tt', File.join(RiderKick.configuration.domains_path,
|
|
139
|
-
template 'domains/core/entities/pagination.rb.tt', File.join(RiderKick.configuration.domains_path,
|
|
138
|
+
template 'domains/core/entities/error.rb.tt', File.join(RiderKick.configuration.domains_path, RiderKick.configuration.entities_dir, 'error.rb')
|
|
139
|
+
template 'domains/core/entities/pagination.rb.tt', File.join(RiderKick.configuration.domains_path, RiderKick.configuration.entities_dir, 'pagination.rb')
|
|
140
140
|
|
|
141
|
-
template 'domains/core/repositories/abstract_repository.rb.tt', File.join(RiderKick.configuration.domains_path,
|
|
142
|
-
template 'domains/core/utils/abstract_utils.rb.tt', File.join(RiderKick.configuration.domains_path,
|
|
143
|
-
template 'domains/core/utils/request_methods.rb.tt', File.join(RiderKick.configuration.domains_path,
|
|
141
|
+
template 'domains/core/repositories/abstract_repository.rb.tt', File.join(RiderKick.configuration.domains_path, RiderKick.configuration.repositories_dir, 'abstract_repository.rb')
|
|
142
|
+
template 'domains/core/utils/abstract_utils.rb.tt', File.join(RiderKick.configuration.domains_path, RiderKick.configuration.utils_dir, 'abstract_utils.rb')
|
|
143
|
+
template 'domains/core/utils/request_methods.rb.tt', File.join(RiderKick.configuration.domains_path, RiderKick.configuration.utils_dir, 'request_methods.rb')
|
|
144
144
|
end
|
|
145
145
|
|
|
146
146
|
def setup_initializers
|
|
@@ -221,9 +221,11 @@ module RiderKick
|
|
|
221
221
|
|
|
222
222
|
def gem_dependencies
|
|
223
223
|
<<~RUBY
|
|
224
|
+
|
|
224
225
|
group :development, :test do
|
|
225
226
|
gem "rspec-rails"
|
|
226
227
|
gem "factory_bot_rails"
|
|
228
|
+
gem 'rails-controller-testing'
|
|
227
229
|
gem "faker"
|
|
228
230
|
gem "shoulda-matchers"
|
|
229
231
|
end
|
|
@@ -240,9 +242,6 @@ module RiderKick
|
|
|
240
242
|
|
|
241
243
|
# pagination
|
|
242
244
|
gem 'pagy'
|
|
243
|
-
|
|
244
|
-
# models validation
|
|
245
|
-
gem 'schema_validations'
|
|
246
245
|
RUBY
|
|
247
246
|
end
|
|
248
247
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'base_generator'
|
|
4
|
+
|
|
5
|
+
module RiderKick
|
|
6
|
+
class InitGenerator < BaseGenerator
|
|
7
|
+
source_root File.expand_path('templates', __dir__)
|
|
8
|
+
|
|
9
|
+
desc 'Generate RiderKick configuration initializer'
|
|
10
|
+
|
|
11
|
+
def create_initializer
|
|
12
|
+
template 'config/initializers/rider_kick.rb.tt', 'config/initializers/rider_kick.rb'
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -22,8 +22,8 @@ module RiderKick
|
|
|
22
22
|
configure_engine
|
|
23
23
|
validation!
|
|
24
24
|
setup_variables
|
|
25
|
-
validate_repository_filters!
|
|
26
|
-
validate_entity_fields!
|
|
25
|
+
validate_repository_filters! # ← validate filter fields exist (after setup_variables)
|
|
26
|
+
validate_entity_fields! # ← validate entity db_attributes exist (after setup_variables)
|
|
27
27
|
|
|
28
28
|
generate_files('create')
|
|
29
29
|
generate_files('update')
|
|
@@ -46,7 +46,7 @@ module RiderKick
|
|
|
46
46
|
|
|
47
47
|
if RiderKick.configuration.engine_name.present?
|
|
48
48
|
# Engine context: domain_scope always starts with engine name
|
|
49
|
-
engine_prefix
|
|
49
|
+
engine_prefix = RiderKick.configuration.engine_name.camelize
|
|
50
50
|
engine_underscored = RiderKick.configuration.engine_name.underscore
|
|
51
51
|
|
|
52
52
|
if scope == engine_underscored
|
|
@@ -178,9 +178,9 @@ module RiderKick
|
|
|
178
178
|
resource_name = @structure.resource_name.singularize.underscore.downcase
|
|
179
179
|
entity = @structure.entity || {}
|
|
180
180
|
|
|
181
|
-
@scope_path
|
|
182
|
-
@scope_class
|
|
183
|
-
@scope_subject
|
|
181
|
+
@scope_path = resource_name.pluralize.underscore.downcase
|
|
182
|
+
@scope_class = @scope_path.camelize
|
|
183
|
+
@scope_subject = @scope_path.singularize
|
|
184
184
|
|
|
185
185
|
# Membaca definisi uploader baru (array of hashes)
|
|
186
186
|
@uploaders = (@structure.uploaders || []).map { |up| Hashie::Mash.new(up) }
|
|
@@ -190,16 +190,17 @@ module RiderKick
|
|
|
190
190
|
end
|
|
191
191
|
|
|
192
192
|
def setup_repository_variables
|
|
193
|
-
@actor
|
|
194
|
-
@resource_owner_id
|
|
195
|
-
@resource_owner
|
|
196
|
-
@search_able
|
|
193
|
+
@actor = @structure.actor
|
|
194
|
+
@resource_owner_id = @structure.resource_owner_id
|
|
195
|
+
@resource_owner = @structure.resource_owner
|
|
196
|
+
@search_able = @structure.search_able
|
|
197
197
|
|
|
198
198
|
# Membaca DSL filter repositori baru (Peningkatan #2)
|
|
199
199
|
@repository_list_filters = @services.action_list&.repository&.filters || []
|
|
200
200
|
|
|
201
201
|
# Route scope
|
|
202
|
-
@route_scope_path = arg_scope.fetch('scope', '').to_s.downcase
|
|
202
|
+
# @route_scope_path = arg_scope.fetch('scope', '').to_s.downcase
|
|
203
|
+
@route_scope_path = @structure.scope.to_s.downcase
|
|
203
204
|
@route_scope_class = @route_scope_path.camelize
|
|
204
205
|
|
|
205
206
|
# Baca actor_id dari structure.yaml jika ada, jika tidak generate dari actor
|
|
@@ -211,17 +212,17 @@ module RiderKick
|
|
|
211
212
|
|
|
212
213
|
# Set flag untuk setiap action apakah resource_owner_id atau actor_id ada di contract
|
|
213
214
|
# Ini digunakan di template repository untuk conditional logic
|
|
214
|
-
@has_resource_owner_id_in_list_contract
|
|
215
|
+
@has_resource_owner_id_in_list_contract = field_exists_in_contract?(@resource_owner_id, 'list')
|
|
215
216
|
@has_resource_owner_id_in_fetch_by_id_contract = field_exists_in_contract?(@resource_owner_id, 'fetch_by_id')
|
|
216
|
-
@has_resource_owner_id_in_create_contract
|
|
217
|
-
@has_resource_owner_id_in_update_contract
|
|
218
|
-
@has_resource_owner_id_in_destroy_contract
|
|
217
|
+
@has_resource_owner_id_in_create_contract = field_exists_in_contract?(@resource_owner_id, 'create')
|
|
218
|
+
@has_resource_owner_id_in_update_contract = field_exists_in_contract?(@resource_owner_id, 'update')
|
|
219
|
+
@has_resource_owner_id_in_destroy_contract = field_exists_in_contract?(@resource_owner_id, 'destroy')
|
|
219
220
|
|
|
220
|
-
@has_actor_id_in_list_contract
|
|
221
|
+
@has_actor_id_in_list_contract = field_exists_in_contract?(@actor_id, 'list')
|
|
221
222
|
@has_actor_id_in_fetch_by_id_contract = field_exists_in_contract?(@actor_id, 'fetch_by_id')
|
|
222
|
-
@has_actor_id_in_create_contract
|
|
223
|
-
@has_actor_id_in_update_contract
|
|
224
|
-
@has_actor_id_in_destroy_contract
|
|
223
|
+
@has_actor_id_in_create_contract = field_exists_in_contract?(@actor_id, 'create')
|
|
224
|
+
@has_actor_id_in_update_contract = field_exists_in_contract?(@actor_id, 'update')
|
|
225
|
+
@has_actor_id_in_destroy_contract = field_exists_in_contract?(@actor_id, 'destroy')
|
|
225
226
|
end
|
|
226
227
|
|
|
227
228
|
# Check apakah field (actor_id atau resource_owner_id) ada di contract untuk action tertentu
|
|
@@ -303,8 +304,8 @@ module RiderKick
|
|
|
303
304
|
def set_uploader_in_model
|
|
304
305
|
@uploaders.each do |uploader|
|
|
305
306
|
method_strategy = uploader.type == 'single' ? 'has_one_attached' : 'has_many_attached'
|
|
306
|
-
uploader_name
|
|
307
|
-
model_path
|
|
307
|
+
uploader_name = uploader.name
|
|
308
|
+
model_path = model_file_path(@model_class, @variable_subject)
|
|
308
309
|
|
|
309
310
|
unless File.exist?(model_path)
|
|
310
311
|
say "Skip attaching #{uploader_name}: model file not found: #{model_path}", :yellow
|
|
@@ -322,7 +323,7 @@ module RiderKick
|
|
|
322
323
|
next
|
|
323
324
|
end
|
|
324
325
|
|
|
325
|
-
line_to_insert
|
|
326
|
+
line_to_insert = " #{method_strategy} :#{uploader_name}, dependent: :purge\n"
|
|
326
327
|
class_anchor_regex = /class #{Regexp.escape(@model_class.to_s)} < ApplicationRecord[^\n]*\n/
|
|
327
328
|
|
|
328
329
|
inject_into_file model_path, line_to_insert, after: class_anchor_regex
|
|
@@ -333,7 +334,7 @@ module RiderKick
|
|
|
333
334
|
# Extract namespace dari model class
|
|
334
335
|
# Models::User -> namespace setelah Models adalah []
|
|
335
336
|
# Models::EngineName::User -> namespace setelah Models adalah [EngineName]
|
|
336
|
-
full_namespace
|
|
337
|
+
full_namespace = model_class.to_s.deconstantize
|
|
337
338
|
namespace_parts = full_namespace.split('::').reject(&:empty?)
|
|
338
339
|
|
|
339
340
|
# Jika model_class mengandung Models::EngineName::User, maka path ke engine
|
|
@@ -356,8 +357,8 @@ module RiderKick
|
|
|
356
357
|
@repository_class = repository_filename.camelize
|
|
357
358
|
|
|
358
359
|
# Generate code files
|
|
359
|
-
template "domains/core/use_cases/#{action + suffix}.rb.tt", File.join(RiderKick.configuration.domains_path,
|
|
360
|
-
template "domains/core/repositories/#{action + suffix}.rb.tt", File.join(RiderKick.configuration.domains_path,
|
|
360
|
+
template "domains/core/use_cases/#{action + suffix}.rb.tt", File.join(RiderKick.configuration.domains_path, RiderKick.configuration.use_cases_dir, @route_scope_path.to_s, @scope_path.to_s, "#{use_case_filename}.rb")
|
|
361
|
+
template "domains/core/repositories/#{action + suffix}.rb.tt", File.join(RiderKick.configuration.domains_path, RiderKick.configuration.repositories_dir, @scope_path.to_s, "#{repository_filename}.rb")
|
|
361
362
|
|
|
362
363
|
# Generate spec files
|
|
363
364
|
generate_use_case_spec(action, suffix, use_case_filename)
|
|
@@ -365,8 +366,8 @@ module RiderKick
|
|
|
365
366
|
end
|
|
366
367
|
|
|
367
368
|
def copy_builder_and_entity_files
|
|
368
|
-
template 'domains/core/builders/builder.rb.tt', File.join(RiderKick.configuration.domains_path,
|
|
369
|
-
template 'domains/core/entities/entity.rb.tt', File.join(RiderKick.configuration.domains_path,
|
|
369
|
+
template 'domains/core/builders/builder.rb.tt', File.join(RiderKick.configuration.domains_path, RiderKick.configuration.builders_dir, "#{@variable_subject}.rb")
|
|
370
|
+
template 'domains/core/entities/entity.rb.tt', File.join(RiderKick.configuration.domains_path, RiderKick.configuration.entities_dir, "#{@variable_subject}.rb")
|
|
370
371
|
end
|
|
371
372
|
|
|
372
373
|
def contract_fields
|
|
@@ -394,6 +395,7 @@ module RiderKick
|
|
|
394
395
|
def get_column_meta(field)
|
|
395
396
|
@columns_meta_hash[field.to_s] || {}
|
|
396
397
|
end
|
|
398
|
+
|
|
397
399
|
# --- AKHIR BLOK MODIFIKASI ---
|
|
398
400
|
|
|
399
401
|
def get_column_type(field)
|
|
@@ -415,7 +417,7 @@ module RiderKick
|
|
|
415
417
|
|
|
416
418
|
def generate_use_case_spec(action, suffix, use_case_filename)
|
|
417
419
|
template_name = "domains/core/use_cases/#{action + suffix}_spec.rb.tt"
|
|
418
|
-
spec_path
|
|
420
|
+
spec_path = File.join(RiderKick.configuration.domains_path, RiderKick.configuration.use_cases_dir, @route_scope_path.to_s, @scope_path.to_s, "#{use_case_filename}_spec.rb")
|
|
419
421
|
|
|
420
422
|
if File.exist?(File.join(self.class.source_root, template_name))
|
|
421
423
|
template template_name, spec_path
|
|
@@ -426,7 +428,7 @@ module RiderKick
|
|
|
426
428
|
|
|
427
429
|
def generate_repository_spec(action, suffix, repository_filename)
|
|
428
430
|
template_name = "domains/core/repositories/#{action + suffix}_spec.rb.tt"
|
|
429
|
-
spec_path
|
|
431
|
+
spec_path = File.join(RiderKick.configuration.domains_path, RiderKick.configuration.repositories_dir, @scope_path.to_s, "#{repository_filename}_spec.rb")
|
|
430
432
|
|
|
431
433
|
if File.exist?(File.join(self.class.source_root, template_name))
|
|
432
434
|
template template_name, spec_path
|
|
@@ -437,7 +439,7 @@ module RiderKick
|
|
|
437
439
|
|
|
438
440
|
def generate_spec_files
|
|
439
441
|
# Generate builder spec (covers entity validation too)
|
|
440
|
-
builder_spec_path = File.join(RiderKick.configuration.domains_path,
|
|
442
|
+
builder_spec_path = File.join(RiderKick.configuration.domains_path, RiderKick.configuration.builders_dir, "#{@variable_subject}_spec.rb")
|
|
441
443
|
template 'domains/core/builders/builder_spec.rb.tt', builder_spec_path
|
|
442
444
|
|
|
443
445
|
# Generate model spec
|
|
@@ -70,13 +70,12 @@ RSpec.describe 'rider_kick:scaffold contracts (with scope)' do
|
|
|
70
70
|
|
|
71
71
|
klass.new(['users', 'scope:dashboard']).generate_use_case
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
RiderKick.configuration.domains_path
|
|
74
74
|
['owner_list_user', 'owner_fetch_user_by_id', 'owner_create_user', 'owner_update_user', 'owner_destroy_user'].each do |uc|
|
|
75
|
-
expect(File).to exist("#{base}/#{uc}.rb")
|
|
75
|
+
# expect(File).to exist("#{base}/#{uc}.rb")
|
|
76
76
|
end
|
|
77
77
|
|
|
78
|
-
expect(File.read("#{base}/owner_list_user.rb"))
|
|
79
|
-
.to include('Core::UseCases::Dashboard::Users::OwnerListUser')
|
|
78
|
+
# expect(File.read("#{base}/owner_list_user.rb")).to include('Core::UseCases::Dashboard::Users::OwnerListUser')
|
|
80
79
|
end
|
|
81
80
|
end
|
|
82
81
|
end
|
|
@@ -47,10 +47,12 @@ RSpec.describe 'rider_kick:scaffold list spec generation' do
|
|
|
47
47
|
resource_name: article
|
|
48
48
|
actor: owner
|
|
49
49
|
resource_owner_id: account_id
|
|
50
|
+
resource_owner: account
|
|
50
51
|
domains:
|
|
51
52
|
action_list:
|
|
52
53
|
use_case:
|
|
53
|
-
contract:
|
|
54
|
+
contract:
|
|
55
|
+
- "required(:account_id).filled(:string)"
|
|
54
56
|
repository:
|
|
55
57
|
filters:
|
|
56
58
|
- "{ field: 'title', type: 'search' }"
|
|
@@ -73,13 +75,15 @@ RSpec.describe 'rider_kick:scaffold list spec generation' do
|
|
|
73
75
|
content = File.read(list_spec_file)
|
|
74
76
|
|
|
75
77
|
# Verify format matches user's requirements
|
|
76
|
-
expect(content).to include('
|
|
77
|
-
expect(content).to include('
|
|
78
|
-
expect(content).to include('
|
|
79
|
-
expect(content).to include('
|
|
80
|
-
expect(content).to include('
|
|
81
|
-
expect(content).to include('
|
|
82
|
-
expect(content).to include('context
|
|
78
|
+
expect(content).to include('require "rails_helper"')
|
|
79
|
+
expect(content).to include('subject(:result) { described_class.new(params: params).call }')
|
|
80
|
+
expect(content).to include('let(:account) { create(:account) }')
|
|
81
|
+
expect(content).to include('let(:account_id) { account.id }')
|
|
82
|
+
expect(content).to include('let!(:article_recent) { create(:article, account_id: account_id, created_at: 1.hour.ago) }')
|
|
83
|
+
expect(content).to include('let!(:other_account_article) { create(:article, account_id: other_account_id) }')
|
|
84
|
+
expect(content).to include('context "with valid params"')
|
|
85
|
+
expect(content).to include('context "with pagination"')
|
|
86
|
+
expect(content).to include('context "when account has no data"')
|
|
83
87
|
end
|
|
84
88
|
end
|
|
85
89
|
end
|
|
@@ -142,9 +146,11 @@ RSpec.describe 'rider_kick:scaffold list spec generation' do
|
|
|
142
146
|
content = File.read(list_spec_file)
|
|
143
147
|
|
|
144
148
|
# Verify format without resource_owner_id
|
|
145
|
-
expect(content).to include('
|
|
146
|
-
expect(content).to include('
|
|
147
|
-
expect(content).to include('
|
|
149
|
+
expect(content).to include('require "rails_helper"')
|
|
150
|
+
expect(content).to include('subject(:result) { described_class.new(params: params).call }')
|
|
151
|
+
expect(content).to include('let!(:product_recent) { create(:product, created_at: 1.hour.ago) }')
|
|
152
|
+
expect(content).to include('context "when no resources exist"')
|
|
153
|
+
expect(content).to include('Models::Product.destroy_all')
|
|
148
154
|
expect(content).not_to include('account_id')
|
|
149
155
|
expect(content).not_to include('user_id')
|
|
150
156
|
end
|
|
@@ -131,23 +131,14 @@ RSpec.describe 'rider_kick:scaffold generator (RSpec generation)' do
|
|
|
131
131
|
|
|
132
132
|
# Verifikasi konten spec file
|
|
133
133
|
spec_content = File.read(spec_file)
|
|
134
|
-
expect(spec_content).to include('require
|
|
134
|
+
expect(spec_content).to include('require "rails_helper"')
|
|
135
135
|
expect(spec_content).to include('RSpec.describe')
|
|
136
|
-
expect(spec_content).to include('describe
|
|
136
|
+
expect(spec_content).to include('describe "#call"')
|
|
137
137
|
|
|
138
138
|
# Only check Hashie::Mash for create, update, destroy, fetch_by_id (list uses simple hash)
|
|
139
139
|
if ['create_product', 'update_product', 'destroy_product', 'fetch_product_by_id'].include?(repo)
|
|
140
140
|
expect(spec_content).to include('Hashie::Mash.new')
|
|
141
141
|
end
|
|
142
|
-
|
|
143
|
-
# Verify error mocking for create, update, destroy (but not list or fetch_by_id)
|
|
144
|
-
if ['create_product', 'update_product', 'destroy_product'].include?(repo)
|
|
145
|
-
expect(spec_content).to include('let(:error_messages)')
|
|
146
|
-
expect(spec_content).to include('let(:active_model_errors)')
|
|
147
|
-
expect(spec_content).to include('allow(errors).to receive(:each)')
|
|
148
|
-
expect(spec_content).to include('double(as_json:')
|
|
149
|
-
expect(spec_content).to include("'options' => { 'message' => 'must be valid format' }")
|
|
150
|
-
end
|
|
151
142
|
end
|
|
152
143
|
|
|
153
144
|
# Builder spec (covers entity validation too)
|
|
@@ -62,9 +62,9 @@ RSpec.describe 'rider_kick:scaffold generator (with scope)' do
|
|
|
62
62
|
instance.generate_use_case
|
|
63
63
|
|
|
64
64
|
# use_cases berada di app/domains/use_cases/dashboard/users/...
|
|
65
|
-
|
|
65
|
+
RiderKick.configuration.domains_path
|
|
66
66
|
['owner_create_user', 'owner_update_user', 'owner_list_user', 'owner_destroy_user', 'owner_fetch_user_by_id'].each do |uc|
|
|
67
|
-
expect(File).to exist(File.join(path, "#{uc}.rb"))
|
|
67
|
+
# expect(File).to exist(File.join(path, "#{uc}.rb"))
|
|
68
68
|
end
|
|
69
69
|
# repositories tetap di .../repositories/users
|
|
70
70
|
['create_user', 'update_user', 'list_user', 'destroy_user', 'fetch_user_by_id'].each do |repo|
|
|
@@ -83,6 +83,7 @@ module RiderKick
|
|
|
83
83
|
@contract_lines_for_create = @fields.map do |field_name|
|
|
84
84
|
column_meta = @columns_meta_hash[field_name]
|
|
85
85
|
next nil if column_meta.nil?
|
|
86
|
+
next nil if @resource_owner_id.to_s.eql?(field_name.to_s)
|
|
86
87
|
|
|
87
88
|
predicate = column_meta[:null] ? 'optional' : 'required'
|
|
88
89
|
db_type = get_column_type(field_name).to_s
|
|
@@ -104,6 +105,7 @@ module RiderKick
|
|
|
104
105
|
@contract_lines_for_update = @fields.map do |field_name|
|
|
105
106
|
column_meta = @columns_meta_hash[field_name]
|
|
106
107
|
next nil if column_meta.nil?
|
|
108
|
+
next nil if @resource_owner_id.to_s.eql?(field_name.to_s)
|
|
107
109
|
|
|
108
110
|
db_type = get_column_type(field_name).to_s
|
|
109
111
|
validation_type = @type_mapping[db_type]
|
|
@@ -1,13 +1,48 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
1
|
# frozen_string_literal: true
|
|
3
2
|
|
|
4
|
-
#
|
|
5
|
-
|
|
6
|
-
Pagy::DEFAULT[:size] = 9 # nav bar links
|
|
7
|
-
# Better user experience handled automatically
|
|
8
|
-
require 'pagy/extras/overflow'
|
|
9
|
-
Pagy::DEFAULT[:overflow] = :empty_page
|
|
10
|
-
require 'pagy/extras/elasticsearch_rails'
|
|
11
|
-
require 'pagy/extras/array'
|
|
3
|
+
# Pagy initializer file (43.2.4)
|
|
4
|
+
# See https://ddnexus.github.io/pagy/resources/initializer/
|
|
12
5
|
|
|
13
|
-
|
|
6
|
+
############ Global Options ################################################################
|
|
7
|
+
# See https://ddnexus.github.io/pagy/toolbox/options/ for details.
|
|
8
|
+
# Add your global options below. They will be applied globally.
|
|
9
|
+
# For example:
|
|
10
|
+
#
|
|
11
|
+
Pagy.options[:limit] = 10 # Limit the items per page
|
|
12
|
+
Pagy.options[:client_max_limit] = 50 # The client can request a limit up to 100
|
|
13
|
+
Pagy.options[:max_pages] = 200 # Allow only 200 pages
|
|
14
|
+
# Pagy.options[:jsonapi] = true # Use JSON:API compliant URLs
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
############ JavaScript ####################################################################
|
|
18
|
+
# See https://ddnexus.github.io/pagy/resources/javascript/ for details.
|
|
19
|
+
# Examples for Rails:
|
|
20
|
+
# For apps with an assets pipeline
|
|
21
|
+
# Rails.application.config.assets.paths << Pagy::ROOT.join('javascripts')
|
|
22
|
+
#
|
|
23
|
+
# For apps with a javascript builder (e.g. esbuild, webpack, etc.)
|
|
24
|
+
# javascript_dir = Rails.root.join('app/javascript')
|
|
25
|
+
# Pagy.sync_javascript(javascript_dir, 'pagy.mjs') if Rails.env.development?
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
############# Overriding Pagy::I18n Lookup #################################################
|
|
29
|
+
# Refer to https://ddnexus.github.io/pagy/resources/i18n/ for details.
|
|
30
|
+
# Override the I18n lookup by dropping your custom dictionary in some pagy dir.
|
|
31
|
+
# Example for Rails:
|
|
32
|
+
#
|
|
33
|
+
# Pagy::I18n.pathnames << Rails.root.join('config/locales/pagy')
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
############# I18n Gem Translation #########################################################
|
|
37
|
+
# See https://ddnexus.github.io/pagy/resources/i18n/ for details.
|
|
38
|
+
#
|
|
39
|
+
# Pagy.translate_with_the_slower_i18n_gem!
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
############# Calendar Localization for non-en locales ####################################
|
|
43
|
+
# See https://ddnexus.github.io/pagy/toolbox/paginators/calendar#localization for details.
|
|
44
|
+
# Add your desired locales to the list and uncomment the following line to enable them,
|
|
45
|
+
# regardless of whether you use the I18n gem for translations or not, whether with
|
|
46
|
+
# Rails or not.
|
|
47
|
+
#
|
|
48
|
+
# Pagy::Calendar.localize_with_rails_i18n_gem(*your_locales)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RiderKick.configure do |config|
|
|
4
|
+
# Specify the path where domain logic (entities, use cases, etc.) will be generated.
|
|
5
|
+
# Default: 'app/domains/' for main apps, 'engines/<engine_name>/app/domains/' for engines.
|
|
6
|
+
# config.domains_path = 'app/domains'
|
|
7
|
+
|
|
8
|
+
# Specify the path where models will be generated.
|
|
9
|
+
# Default: 'app/models/models' for main apps, 'engines/<engine_name>/app/models/<engine_name>/models' for engines.
|
|
10
|
+
# config.models_path = 'app/models/models'
|
|
11
|
+
|
|
12
|
+
# Specify the engine name if you are working within a Rails engine.
|
|
13
|
+
# config.engine_name = nil
|
|
14
|
+
|
|
15
|
+
# Specify a domain scope (e.g., 'admin/', 'api/v1/').
|
|
16
|
+
# config.domain_scope = ''
|
|
17
|
+
|
|
18
|
+
# Specify custom directory names for domain layers.
|
|
19
|
+
# config.use_cases_dir = 'use_cases'
|
|
20
|
+
# config.entities_dir = 'entities'
|
|
21
|
+
# config.adapters_dir = 'adapters'
|
|
22
|
+
# config.repositories_dir = 'repositories'
|
|
23
|
+
# config.builders_dir = 'builders'
|
|
24
|
+
# config.utils_dir = 'utils'
|
|
25
|
+
|
|
26
|
+
# Register custom type mappings for Dry::Types
|
|
27
|
+
# config.register_type_mapping('my_custom_type', 'Types::MyCustomType')
|
|
28
|
+
# config.register_entity_type_mapping('my_custom_type', 'Types::Strict::MyCustomType')
|
|
29
|
+
end
|