dynamic_finders_plus 0.0.5 → 0.0.6
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/Gemfile.lock +1 -1
- data/lib/dynamic_finders_plus/method_missing_hook.rb +2 -2
- data/lib/dynamic_finders_plus/version.rb +1 -1
- data/spec/definer_spec.rb +31 -6
- data/spec/spec_helper.rb +0 -1
- metadata +2 -2
data/Gemfile.lock
CHANGED
@@ -20,8 +20,8 @@ module ActiveRecord
|
|
20
20
|
class Relation
|
21
21
|
alias a39c8f8aecf84ae4a83e86415d111cc8 method_missing
|
22
22
|
def method_missing name, *args, &block
|
23
|
-
if (new_methods = DynamicFindersPlus::Finder.define_for @klass) &&
|
24
|
-
|
23
|
+
if (new_methods = DynamicFindersPlus::Finder.define_for @klass) && new_methods[name]
|
24
|
+
self.send(name, *args, &block)
|
25
25
|
else
|
26
26
|
a39c8f8aecf84ae4a83e86415d111cc8 name, *args, &block
|
27
27
|
end
|
data/spec/definer_spec.rb
CHANGED
@@ -4,14 +4,39 @@ describe SimpleModel do
|
|
4
4
|
|
5
5
|
subject { SimpleModel }
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
context "The first query on the model" do
|
8
|
+
around do |e|
|
9
|
+
ActiveRecord::Base.connection.execute <<-SQL
|
10
|
+
CREATE TABLE users(
|
11
|
+
id INTEGER PRIMARY KEY,
|
12
|
+
name VARCHAR(255),
|
13
|
+
age INTEGER,
|
14
|
+
active BOOLEAN,
|
15
|
+
date_of_birth DATETIME
|
16
|
+
)
|
17
|
+
SQL
|
18
|
+
|
19
|
+
e.run
|
20
|
+
|
21
|
+
ActiveRecord::Base.connection.execute "DROP TABLE users"
|
22
|
+
end
|
23
|
+
|
24
|
+
class User < ActiveRecord::Base
|
25
|
+
end
|
26
|
+
|
27
|
+
subject { User.where(active: true).name_contains("foo") }
|
28
|
+
|
29
|
+
it "should maintain the original scope" do
|
30
|
+
active = User.create active: true, name: "foo"
|
31
|
+
inactive = User.create active: false, name: "foo"
|
32
|
+
|
33
|
+
should include active
|
34
|
+
should_not include inactive
|
10
35
|
end
|
11
36
|
end
|
12
37
|
|
13
|
-
it {
|
14
|
-
it {
|
15
|
-
it {
|
38
|
+
it { expect { SimpleModel.name }.to_not raise_error(NameError) }
|
39
|
+
it { expect { SimpleModel.is_active }.to_not raise_error(NameError) }
|
40
|
+
it { expect { SimpleModel.is_not_active }.to_not raise_error(NameError) }
|
16
41
|
|
17
42
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dynamic_finders_plus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
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: 2012-
|
12
|
+
date: 2012-10-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|