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 +1 -1
- data/fake_arel.gemspec +2 -2
- data/lib/fake_arel/with_scope_replacement.rb +2 -1
- data/spec/fake_arel_spec.rb +18 -10
- data/spec/fixtures/replies.yml +6 -6
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
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.
|
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-
|
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
|
-
|
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)
|
data/spec/fake_arel_spec.rb
CHANGED
@@ -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
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
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
|
data/spec/fixtures/replies.yml
CHANGED
@@ -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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
8
|
+
- 3
|
9
9
|
- 0
|
10
|
-
version: 1.
|
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-
|
18
|
+
date: 2013-05-30 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|