fake_arel 0.1.3 → 0.2

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.
@@ -14,8 +14,9 @@ module ActiveRecord
14
14
  ret = options.proxy_options
15
15
  while local_scope.class == ActiveRecord::NamedScope::Scope
16
16
  ret[:conditions] = merge_conditions(ret[:conditions], local_scope.proxy_options[:conditions])
17
- ret[:includes] = merge_includes(ret[:includes], local_scope.proxy_options[:includes]) if ret[:includes] or local_scope.proxy_options[:includes]
17
+ ret[:includes] = merge_includes(ret[:includes], local_scope.proxy_options[:includes]) if ret[:includes] || local_scope.proxy_options[:includes]
18
18
  ret[:joins] = merge_includes(ret[:joins], local_scope.proxy_options[:joins])
19
+ ret[:order] = merge_includes(ret[:order], local_scope.proxy_options[:order]) if ret[:order] || local_scope.proxy_options[:order]
19
20
  local_scope = local_scope.proxy_scope
20
21
  end
21
22
  ret
@@ -36,8 +37,9 @@ module ActiveRecord
36
37
 
37
38
  class Scope
38
39
  attr_reader :proxy_scope, :proxy_options, :current_scoped_methods_when_defined
40
+ undef select
39
41
  [].methods.each do |m|
40
- unless m =~ /^__/ || NON_DELEGATE_METHODS.include?(m.to_s)
42
+ unless m =~ /^__/ || (NON_DELEGATE_METHODS + ['select']).include?(m.to_s)
41
43
  delegate m, :to => :proxy_found
42
44
  end
43
45
  end
data/lib/fake_arel.rb CHANGED
@@ -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.1.3'
11
+ VERSION = '0.2'
12
12
  ActiveRecord::Base.send :include, Rails3Finders
13
13
  ActiveRecord::Base.send :include, WithScopeReplacement
14
14
  end
@@ -57,6 +57,16 @@ describe "chained nested named scopes" do
57
57
  Reply.filter_join_topic_and_author.recent_with_content_like_ar.all.should == Reply.find(:all, :conditions => "id = 5")
58
58
  end
59
59
 
60
+ it "should be able to take a select after a where" do
61
+ replies = Reply.where("id = 5").select(:id).all
62
+ replies.size.should == 1
63
+ replies[0].attributes.should == {"id" => 5}
64
+ end
65
+
66
+ it "should properly chain order scope in definitions" do
67
+ Reply.topic_4_id_asc.all.should == Reply.find(:all, :conditions => {:topic_id => 4}, :order=>'id asc')
68
+ Reply.topic_4_id_desc.all.should == Reply.find(:all, :conditions => {:topic_id => 4}, :order=>'id desc')
69
+ end
60
70
  end
61
71
 
62
72
  describe "keep scoped functionality" do
@@ -14,6 +14,11 @@ class Reply < ActiveRecord::Base
14
14
  named_scope :arel_id, :conditions => "id = 1"
15
15
  named_scope :arel_id_with_lambda, lambda {|aid| arel_id}
16
16
  named_scope :arel_id_with_nested_lambda, lambda {|aid| arel_id_with_lambda(aid)}
17
+
18
+ named_scope :id_asc, order('id asc')
19
+ named_scope :id_desc, order('id desc')
20
+ named_scope :topic_4_id_asc, id_asc.where(:topic_id => 4)
21
+ named_scope :topic_4_id_desc, id_desc.where(:topic_id => 4)
17
22
 
18
23
  validates_presence_of :content
19
24
 
data/spec/test.db CHANGED
Binary file
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fake_arel
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 3
10
- version: 0.1.3
8
+ - 2
9
+ version: "0.2"
11
10
  platform: ruby
12
11
  authors:
13
12
  - Grant Ammons
@@ -15,7 +14,7 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-07-30 00:00:00 -04:00
17
+ date: 2010-08-13 00:00:00 -04:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency