iknow_view_models 3.6.2 → 3.6.5
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/.circleci/config.yml +10 -10
- data/lib/iknow_view_models/version.rb +1 -1
- data/lib/view_model/access_control/composed.rb +19 -10
- data/lib/view_model/access_control/tree.rb +4 -6
- data/lib/view_model/migration/no_path_error.rb +1 -1
- data/lib/view_model.rb +1 -0
- data/test/unit/view_model/access_control_test.rb +20 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea15135f8f921a083f88184fb1602c2cb1ab1654845bf7d29b5d6a35ce4a1e93
|
4
|
+
data.tar.gz: cbb335d8125222a4e5efdb6fc5ae6317a6c1e74d86270885b68d2e482742f392
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cde2777790785631ba0407ddd576931b05257bb1f51544927c4f9750ec0472cd45f87a9cfc3536271ead56f7b7decbc548f3f401ca23ae48a28bb11c2a6b67dd
|
7
|
+
data.tar.gz: 0bc8000d9cdf342248e2c9cd24e40f8fd4386f34b01891b022785747f9eda8474a19201cc1c72af8d526632ca9493d97eef00e59da3c683ba7bd8d1083790cc2
|
data/.circleci/config.yml
CHANGED
@@ -8,7 +8,7 @@ executors:
|
|
8
8
|
default: "2.7"
|
9
9
|
pg-version:
|
10
10
|
type: string
|
11
|
-
default: "
|
11
|
+
default: "12.10"
|
12
12
|
gemfile:
|
13
13
|
type: string
|
14
14
|
default: "Gemfile"
|
@@ -16,14 +16,14 @@ executors:
|
|
16
16
|
PGHOST: 127.0.0.1
|
17
17
|
PGUSER: eikaiwa
|
18
18
|
docker:
|
19
|
-
- image:
|
19
|
+
- image: cimg/ruby:<< parameters.ruby-version >>
|
20
20
|
environment:
|
21
21
|
BUNDLE_JOBS: 3
|
22
22
|
BUNDLE_RETRY: 3
|
23
23
|
BUNDLE_PATH: vendor/bundle
|
24
24
|
RAILS_ENV: test
|
25
25
|
BUNDLE_GEMFILE: << parameters.gemfile >>
|
26
|
-
- image:
|
26
|
+
- image: cimg/postgres:<< parameters.pg-version >>
|
27
27
|
environment:
|
28
28
|
POSTGRES_USER: eikaiwa
|
29
29
|
POSTGRES_DB: iknow_view_models
|
@@ -104,27 +104,27 @@ workflows:
|
|
104
104
|
- test:
|
105
105
|
name: 'ruby 2.7 rails 5.2 pg 12'
|
106
106
|
ruby-version: "2.7"
|
107
|
-
pg-version: "12"
|
107
|
+
pg-version: "12.10"
|
108
108
|
gemfile: gemfiles/rails_5_2.gemfile
|
109
109
|
- test:
|
110
110
|
name: 'ruby 2.7 rails 6.0 pg 12'
|
111
111
|
ruby-version: "2.7"
|
112
|
-
pg-version: "12"
|
112
|
+
pg-version: "12.10"
|
113
113
|
gemfile: gemfiles/rails_6_0.gemfile
|
114
114
|
- test:
|
115
115
|
name: 'ruby 2.7 rails 6.1 pg 12'
|
116
116
|
ruby-version: "2.7"
|
117
|
-
pg-version: "12"
|
117
|
+
pg-version: "12.10"
|
118
118
|
gemfile: gemfiles/rails_6_1.gemfile
|
119
119
|
- test:
|
120
120
|
name: 'ruby 3.0 rails 6.1 pg 12'
|
121
121
|
ruby-version: "3.0"
|
122
|
-
pg-version: "12"
|
122
|
+
pg-version: "12.10"
|
123
123
|
gemfile: gemfiles/rails_6_1.gemfile
|
124
124
|
- test:
|
125
|
-
name: 'ruby 3.
|
126
|
-
ruby-version: "3.
|
127
|
-
pg-version: "
|
125
|
+
name: 'ruby 3.1 rails 7.0 pg 13'
|
126
|
+
ruby-version: "3.1"
|
127
|
+
pg-version: "13.6"
|
128
128
|
gemfile: gemfiles/rails_7_0.gemfile
|
129
129
|
- publish:
|
130
130
|
filters:
|
@@ -39,10 +39,20 @@ class ViewModel::AccessControl::Composed < ViewModel::AccessControl
|
|
39
39
|
case
|
40
40
|
when new_allow
|
41
41
|
nil
|
42
|
-
when
|
43
|
-
|
42
|
+
when self.allow_error.nil?
|
43
|
+
other.allow_error
|
44
|
+
when other.allow_error.nil?
|
45
|
+
self.allow_error
|
46
|
+
# Mergeable (standard) errors should be merged if possible; if not
|
47
|
+
# possible, we should take the first non-standard error.
|
48
|
+
when mergeable_error?(self.allow_error)
|
49
|
+
if mergeable_error?(other.allow_error)
|
50
|
+
self.allow_error.merge(other.allow_error)
|
51
|
+
else
|
52
|
+
other.allow_error
|
53
|
+
end
|
44
54
|
else
|
45
|
-
self.allow_error
|
55
|
+
self.allow_error
|
46
56
|
end
|
47
57
|
|
48
58
|
ComposedResult.new(new_allow, other.veto, new_allow_error, other.veto_error)
|
@@ -52,7 +62,7 @@ class ViewModel::AccessControl::Composed < ViewModel::AccessControl
|
|
52
62
|
private
|
53
63
|
|
54
64
|
def mergeable_error?(err)
|
55
|
-
err
|
65
|
+
err.is_a?(NoRequiredConditionsError)
|
56
66
|
end
|
57
67
|
end
|
58
68
|
|
@@ -160,16 +170,15 @@ class ViewModel::AccessControl::Composed < ViewModel::AccessControl
|
|
160
170
|
next unless visited.add?(ancestor)
|
161
171
|
next if include_ancestor && !include_ancestor.call(ancestor)
|
162
172
|
|
163
|
-
ancestor.each_check(check_name) { |x| yield x }
|
173
|
+
ancestor.each_check(check_name, include_ancestor) { |x| yield x }
|
164
174
|
end
|
165
175
|
end
|
166
176
|
|
167
177
|
def inspect
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
s
|
178
|
+
checks = inspect_checks
|
179
|
+
checks << "includes checkers: #{@included_checkers.inspect}" if @included_checkers.present?
|
180
|
+
|
181
|
+
super + '(' + checks.join(', ') + ')'
|
173
182
|
end
|
174
183
|
|
175
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
|
256
|
-
self.class.each_check(:root_children_visible_unlesses, ->(a) { a
|
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
|
264
|
-
self.class.each_check(:root_children_editable_unlesses, ->(a) { a
|
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
|
@@ -14,7 +14,7 @@ class ViewModel::Migration::NoPathError < ViewModel::AbstractError
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def detail
|
17
|
-
"No migration path for #{vm_name}
|
17
|
+
"No migration path for #{vm_name} between client version #{from} and server version #{to}"
|
18
18
|
end
|
19
19
|
|
20
20
|
def meta
|
data/lib/view_model.rb
CHANGED
@@ -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.
|
4
|
+
version: 3.6.5
|
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-
|
11
|
+
date: 2022-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -509,7 +509,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
509
509
|
- !ruby/object:Gem::Version
|
510
510
|
version: '0'
|
511
511
|
requirements: []
|
512
|
-
rubygems_version: 3.
|
512
|
+
rubygems_version: 3.3.11
|
513
513
|
signing_key:
|
514
514
|
specification_version: 4
|
515
515
|
summary: ViewModels provide a means of encapsulating a collection of related data
|