iknow_view_models 3.2.0 → 3.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +13 -0
- data/Appraisals +6 -6
- data/Rakefile +5 -5
- data/gemfiles/rails_5_2.gemfile +5 -5
- data/gemfiles/rails_6_0.gemfile +5 -5
- data/iknow_view_models.gemspec +40 -39
- data/lib/iknow_view_models.rb +9 -7
- data/lib/iknow_view_models/version.rb +1 -1
- data/lib/view_model.rb +17 -14
- data/lib/view_model/access_control.rb +5 -2
- data/lib/view_model/access_control/composed.rb +10 -9
- data/lib/view_model/access_control/open.rb +2 -0
- data/lib/view_model/access_control/read_only.rb +2 -0
- data/lib/view_model/access_control/tree.rb +11 -6
- data/lib/view_model/access_control_error.rb +4 -1
- data/lib/view_model/active_record.rb +12 -11
- data/lib/view_model/active_record/association_data.rb +2 -1
- data/lib/view_model/active_record/association_manipulation.rb +6 -4
- data/lib/view_model/active_record/cache.rb +4 -2
- data/lib/view_model/active_record/collection_nested_controller.rb +3 -3
- data/lib/view_model/active_record/controller_base.rb +4 -1
- data/lib/view_model/active_record/nested_controller_base.rb +1 -0
- data/lib/view_model/active_record/update_context.rb +8 -6
- data/lib/view_model/active_record/update_data.rb +32 -30
- data/lib/view_model/active_record/update_operation.rb +17 -13
- data/lib/view_model/active_record/visitor.rb +0 -1
- data/lib/view_model/after_transaction_runner.rb +0 -1
- data/lib/view_model/callbacks.rb +3 -1
- data/lib/view_model/controller.rb +13 -3
- data/lib/view_model/deserialization_error.rb +15 -12
- data/lib/view_model/error.rb +12 -10
- data/lib/view_model/error_view.rb +3 -1
- data/lib/view_model/migration/no_path_error.rb +1 -0
- data/lib/view_model/migration/one_way_error.rb +1 -0
- data/lib/view_model/migration/unspecified_version_error.rb +1 -0
- data/lib/view_model/record.rb +11 -13
- data/lib/view_model/reference.rb +3 -1
- data/lib/view_model/references.rb +8 -5
- data/lib/view_model/registry.rb +1 -1
- data/lib/view_model/schemas.rb +9 -4
- data/lib/view_model/serialization_error.rb +4 -1
- data/lib/view_model/serialize_context.rb +4 -4
- data/lib/view_model/test_helpers.rb +8 -3
- data/lib/view_model/test_helpers/arvm_builder.rb +19 -14
- data/lib/view_model/traversal_context.rb +2 -1
- data/test/.rubocop.yml +14 -0
- data/test/helpers/arvm_test_models.rb +12 -9
- data/test/helpers/arvm_test_utilities.rb +5 -3
- data/test/helpers/controller_test_helpers.rb +31 -29
- data/test/helpers/match_enumerator.rb +1 -0
- data/test/helpers/query_logging.rb +2 -1
- data/test/helpers/test_access_control.rb +5 -3
- data/test/helpers/viewmodel_spec_helpers.rb +21 -20
- data/test/unit/view_model/access_control_test.rb +144 -144
- data/test/unit/view_model/active_record/alias_test.rb +15 -13
- data/test/unit/view_model/active_record/belongs_to_test.rb +40 -39
- data/test/unit/view_model/active_record/cache_test.rb +27 -26
- data/test/unit/view_model/active_record/cloner_test.rb +67 -63
- data/test/unit/view_model/active_record/controller_test.rb +37 -38
- data/test/unit/view_model/active_record/counter_test.rb +10 -9
- data/test/unit/view_model/active_record/customization_test.rb +59 -58
- data/test/unit/view_model/active_record/has_many_test.rb +112 -111
- data/test/unit/view_model/active_record/has_many_through_poly_test.rb +15 -14
- data/test/unit/view_model/active_record/has_many_through_test.rb +33 -38
- data/test/unit/view_model/active_record/has_one_test.rb +37 -36
- data/test/unit/view_model/active_record/migration_test.rb +13 -13
- data/test/unit/view_model/active_record/namespacing_test.rb +19 -17
- data/test/unit/view_model/active_record/poly_test.rb +44 -45
- data/test/unit/view_model/active_record/shared_test.rb +30 -28
- data/test/unit/view_model/active_record/version_test.rb +9 -7
- data/test/unit/view_model/active_record_test.rb +72 -72
- data/test/unit/view_model/callbacks_test.rb +19 -15
- data/test/unit/view_model/controller_test.rb +4 -2
- data/test/unit/view_model/record_test.rb +92 -97
- data/test/unit/view_model/traversal_context_test.rb +4 -5
- data/test/unit/view_model_test.rb +18 -16
- metadata +7 -5
@@ -1,14 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
3
|
require 'minitest/autorun'
|
5
4
|
require 'minitest/unit'
|
6
5
|
require 'minitest/hooks'
|
7
6
|
|
8
|
-
require_relative '../../helpers/match_enumerator
|
9
|
-
require_relative '../../helpers/arvm_test_utilities
|
10
|
-
require_relative '../../helpers/arvm_test_models
|
11
|
-
require_relative '../../helpers/viewmodel_spec_helpers
|
7
|
+
require_relative '../../helpers/match_enumerator'
|
8
|
+
require_relative '../../helpers/arvm_test_utilities'
|
9
|
+
require_relative '../../helpers/arvm_test_models'
|
10
|
+
require_relative '../../helpers/viewmodel_spec_helpers'
|
12
11
|
|
13
12
|
require 'view_model'
|
14
13
|
require 'view_model/record'
|
@@ -1,7 +1,9 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
2
4
|
Bundler.require
|
3
5
|
|
4
|
-
require
|
6
|
+
require 'minitest/autorun'
|
5
7
|
|
6
8
|
class DefaultViewModel < ViewModel
|
7
9
|
self.view_name = 'DefaultViewModel'
|
@@ -19,44 +21,44 @@ end
|
|
19
21
|
|
20
22
|
class ViewModel::ActiveRecordTest < ActiveSupport::TestCase
|
21
23
|
def test_serialize
|
22
|
-
s = TestViewModel.new(
|
24
|
+
s = TestViewModel.new('a')
|
23
25
|
assert_equal(TestViewModel.serialize_to_hash(s),
|
24
|
-
{
|
26
|
+
{ 'name' => 'a' })
|
25
27
|
end
|
26
28
|
|
27
29
|
def test_default_serialize
|
28
|
-
s = DefaultViewModel.new(
|
30
|
+
s = DefaultViewModel.new('a', 1)
|
29
31
|
assert_equal(TestViewModel.serialize_to_hash(s),
|
30
|
-
{
|
32
|
+
{ 'foo' => 'a', 'bar' => 1 })
|
31
33
|
end
|
32
34
|
|
33
35
|
def test_default_serialize_array
|
34
|
-
s = DefaultViewModel.new(
|
36
|
+
s = DefaultViewModel.new('a', [1, 2])
|
35
37
|
assert_equal(TestViewModel.serialize_to_hash(s),
|
36
|
-
{
|
38
|
+
{ 'foo' => 'a', 'bar' => [1, 2] })
|
37
39
|
end
|
38
40
|
|
39
41
|
def test_default_serialize_hash
|
40
|
-
s = DefaultViewModel.new(
|
42
|
+
s = DefaultViewModel.new('a', { 'x' => 'y' })
|
41
43
|
assert_equal(DefaultViewModel.serialize_to_hash(s),
|
42
|
-
{
|
44
|
+
{ 'foo' => 'a', 'bar' => { 'x' => 'y' } })
|
43
45
|
end
|
44
46
|
|
45
47
|
def test_default_serialize_empty_hash
|
46
|
-
s = DefaultViewModel.new(
|
48
|
+
s = DefaultViewModel.new('a', {})
|
47
49
|
assert_equal(DefaultViewModel.serialize_to_hash(s),
|
48
|
-
{
|
50
|
+
{ 'foo' => 'a', 'bar' => {} })
|
49
51
|
end
|
50
52
|
|
51
53
|
def test_default_serialize_viewmodel
|
52
|
-
s = DefaultViewModel.new(
|
54
|
+
s = DefaultViewModel.new('a', DefaultViewModel.new(1, 2))
|
53
55
|
assert_equal(DefaultViewModel.serialize_to_hash(s),
|
54
|
-
{
|
56
|
+
{ 'foo' => 'a', 'bar' => { 'foo' => 1, 'bar' => 2 } })
|
55
57
|
end
|
56
58
|
|
57
59
|
def test_default_serialize_array_of_viewmodel
|
58
|
-
s = DefaultViewModel.new(
|
60
|
+
s = DefaultViewModel.new('a', [TestViewModel.new('x'), TestViewModel.new('y')])
|
59
61
|
assert_equal(DefaultViewModel.serialize_to_hash(s),
|
60
|
-
{
|
62
|
+
{ 'foo' => 'a', 'bar' => [{ 'name' => 'x' }, { 'name' => 'y' }] })
|
61
63
|
end
|
62
64
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iknow_view_models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- iKnow Team
|
@@ -95,7 +95,7 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 2.2.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: keyword_builder
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: safe_values
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - ">="
|
@@ -179,7 +179,7 @@ dependencies:
|
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '0'
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
|
-
name:
|
182
|
+
name: oj
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
184
184
|
requirements:
|
185
185
|
- - ">="
|
@@ -193,7 +193,7 @@ dependencies:
|
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '0'
|
195
195
|
- !ruby/object:Gem::Dependency
|
196
|
-
name:
|
196
|
+
name: renum
|
197
197
|
requirement: !ruby/object:Gem::Requirement
|
198
198
|
requirements:
|
199
199
|
- - ">="
|
@@ -436,6 +436,7 @@ files:
|
|
436
436
|
- nix/dependencies.nix
|
437
437
|
- nix/gem/generate.rb
|
438
438
|
- shell.nix
|
439
|
+
- test/.rubocop.yml
|
439
440
|
- test/config/database.yml
|
440
441
|
- test/helpers/arvm_test_models.rb
|
441
442
|
- test/helpers/arvm_test_utilities.rb
|
@@ -494,6 +495,7 @@ specification_version: 4
|
|
494
495
|
summary: ViewModels provide a means of encapsulating a collection of related data
|
495
496
|
and specifying its JSON serialization.
|
496
497
|
test_files:
|
498
|
+
- test/.rubocop.yml
|
497
499
|
- test/config/database.yml
|
498
500
|
- test/helpers/arvm_test_models.rb
|
499
501
|
- test/helpers/arvm_test_utilities.rb
|