rich-acts_as_revisable 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'acts_as_revisable/options'
|
2
2
|
require 'acts_as_revisable/quoted_columns'
|
3
|
+
require 'acts_as_revisable/validations'
|
3
4
|
require 'acts_as_revisable/acts/common'
|
4
5
|
require 'acts_as_revisable/acts/revision'
|
5
6
|
require 'acts_as_revisable/acts/revisable'
|
@@ -45,6 +46,7 @@ module WithoutScope
|
|
45
46
|
self.revisable_options = Options.new(options, &block)
|
46
47
|
|
47
48
|
self.send(:include, Common)
|
49
|
+
self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?
|
48
50
|
self.send(:include, WithoutScope::QuotedColumnConditions)
|
49
51
|
end
|
50
52
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -97,11 +97,15 @@ class Session < ActiveRecord::Base
|
|
97
97
|
end
|
98
98
|
|
99
99
|
class Foo < ActiveRecord::Base
|
100
|
-
acts_as_revisable :generate_revision_class => true
|
100
|
+
acts_as_revisable :generate_revision_class => true, :no_validation_scoping => true
|
101
|
+
|
102
|
+
validates_uniqueness_of :name
|
101
103
|
end
|
102
104
|
|
103
105
|
class Post < ActiveRecord::Base
|
104
|
-
acts_as_revisable
|
106
|
+
acts_as_revisable
|
107
|
+
|
108
|
+
validates_uniqueness_of :name
|
105
109
|
end
|
106
110
|
|
107
111
|
class PostRevision < ActiveRecord::Base
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
|
+
|
3
|
+
describe WithoutScope::ActsAsRevisable, "with validations" do
|
4
|
+
after(:each) do
|
5
|
+
cleanup_db
|
6
|
+
end
|
7
|
+
|
8
|
+
before(:each) do
|
9
|
+
@post = Post.create(:name => 'a post')
|
10
|
+
@foo = Foo.create(:name => 'a foo')
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "unique fields" do
|
15
|
+
it "should allow revisions" do
|
16
|
+
lambda {@post.revise!; @post.revise!}.should_not raise_error
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "unique fields with validation scoping off" do
|
21
|
+
it "should not allow revisions" do
|
22
|
+
lambda {@foo.revise!; @foo.revise!}.should raise_error
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rich-acts_as_revisable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rich Cavanaugh
|
@@ -38,6 +38,7 @@ files:
|
|
38
38
|
- spec/spec.opts
|
39
39
|
- spec/spec_helper.rb
|
40
40
|
- spec/sti_spec.rb
|
41
|
+
- spec/validations_spec.rb
|
41
42
|
- lib/acts_as_revisable
|
42
43
|
- lib/acts_as_revisable/acts
|
43
44
|
- lib/acts_as_revisable/acts/common.rb
|
@@ -48,6 +49,7 @@ files:
|
|
48
49
|
- lib/acts_as_revisable/gem_spec_options.rb
|
49
50
|
- lib/acts_as_revisable/options.rb
|
50
51
|
- lib/acts_as_revisable/quoted_columns.rb
|
52
|
+
- lib/acts_as_revisable/validations.rb
|
51
53
|
- lib/acts_as_revisable/version.rb
|
52
54
|
- lib/acts_as_revisable.rb
|
53
55
|
- generators/revisable_migration
|