iknow_view_models 2.10.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +119 -0
- data/.travis.yml +31 -0
- data/Appraisals +6 -16
- data/gemfiles/{rails_7_0.gemfile → rails_6_0_beta.gemfile} +2 -2
- data/iknow_view_models.gemspec +3 -5
- data/lib/iknow_view_models/version.rb +1 -1
- data/lib/view_model/active_record/association_data.rb +206 -92
- data/lib/view_model/active_record/association_manipulation.rb +22 -12
- data/lib/view_model/active_record/cache/cacheable_view.rb +3 -13
- data/lib/view_model/active_record/cache.rb +2 -2
- data/lib/view_model/active_record/cloner.rb +11 -11
- data/lib/view_model/active_record/controller.rb +0 -2
- data/lib/view_model/active_record/update_context.rb +21 -3
- data/lib/view_model/active_record/update_data.rb +43 -45
- data/lib/view_model/active_record/update_operation.rb +265 -153
- data/lib/view_model/active_record/visitor.rb +9 -6
- data/lib/view_model/active_record.rb +94 -74
- data/lib/view_model/after_transaction_runner.rb +3 -18
- data/lib/view_model/callbacks.rb +2 -2
- data/lib/view_model/changes.rb +24 -16
- data/lib/view_model/config.rb +6 -2
- data/lib/view_model/deserialization_error.rb +31 -0
- data/lib/view_model/deserialize_context.rb +2 -6
- data/lib/view_model/error_view.rb +6 -5
- data/lib/view_model/record/attribute_data.rb +11 -6
- data/lib/view_model/record.rb +44 -24
- data/lib/view_model/serialize_context.rb +2 -63
- data/lib/view_model/test_helpers/arvm_builder.rb +2 -4
- data/lib/view_model/traversal_context.rb +2 -2
- data/lib/view_model.rb +21 -13
- data/shell.nix +1 -1
- data/test/helpers/arvm_test_models.rb +4 -12
- data/test/helpers/arvm_test_utilities.rb +6 -0
- data/test/helpers/controller_test_helpers.rb +6 -6
- data/test/helpers/viewmodel_spec_helpers.rb +63 -52
- data/test/unit/view_model/access_control_test.rb +88 -37
- data/test/unit/view_model/active_record/belongs_to_test.rb +110 -178
- data/test/unit/view_model/active_record/cache_test.rb +11 -5
- data/test/unit/view_model/active_record/cloner_test.rb +1 -1
- data/test/unit/view_model/active_record/controller_test.rb +12 -20
- data/test/unit/view_model/active_record/has_many_test.rb +540 -316
- data/test/unit/view_model/active_record/has_many_through_poly_test.rb +12 -15
- data/test/unit/view_model/active_record/has_many_through_test.rb +15 -58
- data/test/unit/view_model/active_record/has_one_test.rb +288 -135
- data/test/unit/view_model/active_record/poly_test.rb +0 -1
- data/test/unit/view_model/active_record/shared_test.rb +21 -39
- data/test/unit/view_model/active_record/version_test.rb +3 -2
- data/test/unit/view_model/active_record_test.rb +5 -63
- data/test/unit/view_model/callbacks_test.rb +1 -0
- data/test/unit/view_model/record_test.rb +0 -32
- data/test/unit/view_model/traversal_context_test.rb +13 -12
- metadata +15 -25
- data/.github/workflows/gem-push.yml +0 -31
- data/.github/workflows/test.yml +0 -65
- data/gemfiles/rails_6_0.gemfile +0 -9
- data/gemfiles/rails_6_1.gemfile +0 -9
- data/test/unit/view_model/active_record/optional_attribute_view_test.rb +0 -58
data/.github/workflows/test.yml
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
name: Run Tests
|
2
|
-
|
3
|
-
on:
|
4
|
-
pull_request:
|
5
|
-
branches: "**"
|
6
|
-
|
7
|
-
permissions:
|
8
|
-
contents: read
|
9
|
-
checks: write
|
10
|
-
pull-requests: write
|
11
|
-
|
12
|
-
jobs:
|
13
|
-
test:
|
14
|
-
runs-on: ubuntu-latest
|
15
|
-
|
16
|
-
services:
|
17
|
-
postgres:
|
18
|
-
image: postgres:13-alpine
|
19
|
-
ports:
|
20
|
-
- "5432:5432"
|
21
|
-
env:
|
22
|
-
POSTGRES_DB: iknow_view_models
|
23
|
-
POSTGRES_USER: rails
|
24
|
-
POSTGRES_PASSWORD: password
|
25
|
-
|
26
|
-
strategy:
|
27
|
-
fail-fast: false
|
28
|
-
matrix:
|
29
|
-
ruby-version: ['2.7', '3.0', '3.1', '3.2']
|
30
|
-
include:
|
31
|
-
- ruby-version: '2.7'
|
32
|
-
bundle-gemfile: gemfiles/rails_5_2.gemfile
|
33
|
-
- ruby-version: '3.0'
|
34
|
-
bundle-gemfile: gemfiles/rails_6_0.gemfile
|
35
|
-
- ruby-version: '3.1'
|
36
|
-
bundle-gemfile: gemfiles/rails_6_1.gemfile
|
37
|
-
- ruby-version: '3.2'
|
38
|
-
bundle-gemfile: gemfiles/rails_7_0.gemfile
|
39
|
-
|
40
|
-
env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
|
41
|
-
BUNDLE_GEMFILE: ${{ github.workspace }}/${{ matrix.bundle-gemfile }}
|
42
|
-
DATABASE_URL: "postgres://rails:password@localhost:5432/iknow_view_models"
|
43
|
-
|
44
|
-
steps:
|
45
|
-
- uses: actions/checkout@v3
|
46
|
-
- name: Set up Ruby
|
47
|
-
uses: ruby/setup-ruby@v1
|
48
|
-
with:
|
49
|
-
ruby-version: ${{ matrix.ruby-version }}
|
50
|
-
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
51
|
-
- name: Run tests
|
52
|
-
run: bundle exec rake test
|
53
|
-
- name: Upload result
|
54
|
-
uses: actions/upload-artifact@v3
|
55
|
-
if: always()
|
56
|
-
with:
|
57
|
-
path: test/reports/
|
58
|
-
name: test_results_${{ matrix.ruby-version }}
|
59
|
-
- name: Test Report
|
60
|
-
uses: dorny/test-reporter@v1
|
61
|
-
if: always()
|
62
|
-
with:
|
63
|
-
name: Minitest Tests - ${{ matrix.ruby-version }}
|
64
|
-
path: test/reports/*.xml
|
65
|
-
reporter: java-junit
|
data/gemfiles/rails_6_0.gemfile
DELETED
data/gemfiles/rails_6_1.gemfile
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
require_relative "../../../helpers/arvm_test_utilities.rb"
|
2
|
-
require_relative "../../../helpers/arvm_test_models.rb"
|
3
|
-
|
4
|
-
require "minitest/autorun"
|
5
|
-
|
6
|
-
require "view_model/active_record"
|
7
|
-
|
8
|
-
class ViewModel::ActiveRecord::AttributeViewTest < ActiveSupport::TestCase
|
9
|
-
include ARVMTestUtilities
|
10
|
-
|
11
|
-
def before_all
|
12
|
-
super
|
13
|
-
|
14
|
-
build_viewmodel(:Thing) do
|
15
|
-
define_schema do |t|
|
16
|
-
t.integer :a
|
17
|
-
t.integer :b
|
18
|
-
end
|
19
|
-
|
20
|
-
define_model do
|
21
|
-
end
|
22
|
-
|
23
|
-
define_viewmodel do
|
24
|
-
attribute :a
|
25
|
-
attribute :b, optional: true
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def setup
|
31
|
-
super
|
32
|
-
@thing = Thing.create!(a: 1, b: 2)
|
33
|
-
|
34
|
-
@skel = { "_type" => "Thing",
|
35
|
-
"_version" => 1,
|
36
|
-
"id" => @thing.id }
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_optional_not_serialized
|
40
|
-
view, _refs = serialize_with_references(ThingView.new(@thing))
|
41
|
-
|
42
|
-
assert_equal(@skel.merge("a" => 1), view)
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_optional_included
|
46
|
-
view, _refs = serialize_with_references(ThingView.new(@thing),
|
47
|
-
serialize_context: ThingView.new_serialize_context(include: :b))
|
48
|
-
|
49
|
-
assert_equal(@skel.merge("a" => 1, "b" => 2), view)
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_pruned_not_included
|
53
|
-
view, _refs = serialize_with_references(ThingView.new(@thing),
|
54
|
-
serialize_context: ThingView.new_serialize_context(include: :b, prune: :a))
|
55
|
-
|
56
|
-
assert_equal(@skel.merge("b" => 2), view)
|
57
|
-
end
|
58
|
-
end
|