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.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +13 -0
  3. data/Appraisals +6 -6
  4. data/Rakefile +5 -5
  5. data/gemfiles/rails_5_2.gemfile +5 -5
  6. data/gemfiles/rails_6_0.gemfile +5 -5
  7. data/iknow_view_models.gemspec +40 -39
  8. data/lib/iknow_view_models.rb +9 -7
  9. data/lib/iknow_view_models/version.rb +1 -1
  10. data/lib/view_model.rb +17 -14
  11. data/lib/view_model/access_control.rb +5 -2
  12. data/lib/view_model/access_control/composed.rb +10 -9
  13. data/lib/view_model/access_control/open.rb +2 -0
  14. data/lib/view_model/access_control/read_only.rb +2 -0
  15. data/lib/view_model/access_control/tree.rb +11 -6
  16. data/lib/view_model/access_control_error.rb +4 -1
  17. data/lib/view_model/active_record.rb +12 -11
  18. data/lib/view_model/active_record/association_data.rb +2 -1
  19. data/lib/view_model/active_record/association_manipulation.rb +6 -4
  20. data/lib/view_model/active_record/cache.rb +4 -2
  21. data/lib/view_model/active_record/collection_nested_controller.rb +3 -3
  22. data/lib/view_model/active_record/controller_base.rb +4 -1
  23. data/lib/view_model/active_record/nested_controller_base.rb +1 -0
  24. data/lib/view_model/active_record/update_context.rb +8 -6
  25. data/lib/view_model/active_record/update_data.rb +32 -30
  26. data/lib/view_model/active_record/update_operation.rb +17 -13
  27. data/lib/view_model/active_record/visitor.rb +0 -1
  28. data/lib/view_model/after_transaction_runner.rb +0 -1
  29. data/lib/view_model/callbacks.rb +3 -1
  30. data/lib/view_model/controller.rb +13 -3
  31. data/lib/view_model/deserialization_error.rb +15 -12
  32. data/lib/view_model/error.rb +12 -10
  33. data/lib/view_model/error_view.rb +3 -1
  34. data/lib/view_model/migration/no_path_error.rb +1 -0
  35. data/lib/view_model/migration/one_way_error.rb +1 -0
  36. data/lib/view_model/migration/unspecified_version_error.rb +1 -0
  37. data/lib/view_model/record.rb +11 -13
  38. data/lib/view_model/reference.rb +3 -1
  39. data/lib/view_model/references.rb +8 -5
  40. data/lib/view_model/registry.rb +1 -1
  41. data/lib/view_model/schemas.rb +9 -4
  42. data/lib/view_model/serialization_error.rb +4 -1
  43. data/lib/view_model/serialize_context.rb +4 -4
  44. data/lib/view_model/test_helpers.rb +8 -3
  45. data/lib/view_model/test_helpers/arvm_builder.rb +19 -14
  46. data/lib/view_model/traversal_context.rb +2 -1
  47. data/test/.rubocop.yml +14 -0
  48. data/test/helpers/arvm_test_models.rb +12 -9
  49. data/test/helpers/arvm_test_utilities.rb +5 -3
  50. data/test/helpers/controller_test_helpers.rb +31 -29
  51. data/test/helpers/match_enumerator.rb +1 -0
  52. data/test/helpers/query_logging.rb +2 -1
  53. data/test/helpers/test_access_control.rb +5 -3
  54. data/test/helpers/viewmodel_spec_helpers.rb +21 -20
  55. data/test/unit/view_model/access_control_test.rb +144 -144
  56. data/test/unit/view_model/active_record/alias_test.rb +15 -13
  57. data/test/unit/view_model/active_record/belongs_to_test.rb +40 -39
  58. data/test/unit/view_model/active_record/cache_test.rb +27 -26
  59. data/test/unit/view_model/active_record/cloner_test.rb +67 -63
  60. data/test/unit/view_model/active_record/controller_test.rb +37 -38
  61. data/test/unit/view_model/active_record/counter_test.rb +10 -9
  62. data/test/unit/view_model/active_record/customization_test.rb +59 -58
  63. data/test/unit/view_model/active_record/has_many_test.rb +112 -111
  64. data/test/unit/view_model/active_record/has_many_through_poly_test.rb +15 -14
  65. data/test/unit/view_model/active_record/has_many_through_test.rb +33 -38
  66. data/test/unit/view_model/active_record/has_one_test.rb +37 -36
  67. data/test/unit/view_model/active_record/migration_test.rb +13 -13
  68. data/test/unit/view_model/active_record/namespacing_test.rb +19 -17
  69. data/test/unit/view_model/active_record/poly_test.rb +44 -45
  70. data/test/unit/view_model/active_record/shared_test.rb +30 -28
  71. data/test/unit/view_model/active_record/version_test.rb +9 -7
  72. data/test/unit/view_model/active_record_test.rb +72 -72
  73. data/test/unit/view_model/callbacks_test.rb +19 -15
  74. data/test/unit/view_model/controller_test.rb +4 -2
  75. data/test/unit/view_model/record_test.rb +92 -97
  76. data/test/unit/view_model/traversal_context_test.rb +4 -5
  77. data/test/unit/view_model_test.rb +18 -16
  78. 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.rb'
9
- require_relative '../../helpers/arvm_test_utilities.rb'
10
- require_relative '../../helpers/arvm_test_models.rb'
11
- require_relative '../../helpers/viewmodel_spec_helpers.rb'
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
- require "bundler/setup"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/setup'
2
4
  Bundler.require
3
5
 
4
- require "minitest/autorun"
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("a")
24
+ s = TestViewModel.new('a')
23
25
  assert_equal(TestViewModel.serialize_to_hash(s),
24
- { "name" => "a" })
26
+ { 'name' => 'a' })
25
27
  end
26
28
 
27
29
  def test_default_serialize
28
- s = DefaultViewModel.new("a", 1)
30
+ s = DefaultViewModel.new('a', 1)
29
31
  assert_equal(TestViewModel.serialize_to_hash(s),
30
- { "foo" => "a", "bar" => 1 })
32
+ { 'foo' => 'a', 'bar' => 1 })
31
33
  end
32
34
 
33
35
  def test_default_serialize_array
34
- s = DefaultViewModel.new("a", [1,2])
36
+ s = DefaultViewModel.new('a', [1, 2])
35
37
  assert_equal(TestViewModel.serialize_to_hash(s),
36
- { "foo" => "a", "bar" => [1,2] })
38
+ { 'foo' => 'a', 'bar' => [1, 2] })
37
39
  end
38
40
 
39
41
  def test_default_serialize_hash
40
- s = DefaultViewModel.new("a", { "x" => "y" })
42
+ s = DefaultViewModel.new('a', { 'x' => 'y' })
41
43
  assert_equal(DefaultViewModel.serialize_to_hash(s),
42
- { "foo" => "a", "bar" => { "x" => "y" } })
44
+ { 'foo' => 'a', 'bar' => { 'x' => 'y' } })
43
45
  end
44
46
 
45
47
  def test_default_serialize_empty_hash
46
- s = DefaultViewModel.new("a", {})
48
+ s = DefaultViewModel.new('a', {})
47
49
  assert_equal(DefaultViewModel.serialize_to_hash(s),
48
- { "foo" => "a", "bar" => {} })
50
+ { 'foo' => 'a', 'bar' => {} })
49
51
  end
50
52
 
51
53
  def test_default_serialize_viewmodel
52
- s = DefaultViewModel.new("a", DefaultViewModel.new(1, 2))
54
+ s = DefaultViewModel.new('a', DefaultViewModel.new(1, 2))
53
55
  assert_equal(DefaultViewModel.serialize_to_hash(s),
54
- { "foo" => "a", "bar" => { "foo" => 1, "bar" => 2 } })
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("a", [TestViewModel.new("x"), TestViewModel.new("y")])
60
+ s = DefaultViewModel.new('a', [TestViewModel.new('x'), TestViewModel.new('y')])
59
61
  assert_equal(DefaultViewModel.serialize_to_hash(s),
60
- { "foo" => "a", "bar" => [{"name" => "x"}, {"name" => "y"}] })
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.0
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: safe_values
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: keyword_builder
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: renum
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: oj
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