rails_ops 1.4.2 → 1.4.4
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/.gitignore +1 -0
- data/CHANGELOG.md +17 -2
- data/README.md +12 -2
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/lib/generators/operation/operation_generator.rb +54 -7
- data/lib/generators/operation/templates/controller.erb +34 -23
- data/lib/generators/operation/templates/controller_wrapper.erb +14 -0
- data/lib/rails_ops/hookup/dsl_validator.rb +1 -1
- data/lib/rails_ops/hookup.rb +1 -1
- data/lib/rails_ops/mixins/sub_ops.rb +2 -0
- data/lib/rails_ops/operation.rb +1 -1
- data/rails_ops.gemspec +6 -5
- data/test/dummy/app/controllers/group_controller.rb +28 -0
- data/test/dummy/app/models/ability.rb +7 -0
- data/test/dummy/app/models/animal.rb +5 -1
- data/test/dummy/app/models/bird.rb +3 -1
- data/test/dummy/app/models/phoenix.rb +3 -1
- data/test/dummy/config/environments/development.rb +2 -0
- data/test/dummy/config/environments/production.rb +2 -0
- data/test/dummy/config/hookup.rb +5 -0
- data/test/dummy/config/routes.rb +1 -0
- data/test/test_helper.rb +5 -0
- data/test/unit/rails_ops/generators/operation_generator_test.rb +98 -0
- data/test/unit/rails_ops/hookup_test.rb +82 -0
- data/test/unit/rails_ops/mixins/controller_test.rb +21 -0
- data/test/unit/rails_ops/mixins/model/deep_nesting_test.rb +62 -2
- data/test/unit/rails_ops/mixins/model/marshalling_test.rb +36 -0
- data/test/unit/rails_ops/operation/auth_test.rb +120 -0
- data/test/unit/rails_ops/operation/model/destroy_test.rb +31 -0
- data/test/unit/rails_ops/operation/model/load_test.rb +9 -0
- data/test/unit/rails_ops/operation/model_test.rb +24 -0
- data/test/unit/rails_ops/operation_test.rb +121 -0
- data/test/unit/rails_ops/profiler_test.rb +11 -0
- metadata +36 -5
- data/test/unit/rails_ops/operation/update_auth_test.rb +0 -64
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_ops
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sitrox
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: appraisal
|
@@ -136,6 +136,20 @@ dependencies:
|
|
136
136
|
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: simplecov
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
139
153
|
- !ruby/object:Gem::Dependency
|
140
154
|
name: active_type
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -236,6 +250,7 @@ files:
|
|
236
250
|
- lib/generators/operation/USAGE
|
237
251
|
- lib/generators/operation/operation_generator.rb
|
238
252
|
- lib/generators/operation/templates/controller.erb
|
253
|
+
- lib/generators/operation/templates/controller_wrapper.erb
|
239
254
|
- lib/generators/operation/templates/create.erb
|
240
255
|
- lib/generators/operation/templates/destroy.erb
|
241
256
|
- lib/generators/operation/templates/load.erb
|
@@ -300,9 +315,11 @@ files:
|
|
300
315
|
- test/dummy/app/channels/application_cable/connection.rb
|
301
316
|
- test/dummy/app/controllers/application_controller.rb
|
302
317
|
- test/dummy/app/controllers/concerns/.keep
|
318
|
+
- test/dummy/app/controllers/group_controller.rb
|
303
319
|
- test/dummy/app/helpers/application_helper.rb
|
304
320
|
- test/dummy/app/jobs/application_job.rb
|
305
321
|
- test/dummy/app/mailers/application_mailer.rb
|
322
|
+
- test/dummy/app/models/ability.rb
|
306
323
|
- test/dummy/app/models/animal.rb
|
307
324
|
- test/dummy/app/models/application_record.rb
|
308
325
|
- test/dummy/app/models/bird.rb
|
@@ -335,6 +352,7 @@ files:
|
|
335
352
|
- test/dummy/config/environments/development.rb
|
336
353
|
- test/dummy/config/environments/production.rb
|
337
354
|
- test/dummy/config/environments/test.rb
|
355
|
+
- test/dummy/config/hookup.rb
|
338
356
|
- test/dummy/config/initializers/application_controller_renderer.rb
|
339
357
|
- test/dummy/config/initializers/assets.rb
|
340
358
|
- test/dummy/config/initializers/backtrace_silencers.rb
|
@@ -362,17 +380,22 @@ files:
|
|
362
380
|
- test/dummy/tmp/.keep
|
363
381
|
- test/test_helper.rb
|
364
382
|
- test/unit/rails_ops/generators/operation_generator_test.rb
|
383
|
+
- test/unit/rails_ops/hookup_test.rb
|
384
|
+
- test/unit/rails_ops/mixins/controller_test.rb
|
365
385
|
- test/unit/rails_ops/mixins/model/deep_nesting_test.rb
|
386
|
+
- test/unit/rails_ops/mixins/model/marshalling_test.rb
|
366
387
|
- test/unit/rails_ops/mixins/param_authorization_test.rb
|
367
388
|
- test/unit/rails_ops/mixins/policies_test.rb
|
389
|
+
- test/unit/rails_ops/operation/auth_test.rb
|
368
390
|
- test/unit/rails_ops/operation/model/create_test.rb
|
391
|
+
- test/unit/rails_ops/operation/model/destroy_test.rb
|
369
392
|
- test/unit/rails_ops/operation/model/load_test.rb
|
370
393
|
- test/unit/rails_ops/operation/model/sti_test.rb
|
371
394
|
- test/unit/rails_ops/operation/model/update_test.rb
|
372
395
|
- test/unit/rails_ops/operation/model_test.rb
|
373
|
-
- test/unit/rails_ops/operation/update_auth_test.rb
|
374
396
|
- test/unit/rails_ops/operation/update_lazy_auth_test.rb
|
375
397
|
- test/unit/rails_ops/operation_test.rb
|
398
|
+
- test/unit/rails_ops/profiler_test.rb
|
376
399
|
homepage:
|
377
400
|
licenses: []
|
378
401
|
metadata: {}
|
@@ -391,7 +414,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
391
414
|
- !ruby/object:Gem::Version
|
392
415
|
version: '0'
|
393
416
|
requirements: []
|
394
|
-
rubygems_version: 3.4.
|
417
|
+
rubygems_version: 3.4.10
|
395
418
|
signing_key:
|
396
419
|
specification_version: 4
|
397
420
|
summary: An operations service layer for rails projects.
|
@@ -409,9 +432,11 @@ test_files:
|
|
409
432
|
- test/dummy/app/channels/application_cable/connection.rb
|
410
433
|
- test/dummy/app/controllers/application_controller.rb
|
411
434
|
- test/dummy/app/controllers/concerns/.keep
|
435
|
+
- test/dummy/app/controllers/group_controller.rb
|
412
436
|
- test/dummy/app/helpers/application_helper.rb
|
413
437
|
- test/dummy/app/jobs/application_job.rb
|
414
438
|
- test/dummy/app/mailers/application_mailer.rb
|
439
|
+
- test/dummy/app/models/ability.rb
|
415
440
|
- test/dummy/app/models/animal.rb
|
416
441
|
- test/dummy/app/models/application_record.rb
|
417
442
|
- test/dummy/app/models/bird.rb
|
@@ -444,6 +469,7 @@ test_files:
|
|
444
469
|
- test/dummy/config/environments/development.rb
|
445
470
|
- test/dummy/config/environments/production.rb
|
446
471
|
- test/dummy/config/environments/test.rb
|
472
|
+
- test/dummy/config/hookup.rb
|
447
473
|
- test/dummy/config/initializers/application_controller_renderer.rb
|
448
474
|
- test/dummy/config/initializers/assets.rb
|
449
475
|
- test/dummy/config/initializers/backtrace_silencers.rb
|
@@ -471,14 +497,19 @@ test_files:
|
|
471
497
|
- test/dummy/tmp/.keep
|
472
498
|
- test/test_helper.rb
|
473
499
|
- test/unit/rails_ops/generators/operation_generator_test.rb
|
500
|
+
- test/unit/rails_ops/hookup_test.rb
|
501
|
+
- test/unit/rails_ops/mixins/controller_test.rb
|
474
502
|
- test/unit/rails_ops/mixins/model/deep_nesting_test.rb
|
503
|
+
- test/unit/rails_ops/mixins/model/marshalling_test.rb
|
475
504
|
- test/unit/rails_ops/mixins/param_authorization_test.rb
|
476
505
|
- test/unit/rails_ops/mixins/policies_test.rb
|
506
|
+
- test/unit/rails_ops/operation/auth_test.rb
|
477
507
|
- test/unit/rails_ops/operation/model/create_test.rb
|
508
|
+
- test/unit/rails_ops/operation/model/destroy_test.rb
|
478
509
|
- test/unit/rails_ops/operation/model/load_test.rb
|
479
510
|
- test/unit/rails_ops/operation/model/sti_test.rb
|
480
511
|
- test/unit/rails_ops/operation/model/update_test.rb
|
481
512
|
- test/unit/rails_ops/operation/model_test.rb
|
482
|
-
- test/unit/rails_ops/operation/update_auth_test.rb
|
483
513
|
- test/unit/rails_ops/operation/update_lazy_auth_test.rb
|
484
514
|
- test/unit/rails_ops/operation_test.rb
|
515
|
+
- test/unit/rails_ops/profiler_test.rb
|
@@ -1,64 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'rails_ops/authorization_backend/can_can_can'
|
3
|
-
require 'cancancan'
|
4
|
-
|
5
|
-
class RailsOps::Operation::UpdateLazyAuthTest < ActiveSupport::TestCase
|
6
|
-
include TestHelper
|
7
|
-
|
8
|
-
BASIC_OP = Class.new(RailsOps::Operation::Model::Update) do
|
9
|
-
model ::Group
|
10
|
-
|
11
|
-
model_authorization_action :update
|
12
|
-
|
13
|
-
def perform
|
14
|
-
fail osparams.exception if osparams.exception
|
15
|
-
@done = true
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
ABILITY = Class.new do
|
20
|
-
include CanCan::Ability
|
21
|
-
|
22
|
-
def initialize(read: false, update: false)
|
23
|
-
super()
|
24
|
-
|
25
|
-
can :read, Group if read
|
26
|
-
can :update, Group if update
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
setup do
|
31
|
-
Group.create!(id: 1, name: 'Group')
|
32
|
-
RailsOps.config.authorization_backend = 'RailsOps::AuthorizationBackend::CanCanCan'
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_unpermitted_read
|
36
|
-
ctx = RailsOps::Context.new(ability: ABILITY.new(read: true))
|
37
|
-
assert_raises CanCan::AccessDenied do
|
38
|
-
BASIC_OP.new(ctx, id: 1)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_permitted_read
|
43
|
-
ctx = RailsOps::Context.new(ability: ABILITY.new(read: true))
|
44
|
-
assert_nothing_raised do
|
45
|
-
BASIC_OP.new(ctx, id: 1)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_unpermitted_update
|
50
|
-
ctx = RailsOps::Context.new(ability: ABILITY.new(read: true))
|
51
|
-
op = BASIC_OP.new(ctx, id: 1)
|
52
|
-
assert_raises CanCan::AccessDenied do
|
53
|
-
op.run!
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_permitted_update
|
58
|
-
ctx = RailsOps::Context.new(ability: ABILITY.new(read: true, update: true))
|
59
|
-
op = BASIC_OP.new(ctx, id: 1)
|
60
|
-
assert_nothing_raised do
|
61
|
-
op.run!
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|