fake_arel 0.7 → 0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,7 +8,7 @@ require 'fake_arel/with_scope_replacement'
8
8
  require 'fake_arel/rails_3_finders'
9
9
 
10
10
  module FakeArel
11
- VERSION = '0.7'
11
+ VERSION = '0.8'
12
12
  ActiveRecord::Base.send :include, Rails3Finders
13
13
  ActiveRecord::Base.send :include, WithScopeReplacement
14
14
  end
@@ -41,8 +41,8 @@ module ActiveRecord
41
41
  elsif local_conditions
42
42
  ret[:conditions] = local_conditions
43
43
  end
44
- ret[:includes] = merge_includes(ret[:includes], local_scope.proxy_options[:includes]) if ret[:includes] || local_scope.proxy_options[:includes]
45
- ret[:joins] = merge_includes(ret[:joins], local_scope.proxy_options[: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
@@ -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
@@ -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
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: 5
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 7
9
- version: "0.7"
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-13 00:00:00 -04:00
17
+ date: 2010-09-20 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency