fake_arel 0.7 → 0.8
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/fake_arel.rb +1 -1
- data/lib/fake_arel/extensions.rb +2 -2
- data/spec/fake_arel_spec.rb +28 -0
- data/spec/fixtures/topic.rb +7 -0
- data/spec/test.db +0 -0
- metadata +4 -4
data/lib/fake_arel.rb
CHANGED
data/lib/fake_arel/extensions.rb
CHANGED
|
@@ -41,8 +41,8 @@ module ActiveRecord
|
|
|
41
41
|
elsif local_conditions
|
|
42
42
|
ret[:conditions] = local_conditions
|
|
43
43
|
end
|
|
44
|
-
ret[:
|
|
45
|
-
ret[:joins] =
|
|
44
|
+
ret[:include] = merge_includes(ret[:include], local_scope.proxy_options[:include])
|
|
45
|
+
ret[:joins] = merge_joins(ret[:joins], local_scope.proxy_options[:joins]) if ret[:joins] || local_scope.proxy_options[:joins]
|
|
46
46
|
ret[:order] = [local_scope.proxy_options[:order], ret[:order]].select{|o| !o.blank?}.join(',') if ret[:order] || local_scope.proxy_options[:order]
|
|
47
47
|
local_scope = local_scope.proxy_scope
|
|
48
48
|
end
|
data/spec/fake_arel_spec.rb
CHANGED
|
@@ -96,6 +96,34 @@ describe "chained nested named scopes" do
|
|
|
96
96
|
end
|
|
97
97
|
end.should == Reply.find(:all, :order=>'created_at desc, topic_id asc')
|
|
98
98
|
end
|
|
99
|
+
|
|
100
|
+
it "should chain string join scope" do
|
|
101
|
+
lambda {
|
|
102
|
+
Topic.join_replies_by_string_and_author.all
|
|
103
|
+
Topic.join_replies_by_string_and_author_lambda.all
|
|
104
|
+
}.should_not raise_error
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
it "should properly chain with includes" do
|
|
108
|
+
topics = nil
|
|
109
|
+
lambda {
|
|
110
|
+
topics = Topic.mentions_activerecord_with_replies.all
|
|
111
|
+
}.should_not raise_error
|
|
112
|
+
topics.each {|topic|
|
|
113
|
+
topic.replies.loaded?.should be_true
|
|
114
|
+
}
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
it "should properly chain with includes in lambda" do
|
|
118
|
+
topics = nil
|
|
119
|
+
lambda {
|
|
120
|
+
topics = Topic.by_title_with_replies('%ActiveRecord%').all
|
|
121
|
+
}.should_not raise_error
|
|
122
|
+
topics.each {|topic|
|
|
123
|
+
topic.replies.loaded?.should be_true
|
|
124
|
+
}
|
|
125
|
+
end
|
|
126
|
+
|
|
99
127
|
end
|
|
100
128
|
|
|
101
129
|
describe "keep scoped functionality" do
|
data/spec/fixtures/topic.rb
CHANGED
|
@@ -7,4 +7,11 @@ class Topic < ActiveRecord::Base
|
|
|
7
7
|
named_scope :with_replies_starting_with, lambda { |text|
|
|
8
8
|
{ :conditions => "replies.content LIKE '#{text}%' ", :include => :replies }
|
|
9
9
|
}
|
|
10
|
+
|
|
11
|
+
named_scope :mentions_activerecord_with_replies, includes(:replies).mentions_activerecord
|
|
12
|
+
named_scope :by_title_with_replies, lambda {|title| includes(:replies).where('topics.title like ?', title) }
|
|
13
|
+
|
|
14
|
+
named_scope :join_replies_by_string, joins('inner join replies on topics.id = replies.topic_id')
|
|
15
|
+
named_scope :join_replies_by_string_and_author, join_replies_by_string.joins(:author)
|
|
16
|
+
named_scope :join_replies_by_string_and_author_lambda, join_replies_by_string.joins(:author)
|
|
10
17
|
end
|
data/spec/test.db
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fake_arel
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 27
|
|
5
5
|
prerelease: false
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
|
-
-
|
|
9
|
-
version: "0.
|
|
8
|
+
- 8
|
|
9
|
+
version: "0.8"
|
|
10
10
|
platform: ruby
|
|
11
11
|
authors:
|
|
12
12
|
- Grant Ammons
|
|
@@ -14,7 +14,7 @@ autorequire:
|
|
|
14
14
|
bindir: bin
|
|
15
15
|
cert_chain: []
|
|
16
16
|
|
|
17
|
-
date: 2010-09-
|
|
17
|
+
date: 2010-09-20 00:00:00 -04:00
|
|
18
18
|
default_executable:
|
|
19
19
|
dependencies:
|
|
20
20
|
- !ruby/object:Gem::Dependency
|