belongs_to_enum 0.3 → 0.3.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/lib/belongs_to_enum/enum.rb +1 -1
- data/lib/belongs_to_enum/version.rb +1 -1
- data/spec/belongs_to_enum.rb +4 -4
- metadata +1 -1
data/lib/belongs_to_enum/enum.rb
CHANGED
@@ -82,7 +82,7 @@ module BelongsToEnum
|
|
82
82
|
if options[:create_scopes]
|
83
83
|
klass.raw_hash.each do |key, value|
|
84
84
|
parent.instance_exec do
|
85
|
-
scope key.to_s
|
85
|
+
scope key.to_s, where("#{name.to_s.underscore}_id = #{value}")
|
86
86
|
end
|
87
87
|
end
|
88
88
|
end
|
data/spec/belongs_to_enum.rb
CHANGED
@@ -127,11 +127,11 @@ describe "Belongs To Enum models" do
|
|
127
127
|
belongs_to_enum :role2, [:admin]
|
128
128
|
end
|
129
129
|
klass.should respond_to("sanity_scope")
|
130
|
-
klass.should respond_to("
|
131
|
-
klass.should_not respond_to("
|
130
|
+
klass.should respond_to("normal")
|
131
|
+
klass.should_not respond_to("admin")
|
132
132
|
|
133
|
-
klass.method("
|
134
|
-
klass.send("
|
133
|
+
klass.method("normal").source_location.should == klass.method("sanity_scope").source_location
|
134
|
+
klass.send("normal").to_sql.strip.squeeze(" ").should == 'SELECT "scope_checkers".* FROM "scope_checkers" WHERE (role1_id = 1)'
|
135
135
|
end
|
136
136
|
|
137
137
|
|