nakajima-fixjour 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/fixjour/verify.rb +15 -11
- metadata +1 -1
data/lib/fixjour/verify.rb
CHANGED
@@ -21,18 +21,22 @@ module Fixjour
|
|
21
21
|
error(klass, WrongBuilderType, "must return an instance of #{klass}")
|
22
22
|
end
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
24
|
+
klass.transaction do
|
25
|
+
begin
|
26
|
+
result.save!
|
27
|
+
rescue => e
|
28
|
+
error(klass, UnsavableBuilder, "raises #{e.inspect} when saved to the database")
|
29
|
+
end
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
unless new_record(klass).valid?
|
32
|
+
msg = ""
|
33
|
+
msg << "returns invalid an invalid object after another object has been saved.\n"
|
34
|
+
msg << "This could be caused by a validates_uniqueness_of validation in your model.\n"
|
35
|
+
msg << "Use something like the faker gem to alleviate this issue."
|
36
|
+
error(klass, DangerousBuilder, msg)
|
37
|
+
end
|
38
|
+
|
39
|
+
raise ActiveRecord::Rollback
|
36
40
|
end
|
37
41
|
end
|
38
42
|
end
|