fake_arel 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/fake_arel.rb +1 -1
- data/lib/fake_arel/extensions.rb +1 -0
- data/spec/fake_arel_spec.rb +9 -1
- data/spec/fixtures/reply.rb +2 -2
- data/spec/test.db +0 -0
- metadata +4 -4
data/lib/fake_arel.rb
CHANGED
data/lib/fake_arel/extensions.rb
CHANGED
@@ -45,6 +45,7 @@ module ActiveRecord
|
|
45
45
|
delegate :scopes, :with_scope, :scoped_methods, :to => :proxy_scope
|
46
46
|
|
47
47
|
def initialize(proxy_scope, options = {}, &block)
|
48
|
+
options ||= {}
|
48
49
|
options = options.proxy_options if options.class == ActiveRecord::NamedScope::Scope
|
49
50
|
[options[:extend]].flatten.each { |extension| extend extension } if options[:extend]
|
50
51
|
extend Module.new(&block) if block_given?
|
data/spec/fake_arel_spec.rb
CHANGED
@@ -53,6 +53,14 @@ describe "chained nested named scopes" do
|
|
53
53
|
end
|
54
54
|
|
55
55
|
it "should be able to join multiple items" do
|
56
|
-
Reply.filter_join_topic_and_author.
|
56
|
+
Reply.filter_join_topic_and_author.all.should == Reply.find(:all, :conditions => "id in (5,6)")
|
57
|
+
Reply.filter_join_topic_and_author.recent_with_content_like_ar.all.should == Reply.find(:all, :conditions => "id = 5")
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "keep scoped functionality" do
|
63
|
+
it "should respond to scoped" do
|
64
|
+
Reply.scoped.class.should == ActiveRecord::NamedScope::Scope
|
57
65
|
end
|
58
66
|
end
|
data/spec/fixtures/reply.rb
CHANGED
@@ -3,8 +3,8 @@ class Reply < ActiveRecord::Base
|
|
3
3
|
|
4
4
|
named_scope :recent, where('replies.created_at > ?', 15.minutes.ago)
|
5
5
|
named_scope :recent_limit_1, where('replies.created_at > ?', 15.minutes.ago).limit(1)
|
6
|
-
named_scope :recent_with_content_like_ar, recent.where('lower(content) like ?', "AR%")
|
7
|
-
named_scope :recent_with_content_like_ar_and_id_4, recent.where('lower(content) like ?', "AR%").where("id = 4")
|
6
|
+
named_scope :recent_with_content_like_ar, recent.where('lower(replies.content) like ?', "AR%")
|
7
|
+
named_scope :recent_with_content_like_ar_and_id_4, recent.where('lower(replies.content) like ?', "AR%").where("id = 4")
|
8
8
|
named_scope :recent_joins_topic, recent.joins(:topic)
|
9
9
|
named_scope :topic_title_is, lambda {|topic_title| where("topics.title like ?", topic_title + "%") }
|
10
10
|
|
data/spec/test.db
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fake_arel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 3
|
10
|
+
version: 0.1.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Grant Ammons
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-07-
|
18
|
+
date: 2010-07-30 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|