virtus_model 0.2.7 → 0.2.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6f1a953646349c44fa54aa05ee837957d5dbea1b
4
- data.tar.gz: 3ef20b44398a1d6e7f570ed9d1e47b252c40d699
3
+ metadata.gz: e85be758bb952a2fbc508008efbe0d244f5af3e2
4
+ data.tar.gz: cdad84c5350c981a368abc3f1b308e2e061ceeb9
5
5
  SHA512:
6
- metadata.gz: fe46421d757999c247e41a7e3e7f9c4eb3ed149a67cd7c0e4b2cd464dc64814a34e67ce32497560b88b2fa5ca1ddb78534efae806d4e20c55e0bb5f9c18d861a
7
- data.tar.gz: f180ba36edbc18769315a6a9652d4ff890a11b86348fb4af011f92c943fe7ecc3817a579a04546f263015396eaf873f609f5142c30b18106a4322ea6fc65f2a8
6
+ metadata.gz: 74bef150dbd2ab9809b3a666d0ff835050956d797f22374ce07045eb412ead50eeb981cadadea23bad4a58728035932adcc7a74141bce794a8a5ffac0072183b
7
+ data.tar.gz: f00a3746229a7971a1fad82b64c030097d06f66f5e031dfa72c8448645c11b2e967a3877a850f2570e803c0854349f868c89da15ce3f2c4f560a73c2a5525968
@@ -6,9 +6,10 @@ module VirtusModel
6
6
  class Base
7
7
  include ActiveModel::Conversion
8
8
  include ActiveModel::Validations
9
+ include ActiveModel::Validations::Callbacks
9
10
  include Virtus.model(nullify_blank: true)
10
11
 
11
- set_callback :validate, :validate_associations
12
+ before_validation :validate_associations
12
13
 
13
14
  # Get an array of attribute names.
14
15
  def self.attributes
@@ -1,3 +1,3 @@
1
1
  module VirtusModel
2
- VERSION = '0.2.7'.freeze
2
+ VERSION = '0.2.8'.freeze
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -6,6 +6,7 @@ Bundler.setup
6
6
 
7
7
  require 'virtus_model'
8
8
  require 'shoulda/matchers'
9
+ require 'shoulda/callback/matchers'
9
10
  require 'active_support/core_ext/object/try'
10
11
 
11
12
  Shoulda::Matchers.configure do |config|
@@ -8,6 +8,7 @@ describe VirtusModel::Base do
8
8
  let(:simple_model_attributes) { { name: 'test' } }
9
9
 
10
10
  describe SimpleModel, type: :model do
11
+ it { is_expected.to callback(:validate_associations).before(:validation) }
11
12
  it { is_expected.to validate_presence_of(:name) }
12
13
  end
13
14
 
@@ -27,6 +28,7 @@ describe VirtusModel::Base do
27
28
  end
28
29
 
29
30
  describe ComplexModel, type: :model do
31
+ it { is_expected.to callback(:validate_associations).before(:validation) }
30
32
  it { is_expected.to validate_presence_of(:model) }
31
33
  it { is_expected.to validate_presence_of(:models) }
32
34
  end
@@ -36,10 +38,21 @@ describe VirtusModel::Base do
36
38
  end
37
39
 
38
40
  describe InheritedModel, type: :model do
41
+ it { is_expected.to callback(:validate_associations).before(:validation) }
39
42
  it { is_expected.to validate_presence_of(:model) }
40
43
  it { is_expected.to validate_presence_of(:models) }
41
44
  end
42
45
 
46
+ class CallbackModel < ComplexModel
47
+ after_validation :child_callback
48
+ end
49
+
50
+ describe CallbackModel, type: :model do
51
+ before(:example) { allow(subject).to receive(:child_callback) }
52
+ it { is_expected.to callback(:validate_associations).before(:validation) }
53
+ it { is_expected.to callback(:child_callback).after(:validation) }
54
+ end
55
+
43
56
  describe '.attribute?' do
44
57
  context SimpleModel do
45
58
  subject { SimpleModel }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: virtus_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derek Schaefer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-20 00:00:00.000000000 Z
11
+ date: 2016-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: virtus
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '3.1'
111
+ - !ruby/object:Gem::Dependency
112
+ name: shoulda-callback-matchers
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1.1'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1.1'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: simplecov
113
127
  requirement: !ruby/object:Gem::Requirement