iknow_view_models 3.6.3 → 3.6.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0f71d69093b0d35214edcfe799aa3fc4493e0640a349e93c828e0158260d4b6c
4
- data.tar.gz: 2c2368cd3b0bb27f37ef8e609eae6a396d4de12c4555b90c153386e8bd2a9998
3
+ metadata.gz: 31ecbd493e6716db0442e309c1566f38c13f676ef72a55ea9708f1537875331f
4
+ data.tar.gz: b03d5b1b1f0d3ba458f11f5575f379969eea72089f781ef65462ab47e181e158
5
5
  SHA512:
6
- metadata.gz: c27c10d2940db8b9ed7f0ec512873053f4a2d94283d11004d68b4b70153f696fe3fd45aa103f7ee02ed75fbf3c5d0d8ac899b9df769196308cf67c32dbb3af35
7
- data.tar.gz: 882931e849905b9caaf8af154725339b7cda761b1f3ad2deb4d93c4f489cb11c8699143df1e907e51d572ec0a93c07d2f960c86f3e6c35b844d2f86c2839eb66
6
+ metadata.gz: 06e8384611d8fe7e93ac6065c11aca651f15b717be02a0818106198b769fe6ea59c843a83fd7cd457089a44a98cda499e7f5a2ae905d6c4b46c04e18c68cd4af
7
+ data.tar.gz: 3c20e972b8a5011aeae40494bf8d271ec3ef5092bbccb7495ea435a7e99dbf45b89f632e868c56bdf681722251f4432e6bd426dba2bfd9d2ef93cce7fc71c066
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IknowViewModels
4
- VERSION = '3.6.3'
4
+ VERSION = '3.6.4'
5
5
  end
@@ -175,11 +175,10 @@ class ViewModel::AccessControl::Composed < ViewModel::AccessControl
175
175
  end
176
176
 
177
177
  def inspect
178
- s = super + '('
179
- s += inspect_checks.join(', ')
180
- s += " includes checkers: #{@included_checkers.inspect}" if @included_checkers.present?
181
- s += ')'
182
- s
178
+ checks = inspect_checks
179
+ checks << "includes checkers: #{@included_checkers.inspect}" if @included_checkers.present?
180
+
181
+ super + '(' + checks.join(', ') + ')'
183
182
  end
184
183
 
185
184
  def inspect_checks
@@ -192,8 +192,6 @@ class ViewModel::AccessControl::Tree < ViewModel::AccessControl
192
192
  def inspect_checks
193
193
  checks = super
194
194
  if root?
195
- checks << 'no root checks'
196
- else
197
195
  checks << "root_children_visible_if: #{root_children_visible_ifs.map(&:reason)}" if root_children_visible_ifs.present?
198
196
  checks << "root_children_visible_unless: #{root_children_visible_unlesses.map(&:reason)}" if root_children_visible_unlesses.present?
199
197
  checks << "root_children_editable_if: #{root_children_editable_ifs.map(&:reason)}" if root_children_editable_ifs.present?
@@ -252,16 +250,16 @@ class ViewModel::AccessControl::Tree < ViewModel::AccessControl
252
250
 
253
251
  def save_root_visibility!(traversal_env)
254
252
  result = check_delegates(traversal_env,
255
- self.class.each_check(:root_children_visible_ifs, ->(a) { a.is_a?(Node) }),
256
- self.class.each_check(:root_children_visible_unlesses, ->(a) { a.is_a?(Node) }))
253
+ self.class.each_check(:root_children_visible_ifs, ->(a) { a < Node }),
254
+ self.class.each_check(:root_children_visible_unlesses, ->(a) { a < Node }))
257
255
 
258
256
  store_descendent_visibility(traversal_env.view, result)
259
257
  end
260
258
 
261
259
  def save_root_editability!(traversal_env)
262
260
  result = check_delegates(traversal_env,
263
- self.class.each_check(:root_children_editable_ifs, ->(a) { a.is_a?(Node) }),
264
- self.class.each_check(:root_children_editable_unlesses, ->(a) { a.is_a?(Node) }))
261
+ self.class.each_check(:root_children_editable_ifs, ->(a) { a < Node }),
262
+ self.class.each_check(:root_children_editable_unlesses, ->(a) { a < Node }))
265
263
 
266
264
  store_descendent_editability(traversal_env.view, result)
267
265
  end
@@ -319,6 +319,26 @@ class ViewModel::AccessControlTest < ActiveSupport::TestCase
319
319
  assert_serializes(Tree1View, make_tree('rule:visible_children', 'visible child', 'rule:visible_children', 'visible child'))
320
320
  end
321
321
 
322
+ def test_root_inheritance
323
+ parent_access_control = Class.new(ViewModel::AccessControl::Tree)
324
+ parent_access_control.view 'Tree1' do
325
+ visible_if!('true') { true }
326
+
327
+ root_children_visible_if!('root children visible') do
328
+ view.val == 'rule:visible_children'
329
+ end
330
+ end
331
+
332
+ TestAccessControl.include_from(parent_access_control)
333
+
334
+ refute_serializes(Tree1View, make_tree('arbitrary parent', 'invisible child'))
335
+ assert_serializes(Tree1View, make_tree('rule:visible_children', 'visible child'))
336
+
337
+ # nested root
338
+ refute_serializes(Tree1View, make_tree('rule:visible_children', 'visible child', 'arbitrary parent', 'invisible child'))
339
+ assert_serializes(Tree1View, make_tree('rule:visible_children', 'visible child', 'rule:visible_children', 'visible child'))
340
+ end
341
+
322
342
  def test_visibility_veto_from_root
323
343
  TestAccessControl.view 'Tree1' do
324
344
  root_children_visible_unless!('root children invisible') do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iknow_view_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.3
4
+ version: 3.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - iKnow Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-23 00:00:00.000000000 Z
11
+ date: 2022-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack