fake_arel 1.0.0.a → 1.0.0
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.
- data/VERSION +1 -1
- data/fake_arel.gemspec +4 -4
- data/lib/fake_arel/extensions.rb +4 -1
- data/lib/fake_arel/rails_3_finders.rb +1 -1
- data/spec/fake_arel_spec.rb +11 -1
- data/spec/fixtures/topic.rb +1 -0
- metadata +35 -38
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.0
|
1
|
+
1.0.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.0.0
|
8
|
+
s.version = "1.0.0"
|
9
9
|
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new("
|
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{
|
12
|
+
s.date = %q{2012-04-03}
|
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 = [
|
@@ -51,7 +51,7 @@ Gem::Specification.new do |s|
|
|
51
51
|
s.homepage = %q{http://github.com/gammons/fake_arel}
|
52
52
|
s.licenses = ["MIT"]
|
53
53
|
s.require_paths = ["lib"]
|
54
|
-
s.rubygems_version = %q{1.
|
54
|
+
s.rubygems_version = %q{1.6.2}
|
55
55
|
s.summary = %q{fake_arel: a Rails 3 query interface to Rails 2}
|
56
56
|
|
57
57
|
if s.respond_to? :specification_version then
|
data/lib/fake_arel/extensions.rb
CHANGED
@@ -21,6 +21,7 @@ module ActiveRecord
|
|
21
21
|
|
22
22
|
class Scope
|
23
23
|
undef select
|
24
|
+
undef from
|
24
25
|
|
25
26
|
alias initialize_without_arel initialize
|
26
27
|
def initialize(proxy_scope, options = {}, &block)
|
@@ -51,7 +52,9 @@ module ActiveRecord
|
|
51
52
|
ret[:joins] = merge_joins((ret[:joins] || []), (local_scope.proxy_options[:joins] || []))
|
52
53
|
end
|
53
54
|
end
|
54
|
-
|
55
|
+
local_proxy_order_options = local_scope.proxy_options[:order].split(',') unless local_scope.proxy_options[:order].nil?
|
56
|
+
ret_order_options = ret[:order].split(',') unless ret[:order].nil?
|
57
|
+
ret[:order] = [local_proxy_order_options, ret_order_options].flatten.uniq.select{|o| !o.blank?}.join(',') if ret[:order] || local_scope.proxy_options[:order]
|
55
58
|
local_scope = local_scope.proxy_scope
|
56
59
|
end
|
57
60
|
ret
|
@@ -11,7 +11,7 @@ module Rails3Finders
|
|
11
11
|
named_scope :joins, lambda {|*join| {:joins => join } if join[0]}
|
12
12
|
named_scope :from, lambda {|*from| {:from => from }}
|
13
13
|
named_scope :having, lambda {|*having| {:having => having }}
|
14
|
-
named_scope :group, lambda {|*group| {:group => group }}
|
14
|
+
named_scope :group, lambda {|*group| {:group => group.join(',') }}
|
15
15
|
named_scope :readonly, lambda {|readonly| {:readonly => readonly }}
|
16
16
|
named_scope :lock, lambda {|lock| {:lock => lock }}
|
17
17
|
|
data/spec/fake_arel_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
require 'reply'
|
3
3
|
require 'topic'
|
4
4
|
require 'author'
|
@@ -48,6 +48,12 @@ describe "Fake Arel" do
|
|
48
48
|
sql.should =~ /"topic_id" = 4/
|
49
49
|
sql.should =~ /ORDER BY id desc/i
|
50
50
|
end
|
51
|
+
|
52
|
+
it "should generate same sql always" do
|
53
|
+
first_sql = Topic.first_four_sorted_by_date.to_sql
|
54
|
+
second_sql = Topic.first_four_sorted_by_date.to_sql
|
55
|
+
first_sql.should == second_sql
|
56
|
+
end
|
51
57
|
it "should not dublication conditions" do
|
52
58
|
sql = Topic.select('content').joins(:replies).limit(1).order('id desc').where(:author_id => 1).to_sql
|
53
59
|
sql.should_not =~ /"author_id" = 1.+"author_id" = 1/
|
@@ -71,6 +77,10 @@ describe "Fake Arel" do
|
|
71
77
|
replies[0].attributes.should == {"id" => 5}
|
72
78
|
end
|
73
79
|
|
80
|
+
it "should be able to group properly" do
|
81
|
+
Reply.group(:topic_id).map(&:topic_id).sort.should == [1, 2, 4].sort
|
82
|
+
end
|
83
|
+
|
74
84
|
it "should properly chain order scope in definitions" do
|
75
85
|
Reply.topic_4_id_asc.all.should == Reply.find(:all, :conditions => {:topic_id => 4}, :order=>'id asc')
|
76
86
|
Reply.topic_4_id_desc.all.should == Reply.find(:all, :conditions => {:topic_id => 4}, :order=>'id desc')
|
data/spec/fixtures/topic.rb
CHANGED
@@ -15,4 +15,5 @@ class Topic < ActiveRecord::Base
|
|
15
15
|
named_scope :join_replies_by_string_and_author, join_replies_by_string.joins(:author)
|
16
16
|
named_scope :join_replies_by_string_and_author_lambda, join_replies_by_string.joins(:author)
|
17
17
|
named_scope :select_only_id, select('id as super_duper_id').includes(:replies)
|
18
|
+
named_scope :first_four_sorted_by_date, order('id ASC').order('created_at DESC').limit(4)
|
18
19
|
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fake_arel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 23
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
9
|
- 0
|
10
|
-
|
11
|
-
version: 1.0.0.a
|
10
|
+
version: 1.0.0
|
12
11
|
platform: ruby
|
13
12
|
authors:
|
14
13
|
- Grant Ammons
|
@@ -16,14 +15,11 @@ autorequire:
|
|
16
15
|
bindir: bin
|
17
16
|
cert_chain: []
|
18
17
|
|
19
|
-
date:
|
18
|
+
date: 2012-04-03 00:00:00 -04:00
|
20
19
|
default_executable:
|
21
20
|
dependencies:
|
22
21
|
- !ruby/object:Gem::Dependency
|
23
|
-
|
24
|
-
name: activerecord
|
25
|
-
type: :runtime
|
26
|
-
version_requirements: &id001 !ruby/object:Gem::Requirement
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
27
23
|
none: false
|
28
24
|
requirements:
|
29
25
|
- - ~>
|
@@ -34,12 +30,12 @@ dependencies:
|
|
34
30
|
- 3
|
35
31
|
- 11
|
36
32
|
version: 2.3.11
|
37
|
-
requirement: *id001
|
38
|
-
- !ruby/object:Gem::Dependency
|
39
33
|
prerelease: false
|
40
|
-
name:
|
41
|
-
|
42
|
-
|
34
|
+
name: activerecord
|
35
|
+
version_requirements: *id001
|
36
|
+
type: :runtime
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
43
39
|
none: false
|
44
40
|
requirements:
|
45
41
|
- - ~>
|
@@ -50,12 +46,12 @@ dependencies:
|
|
50
46
|
- 0
|
51
47
|
- 0
|
52
48
|
version: 1.0.0
|
53
|
-
requirement: *id002
|
54
|
-
- !ruby/object:Gem::Dependency
|
55
49
|
prerelease: false
|
56
|
-
name:
|
50
|
+
name: bundler
|
51
|
+
version_requirements: *id002
|
57
52
|
type: :development
|
58
|
-
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
59
55
|
none: false
|
60
56
|
requirements:
|
61
57
|
- - ~>
|
@@ -66,12 +62,12 @@ dependencies:
|
|
66
62
|
- 6
|
67
63
|
- 4
|
68
64
|
version: 1.6.4
|
69
|
-
requirement: *id003
|
70
|
-
- !ruby/object:Gem::Dependency
|
71
65
|
prerelease: false
|
72
|
-
name:
|
66
|
+
name: jeweler
|
67
|
+
version_requirements: *id003
|
73
68
|
type: :development
|
74
|
-
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
75
71
|
none: false
|
76
72
|
requirements:
|
77
73
|
- - ">="
|
@@ -80,12 +76,12 @@ dependencies:
|
|
80
76
|
segments:
|
81
77
|
- 0
|
82
78
|
version: "0"
|
83
|
-
requirement: *id004
|
84
|
-
- !ruby/object:Gem::Dependency
|
85
79
|
prerelease: false
|
86
|
-
name:
|
80
|
+
name: rcov
|
81
|
+
version_requirements: *id004
|
87
82
|
type: :development
|
88
|
-
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
89
85
|
none: false
|
90
86
|
requirements:
|
91
87
|
- - "="
|
@@ -96,12 +92,12 @@ dependencies:
|
|
96
92
|
- 3
|
97
93
|
- 1
|
98
94
|
version: 1.3.1
|
99
|
-
requirement: *id005
|
100
|
-
- !ruby/object:Gem::Dependency
|
101
95
|
prerelease: false
|
102
|
-
name:
|
96
|
+
name: rspec
|
97
|
+
version_requirements: *id005
|
103
98
|
type: :development
|
104
|
-
|
99
|
+
- !ruby/object:Gem::Dependency
|
100
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
105
101
|
none: false
|
106
102
|
requirements:
|
107
103
|
- - ">="
|
@@ -110,7 +106,10 @@ dependencies:
|
|
110
106
|
segments:
|
111
107
|
- 0
|
112
108
|
version: "0"
|
113
|
-
|
109
|
+
prerelease: false
|
110
|
+
name: sqlite3-ruby
|
111
|
+
version_requirements: *id006
|
112
|
+
type: :development
|
114
113
|
description: fake_arel will simulate rails 3 arel syntax for Rails 2.
|
115
114
|
email: grant@pipelinedealsco.com
|
116
115
|
executables: []
|
@@ -172,18 +171,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
172
171
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
173
172
|
none: false
|
174
173
|
requirements:
|
175
|
-
- - "
|
174
|
+
- - ">="
|
176
175
|
- !ruby/object:Gem::Version
|
177
|
-
hash:
|
176
|
+
hash: 3
|
178
177
|
segments:
|
179
|
-
-
|
180
|
-
|
181
|
-
- 1
|
182
|
-
version: 1.3.1
|
178
|
+
- 0
|
179
|
+
version: "0"
|
183
180
|
requirements: []
|
184
181
|
|
185
182
|
rubyforge_project:
|
186
|
-
rubygems_version: 1.
|
183
|
+
rubygems_version: 1.6.2
|
187
184
|
signing_key:
|
188
185
|
specification_version: 3
|
189
186
|
summary: "fake_arel: a Rails 3 query interface to Rails 2"
|