josevalim-auth_helpers 0.2.0 → 0.2.1
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.
- data/README +3 -2
- data/lib/auth_helpers/spec/associatable.rb +31 -0
- metadata +2 -1
data/README
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
AuthHelpers
|
2
2
|
License: MIT
|
3
|
-
Version: 0.2
|
3
|
+
Version: 0.2.1
|
4
4
|
|
5
5
|
You can also read this README in pretty html at the GitHub project Wiki page:
|
6
6
|
|
@@ -126,7 +126,8 @@ with the following contents:
|
|
126
126
|
module AuthHelpers
|
127
127
|
describe Notifier do
|
128
128
|
include AuthHelpers::Spec::Notifier
|
129
|
-
end
|
129
|
+
end
|
130
|
+
end
|
130
131
|
|
131
132
|
I18n
|
132
133
|
----
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module AuthHelpers
|
2
|
+
module Spec
|
3
|
+
|
4
|
+
module Associatable
|
5
|
+
def self.included(base)
|
6
|
+
klass = base.described_class
|
7
|
+
|
8
|
+
column = klass.columns.detect{|c| c.name =~ /_id$/ }
|
9
|
+
raise ScriptError, "Could not find a column that ends with id in #{base.name.tableize}" unless column
|
10
|
+
|
11
|
+
association = column.name.gsub(/_id$/, '').to_sym
|
12
|
+
polymorphic = !!klass.columns.detect{ |c| c.name == "#{association}_type" }
|
13
|
+
|
14
|
+
base.class_eval do
|
15
|
+
it "should validate associated #{association}" do
|
16
|
+
associatable = base.described_class.create(@valid_attributes.merge(:"#{association}_attributes" => {}))
|
17
|
+
associatable.should_not be_valid
|
18
|
+
|
19
|
+
unless associatable.send(association).errors.empty?
|
20
|
+
associatable.errors.should be_empty # this should be blank since errors is
|
21
|
+
# on the associated object.
|
22
|
+
|
23
|
+
associatable.send(association).errors.should_not be_empty
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: josevalim-auth_helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Jos\xC3\xA9 Valim"
|
@@ -41,6 +41,7 @@ files:
|
|
41
41
|
- lib/auth_helpers/model/confirmable.rb
|
42
42
|
- lib/auth_helpers/model/recoverable.rb
|
43
43
|
- lib/auth_helpers/model/updatable.rb
|
44
|
+
- lib/auth_helpers/spec/associatable.rb
|
44
45
|
- lib/auth_helpers/spec/confirmable.rb
|
45
46
|
- lib/auth_helpers/spec/notifier.rb
|
46
47
|
- lib/auth_helpers/spec/recoverable.rb
|