active_node 2.3.5 → 2.3.6

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: 2f5fd6bbd377e9d3a0ea0d1ee61fae0b6e04ad87
4
- data.tar.gz: 1ba851caa4b8a465c41f2e66291874d68b3272cb
3
+ metadata.gz: b884b5d0dd3dad07e649785c7f93ebc1ddf306b6
4
+ data.tar.gz: 59b3577cb8953aa800694f5c29db1e4f15800dcd
5
5
  SHA512:
6
- metadata.gz: ac304c846ad143695f9318c30888afb62d263ed23ec5a97b8e162473a3955c935357fc87677105a7f1a6646525f670504b664b12962d638da4d73f415c86d41f
7
- data.tar.gz: da05a6381b63b281c03c3058fb4dd6a33d6c09fc84a43b6d2b38abaf1b14c80e9aebbf84de675401016f5b1fba3da704c9d84dcf1dc8bf43a9a45e4f8b5e4665
6
+ metadata.gz: 7a8cb52eb6fc1dcde0ebad7bd241e9d77e14551d76fa034c3e5be6d8f8891e256dd1df34f27a7850552c2dc51e39c27f342da8a58bdfc928f11423fed27f9071
7
+ data.tar.gz: 6e5a9e4e2550236549f1d1620551b70d981cc55decfe56bb9d2a4e75825ef6032f04899129df18c95f503de816b06a6ede216c897063d25b4a50c875b13cfd98
data/.travis.yml CHANGED
@@ -1,4 +1,4 @@
1
- script: "bundle exec rake neo4j:install['enterprise','2.1.6'] neo4j:start spec --trace"
1
+ script: "bundle exec rake neo4j:install['enterprise','2.3.2'] neo4j:unsecure neo4j:start spec --trace"
2
2
  language: ruby
3
3
  rvm:
4
4
  - 2.1.2
@@ -34,6 +34,18 @@ module ActiveNode
34
34
  autoload :UniquenessValidator, 'active_node/validations/uniqueness'
35
35
 
36
36
  module ClassMethods
37
+ # Initializes and saves an object in a single step.
38
+ def create(attributes = nil, &block)
39
+ if attributes.is_a?(Array)
40
+ attributes.collect { |attr| create(attr, &block) }
41
+ else
42
+ object = new(attributes)
43
+ yield(object) if block_given?
44
+ object.save
45
+ object
46
+ end
47
+ end
48
+
37
49
  # Creates an object just like Base.create but calls <tt>save!</tt> instead of +save+
38
50
  # so an exception is raised if the record is invalid.
39
51
  def create!(attributes = nil, &block)
@@ -1,3 +1,3 @@
1
1
  module ActiveNode
2
- VERSION = "2.3.5"
2
+ VERSION = "2.3.6"
3
3
  end
@@ -27,4 +27,19 @@ describe ActiveNode::Validations do
27
27
  expect(House.find(house.id)).to be_valid
28
28
  end
29
29
  end
30
+
31
+ describe "#create" do
32
+ it "should not create invalid object" do
33
+ expect(Client.create).not_to be_persisted
34
+ end
35
+
36
+ it "should create valid object" do
37
+ expect(Client.create(name: 'abc7')).to be_persisted
38
+ expect(Client.all.first.name).to eq('abc7')
39
+ end
40
+
41
+ it "should create an instance of the model class" do
42
+ expect(Client.create(name: 'abc7')).to be_a(Client)
43
+ end
44
+ end
30
45
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_node
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.5
4
+ version: 2.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Heinrich Klobuczek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-22 00:00:00.000000000 Z
11
+ date: 2016-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_attr