active_remote 1.3.1 → 1.3.2
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.
@@ -8,7 +8,16 @@ module ActiveRemote
|
|
8
8
|
include ActiveRemote::Persistence::InstanceMethods
|
9
9
|
include ActiveRemote::RPC
|
10
10
|
|
11
|
+
# Allow users to create callbacks around a `save` call.
|
12
|
+
#
|
11
13
|
define_model_callbacks :save
|
14
|
+
|
15
|
+
# Before a save occurs, ensure that we
|
16
|
+
# clear out the errors list.
|
17
|
+
#
|
18
|
+
set_callback :save, :before do |remote|
|
19
|
+
remote.errors.clear
|
20
|
+
end
|
12
21
|
end
|
13
22
|
end
|
14
23
|
|
@@ -181,20 +181,28 @@ describe ActiveRemote::Persistence do
|
|
181
181
|
end
|
182
182
|
|
183
183
|
context "when the record is saved" do
|
184
|
-
before { subject.errors.clear }
|
185
|
-
|
186
184
|
it "returns true" do
|
185
|
+
subject.should_receive(:has_errors?) { false }
|
187
186
|
subject.save.should be_true
|
188
187
|
end
|
189
188
|
end
|
190
189
|
|
191
190
|
context "when the record is not saved" do
|
192
|
-
before { subject.errors[:base] << "Boom!" }
|
193
|
-
|
194
191
|
it "returns false" do
|
192
|
+
subject.should_receive(:has_errors?) { true }
|
195
193
|
subject.save.should be_false
|
196
194
|
end
|
197
195
|
end
|
196
|
+
|
197
|
+
context "when the record has errors before the save" do
|
198
|
+
before { subject.errors[:base] << "Boom!" }
|
199
|
+
|
200
|
+
it "clears the errors before the save" do
|
201
|
+
subject.errors.should_not be_empty
|
202
|
+
subject.save.should be_true
|
203
|
+
subject.errors.should be_empty
|
204
|
+
end
|
205
|
+
end
|
198
206
|
end
|
199
207
|
|
200
208
|
describe "#save!" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_remote
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: active_attr
|
@@ -218,7 +218,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
218
218
|
version: '0'
|
219
219
|
segments:
|
220
220
|
- 0
|
221
|
-
hash:
|
221
|
+
hash: -3364486673582194034
|
222
222
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
223
223
|
none: false
|
224
224
|
requirements:
|
@@ -227,7 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
227
227
|
version: '0'
|
228
228
|
segments:
|
229
229
|
- 0
|
230
|
-
hash:
|
230
|
+
hash: -3364486673582194034
|
231
231
|
requirements: []
|
232
232
|
rubyforge_project:
|
233
233
|
rubygems_version: 1.8.24
|