active-triples 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a8509c08a01f7e74117e8ea5791aaf2728360c80
4
- data.tar.gz: f1941f479ed0e56364c957497e8d8f39403b6efa
3
+ metadata.gz: 024aea8eb521fecc89a76d764bb1dd856febbf9c
4
+ data.tar.gz: e0fc3915d0fe0faba66b65df1adc31233a976433
5
5
  SHA512:
6
- metadata.gz: faff9891e25d5962d178cf88baceaaaf0b40b8f0d0bca6538d15421834f6529d00cdbe5e5995e1cfef868a8f593a1a2e84aa3309b3cb933ee7e5192333fcfc4c
7
- data.tar.gz: 76ef886b46c6cafb1f24a64df413a7d2f8d08aff2e97e2821cbca91e827bd03089eb337ace703aacf774d774b764c5320de891dd88320468608c408c079b214f
6
+ metadata.gz: 20b0ff10a9833b835c4eae9957baa1712ced77bceebb362eff685a508475d2dc05ca587b2cfe30959ddcc31385696136f8d714c57997e30c4e1ffc809a4c967e
7
+ data.tar.gz: b61e998c602a8d860fef2614158ecebeb3acec51c83b4e8e1b264554a2dced2beb10c9a1cc20cc3b746f4029df2318ab3ae8dcc50a07802b1742a4f096854e42
data/CHANGES.md CHANGED
@@ -1,3 +1,10 @@
1
+ 0.7.2
2
+ ----
3
+
4
+ - Allows interoperability between `ActiveModel::Validations` and
5
+ `RDF::Graph#valid?`. This fixes a bug with validation callbacks. See:
6
+ [#167](https://github.com/ActiveTriples/ActiveTriples/pull/167).
7
+
1
8
  0.7.1
2
9
  ----
3
10
 
@@ -47,10 +47,10 @@ module ActiveTriples
47
47
  include RDF::Enumerable
48
48
  include RDF::Queryable
49
49
  include RDF::Mutable
50
- include ActiveModel::Validations
51
50
  include ActiveModel::Conversion
52
51
  include ActiveModel::Serialization
53
52
  include ActiveModel::Serializers::JSON
53
+ include ActiveModel::Validations
54
54
 
55
55
  attr_accessor :parent
56
56
 
@@ -66,6 +66,13 @@ module ActiveTriples
66
66
  extend ActiveModel::Translation
67
67
  extend ActiveModel::Callbacks
68
68
 
69
+ validate do
70
+ errors.add(:rdf_subject, 'The #rdf_subject Term must be valid') unless
71
+ rdf_subject.valid?
72
+ errors.add(:base, 'The underlying graph must be valid') unless
73
+ graph.valid?
74
+ end
75
+
69
76
  delegate :each, :load!, :count, :has_statement?, :to => :@graph
70
77
 
71
78
  define_model_callbacks :persist
@@ -436,6 +443,10 @@ module ActiveTriples
436
443
 
437
444
  private
438
445
 
446
+ def graph
447
+ @graph
448
+ end
449
+
439
450
  ##
440
451
  # Returns the properties registered and their configurations.
441
452
  #
@@ -1,3 +1,3 @@
1
1
  module ActiveTriples
2
- VERSION = "0.7.1".freeze
2
+ VERSION = '0.7.2'.freeze
3
3
  end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe ActiveTriples::Resource do
4
+
5
+ subject { MyResource.new }
6
+
7
+ before(:all) do
8
+ class MyResource < ActiveTriples::Resource
9
+ property :title, predicate: ::RDF::DC.title
10
+
11
+ validates_presence_of :title
12
+ end
13
+ end
14
+
15
+ after(:all) do
16
+ Object.send(:remove_const, :MyResource)
17
+ end
18
+
19
+ describe "validation" do
20
+ it "should have a presence validator on the class" do
21
+ expect(MyResource.validators.first).to be_a(ActiveModel::Validations::PresenceValidator)
22
+ end
23
+ it "should have validation callbacks" do
24
+ expect(MyResource._validate_callbacks).to be_present
25
+ end
26
+ it "should run the validations" do
27
+ expect(subject).to receive(:run_validations!)
28
+ subject.valid?
29
+ end
30
+ it { is_expected.to be_invalid }
31
+ end
32
+
33
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active-triples
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Johnson
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-06-11 00:00:00.000000000 Z
12
+ date: 2015-10-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rdf
@@ -233,6 +233,7 @@ files:
233
233
  - spec/active_triples/repositories_spec.rb
234
234
  - spec/active_triples/resource_spec.rb
235
235
  - spec/active_triples/schema_spec.rb
236
+ - spec/active_triples/validations_spec.rb
236
237
  - spec/active_triples_spec.rb
237
238
  - spec/pragmatic_context_spec.rb
238
239
  - spec/spec_helper.rb
@@ -257,7 +258,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
257
258
  version: '0'
258
259
  requirements: []
259
260
  rubyforge_project:
260
- rubygems_version: 2.4.5
261
+ rubygems_version: 2.2.0
261
262
  signing_key:
262
263
  specification_version: 4
263
264
  summary: RDF graphs in ActiveModel wrappers.