fake_arel 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.0
1
+ 1.3.0
data/fake_arel.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{fake_arel}
8
- s.version = "1.2.0"
8
+ s.version = "1.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Grant Ammons"]
12
- s.date = %q{2013-05-15}
12
+ s.date = %q{2013-05-30}
13
13
  s.description = %q{fake_arel will simulate rails 3 arel syntax for Rails 2.}
14
14
  s.email = %q{grant@pipelinedealsco.com}
15
15
  s.extra_rdoc_files = [
@@ -3,7 +3,8 @@ module WithScopeReplacement
3
3
  base.class_eval do
4
4
  class << self
5
5
  def to_sql
6
- construct_finder_sql({})
6
+ jd = JoinDependency.new(self, merge_includes(scope(:find, :include), nil), nil)
7
+ construct_finder_sql_with_included_associations(current_scoped_methods, jd)
7
8
  end
8
9
 
9
10
  def with_scope(method_scoping = {}, action = :merge, &block)
@@ -37,16 +37,24 @@ describe "Fake Arel" do
37
37
  Reply.find_all_but_first.map(&:id).should == [2,3,4,5,6]
38
38
  end
39
39
 
40
- it "should be able to output sql" do
41
- sql = Topic.select('content').joins(:replies).limit(1).order('id desc').where(:author_id => 1).to_sql
42
- sql.should =~ /SELECT content/i
43
- sql.should =~ /JOIN "replies"/i
44
- sql.should =~ /"author_id" = 1/
45
- sql.should =~ /LIMIT 1/i
46
- sql.should =~ /ORDER BY id desc/i
47
- sql = Reply.topic_4_id_desc.to_sql
48
- sql.should =~ /"topic_id" = 4/
49
- sql.should =~ /ORDER BY id desc/i
40
+ describe ".to_sql" do
41
+ it "should be able to output sql" do
42
+ sql = Topic.select('content').joins(:replies).limit(1).order('id desc').where(:author_id => 1).to_sql
43
+ sql.should =~ /SELECT content/i
44
+ sql.should =~ /JOIN "replies"/i
45
+ sql.should =~ /"author_id" = 1/
46
+ sql.should =~ /LIMIT 1/i
47
+ sql.should =~ /ORDER BY id desc/i
48
+ sql = Reply.topic_4_id_desc.to_sql
49
+ sql.should =~ /"topic_id" = 4/
50
+ sql.should =~ /ORDER BY id desc/i
51
+ end
52
+
53
+ it "should includes includes when including included includes" do
54
+ sql = Topic.includes(:replies, :author).where("replies.id = 1").to_sql
55
+ p sql
56
+ sql.should =~ /JOIN "replies"/i
57
+ end
50
58
  end
51
59
 
52
60
  it "should generate same sql always" do
@@ -2,34 +2,34 @@ witty_retort:
2
2
  id: 1
3
3
  topic_id: 1
4
4
  content: Birdman is better!
5
- created_at: <%= 6.hours.ago.utc.to_s(:db) %>
5
+ created_at: <%= 6.hours.ago.to_s(:db) %>
6
6
 
7
7
  another:
8
8
  id: 2
9
9
  topic_id: 2
10
10
  content: Nuh uh!
11
- created_at: <%= 1.hour.ago.utc.to_s(:db) %>
11
+ created_at: <%= 1.hour.ago.to_s(:db) %>
12
12
 
13
13
  spam:
14
14
  id: 3
15
15
  topic_id: 1
16
16
  content: Nice site!
17
- created_at: <%= 1.hour.ago.utc.to_s(:db) %>
17
+ created_at: <%= 1.hour.ago.to_s(:db) %>
18
18
 
19
19
  decisive:
20
20
  id: 4
21
21
  topic_id: 4
22
22
  content: "I'm getting to the bottom of this"
23
- created_at: <%= 30.minutes.ago.utc.to_s(:db) %>
23
+ created_at: <%= 30.minutes.ago.to_s(:db) %>
24
24
 
25
25
  brave:
26
26
  id: 5
27
27
  topic_id: 4
28
28
  content: "AR doesn't scare me a bit"
29
- created_at: <%= 10.minutes.ago.utc.to_s(:db) %>
29
+ created_at: <%= 10.minutes.ago.to_s(:db) %>
30
30
 
31
31
  thang:
32
32
  id: 6
33
33
  topic_id: 4
34
34
  content: "AR This is some more content"
35
- created_at: <%= 10.hours.ago.utc.to_s(:db) %>
35
+ created_at: <%= 10.hours.ago.to_s(:db) %>
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: 31
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
- - 2
8
+ - 3
9
9
  - 0
10
- version: 1.2.0
10
+ version: 1.3.0
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: 2013-05-15 00:00:00 -04:00
18
+ date: 2013-05-30 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency