fake_arel 0.1.1 → 0.1.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.
@@ -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.1'
11
+ VERSION = '0.1.2'
12
12
  ActiveRecord::Base.send :include, Rails3Finders
13
13
  ActiveRecord::Base.send :include, WithScopeReplacement
14
14
  end
@@ -13,11 +13,9 @@ module ActiveRecord
13
13
  local_scope = options.proxy_scope
14
14
  ret = options.proxy_options
15
15
  while local_scope.class == ActiveRecord::NamedScope::Scope
16
- unless ret[:conditions].to_s.index merge_conditions(local_scope.proxy_options[:conditions])
17
- ret[:conditions] = merge_conditions(ret[:conditions], local_scope.proxy_options[:conditions])
18
- ret[:includes] = merge_includes(ret[:includes], local_scope.proxy_options[:includes]) if ret[:includes] or local_scope.proxy_options[:includes]
19
- ret[:joins] = merge_includes(ret[:joins], local_scope.proxy_options[:joins])
20
- end
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]
18
+ ret[:joins] = merge_includes(ret[:joins], local_scope.proxy_options[:joins])
21
19
  local_scope = local_scope.proxy_scope
22
20
  end
23
21
  ret
@@ -1,7 +1,7 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
  require 'reply'
3
3
  require 'topic'
4
-
4
+ require 'author'
5
5
 
6
6
  describe "Basics" do
7
7
  it "should accomplish basic where" do
@@ -51,4 +51,8 @@ describe "chained nested named scopes" do
51
51
  Reply.recent_joins_topic.topic_title_is("ActiveRecord").first.should == Reply.find(5)
52
52
  Reply.recent_joins_topic.topic_title_is("Nothin").first.should == nil
53
53
  end
54
+
55
+ it "should be able to join multiple items" do
56
+ Reply.filter_join_topic_and_author.first.topic.author
57
+ end
54
58
  end
@@ -8,6 +8,9 @@ class Reply < ActiveRecord::Base
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
 
11
+ named_scope :join_topic_and_author, joins(:topic => [:author])
12
+ named_scope :filter_join_topic_and_author, joins(:topic => [:author]).where('lower(replies.content) like ?','AR%')
13
+
11
14
  named_scope :arel_id, :conditions => "id = 1"
12
15
  named_scope :arel_id_with_lambda, lambda {|aid| arel_id}
13
16
  named_scope :arel_id_with_nested_lambda, lambda {|aid| arel_id_with_lambda(aid)}
@@ -1,6 +1,6 @@
1
1
  ActiveRecord::Schema.define do
2
2
  create_table "topics", :force => true do |t|
3
- t.column "project_id", :integer
3
+ t.column "author_id", :integer
4
4
  t.column "title", :string
5
5
  t.column "subtitle", :string
6
6
  t.column "content", :text
@@ -14,4 +14,10 @@ ActiveRecord::Schema.define do
14
14
  t.column "updated_at", :datetime
15
15
  t.column "topic_id", :integer
16
16
  end
17
+
18
+ create_table "authors", :force => true do |t|
19
+ t.column "name", :string
20
+ t.column "created_at", :datetime
21
+ t.column "updated_at", :datetime
22
+ end
17
23
  end
@@ -1,6 +1,6 @@
1
1
  class Topic < ActiveRecord::Base
2
2
  has_many :replies, :dependent => :destroy, :order => 'replies.created_at DESC'
3
- belongs_to :project
3
+ belongs_to :author
4
4
 
5
5
  named_scope :mentions_activerecord, :conditions => ['topics.title LIKE ?', '%ActiveRecord%']
6
6
 
@@ -1,5 +1,6 @@
1
1
  futurama:
2
2
  id: 1
3
+ author_id: 1
3
4
  title: Isnt futurama awesome?
4
5
  subtitle: It really is, isnt it.
5
6
  content: I like futurama
@@ -8,6 +9,7 @@ futurama:
8
9
 
9
10
  harvey_birdman:
10
11
  id: 2
12
+ author_id: 1
11
13
  title: Harvey Birdman is the king of all men
12
14
  subtitle: yup
13
15
  content: He really is
@@ -16,7 +18,7 @@ harvey_birdman:
16
18
 
17
19
  rails:
18
20
  id: 3
19
- project_id: 1
21
+ author_id: 1
20
22
  title: Rails is nice
21
23
  subtitle: It makes me happy
22
24
  content: except when I have to hack internals to fix pagination. even then really.
@@ -24,7 +26,7 @@ rails:
24
26
 
25
27
  ar:
26
28
  id: 4
27
- project_id: 1
29
+ author_id: 1
28
30
  title: ActiveRecord sometimes freaks me out
29
31
  content: "I mean, what's the deal with eager loading?"
30
32
  created_at: <%= 15.minutes.ago.to_s(:db) %>
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: 25
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Grant Ammons