mongoid 0.11.2 → 0.11.3

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.11.3
2
+ - Fixed issue with Document#save! not calling before
3
+ and after create callbacks if document is new
4
+
1
5
  === 0.11.2
2
6
  - Fixing bug where has many and has one relational
3
7
  associations create method did not return the
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.11.2
1
+ 0.11.3
@@ -60,9 +60,10 @@ module Mongoid #:nodoc:
60
60
  #
61
61
  # Returns: true if validation passes, false if not.
62
62
  def save(validate = true)
63
- run_callbacks(:before_create) if new_record?
63
+ new = new_record?
64
+ run_callbacks(:before_create) if new
64
65
  saved = Save.execute(self, validate)
65
- run_callbacks(:after_create) if new_record?
66
+ run_callbacks(:after_create) if new
66
67
  saved
67
68
  end
68
69
 
@@ -75,7 +76,7 @@ module Mongoid #:nodoc:
75
76
  #
76
77
  # Returns: true if validation passes
77
78
  def save!
78
- return Save.execute(self, true) || (raise Errors::Validations.new(self.errors))
79
+ return save(true) || (raise Errors::Validations.new(self.errors))
79
80
  end
80
81
 
81
82
  # Update the document attributes and persist the document to the
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mongoid}
8
- s.version = "0.11.2"
8
+ s.version = "0.11.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Durran Jordan"]
12
- s.date = %q{2010-01-03}
12
+ s.date = %q{2010-01-04}
13
13
  s.email = %q{durran@gmail.com}
14
14
  s.extra_rdoc_files = [
15
15
  "README.textile"
@@ -42,6 +42,13 @@ describe Mongoid::Commands do
42
42
  @person.save
43
43
  end
44
44
 
45
+ it "runs the before and after create callbacks" do
46
+ @person.expects(:run_callbacks).with(:before_create)
47
+ Mongoid::Commands::Save.expects(:execute).with(@person, true).returns(true)
48
+ @person.expects(:run_callbacks).with(:after_create)
49
+ @person.save
50
+ end
51
+
45
52
  end
46
53
 
47
54
  context "when not validating" do
@@ -99,6 +106,13 @@ describe Mongoid::Commands do
99
106
 
100
107
  end
101
108
 
109
+ it "runs the before and after create callbacks" do
110
+ @person.expects(:run_callbacks).with(:before_create)
111
+ Mongoid::Commands::Save.expects(:execute).with(@person, true).returns(true)
112
+ @person.expects(:run_callbacks).with(:after_create)
113
+ @person.save!
114
+ end
115
+
102
116
  end
103
117
 
104
118
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.2
4
+ version: 0.11.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Durran Jordan
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-03 00:00:00 -05:00
12
+ date: 2010-01-04 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency