edge_rider 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -2
- data/.ruby-version +1 -1
- data/.travis.yml +61 -10
- data/README.md +7 -8
- data/Rakefile +5 -61
- data/edge_rider.gemspec +2 -3
- data/gemfiles/Gemfile.2.3.mysql2 +16 -0
- data/gemfiles/Gemfile.2.3.mysql2.lock +37 -0
- data/gemfiles/Gemfile.3.2.mysql2 +16 -0
- data/gemfiles/Gemfile.3.2.mysql2.lock +62 -0
- data/gemfiles/Gemfile.4.2.mysql2 +15 -0
- data/gemfiles/Gemfile.4.2.mysql2.lock +66 -0
- data/gemfiles/Gemfile.4.2.pg +15 -0
- data/gemfiles/Gemfile.4.2.pg.lock +66 -0
- data/gemfiles/Gemfile.5.1.mysql2 +15 -0
- data/gemfiles/Gemfile.5.1.mysql2.lock +63 -0
- data/gemfiles/Gemfile.5.1.pg +15 -0
- data/gemfiles/Gemfile.5.1.pg.lock +63 -0
- data/lib/edge_rider.rb +2 -0
- data/lib/edge_rider/collect_column.rb +7 -1
- data/lib/edge_rider/collect_ids.rb +3 -3
- data/lib/edge_rider/development.rb +2 -15
- data/lib/edge_rider/util.rb +31 -2
- data/lib/edge_rider/version.rb +1 -1
- data/spec/{shared/spec/edge_rider → edge_rider}/collect_column_spec.rb +0 -0
- data/spec/{shared/spec/edge_rider → edge_rider}/collect_ids_spec.rb +2 -2
- data/spec/{shared/spec/edge_rider → edge_rider}/origin_class_spec.rb +0 -0
- data/spec/{shared/spec/edge_rider → edge_rider}/preload_associations_spec.rb +0 -0
- data/spec/{shared/spec/edge_rider → edge_rider}/scoped_spec.rb +2 -1
- data/spec/{shared/spec/edge_rider → edge_rider}/to_id_query_spec.rb +3 -3
- data/spec/{shared/spec/edge_rider → edge_rider}/to_sql_spec.rb +1 -1
- data/spec/{shared/spec/edge_rider → edge_rider}/traverse_association_spec.rb +0 -0
- data/spec/{shared/spec/edge_rider → edge_rider}/util_spec.rb +0 -0
- data/spec/spec_helper.rb +12 -0
- data/spec/support/database.rb +34 -0
- data/spec/{shared/app_root/config → support}/database.sample.yml +6 -2
- data/spec/support/database.travis.yml +9 -0
- data/spec/support/models.rb +92 -0
- metadata +60 -155
- data/spec/rails-2.3/.ruby-version +0 -1
- data/spec/rails-2.3/Gemfile +0 -17
- data/spec/rails-2.3/Gemfile.lock +0 -66
- data/spec/rails-2.3/Rakefile +0 -11
- data/spec/rails-2.3/app_root/config/boot.rb +0 -130
- data/spec/rails-2.3/app_root/config/environment.rb +0 -16
- data/spec/rails-2.3/app_root/config/environments/test.rb +0 -0
- data/spec/rails-2.3/app_root/config/initializers/fix_missing_source_file.rb +0 -1
- data/spec/rails-2.3/app_root/config/preinitializer.rb +0 -22
- data/spec/rails-2.3/app_root/config/routes.rb +0 -15
- data/spec/rails-2.3/app_root/log/.gitignore +0 -1
- data/spec/rails-2.3/rcov.opts +0 -2
- data/spec/rails-2.3/spec.opts +0 -5
- data/spec/rails-2.3/spec/spec_helper.rb +0 -25
- data/spec/rails-3.0/.rspec +0 -2
- data/spec/rails-3.0/.ruby-version +0 -1
- data/spec/rails-3.0/Gemfile +0 -12
- data/spec/rails-3.0/Gemfile.lock +0 -120
- data/spec/rails-3.0/Rakefile +0 -11
- data/spec/rails-3.0/app_root/.gitignore +0 -4
- data/spec/rails-3.0/app_root/config/application.rb +0 -33
- data/spec/rails-3.0/app_root/config/boot.rb +0 -15
- data/spec/rails-3.0/app_root/config/environment.rb +0 -7
- data/spec/rails-3.0/app_root/config/environments/test.rb +0 -37
- data/spec/rails-3.0/app_root/config/initializers/backtrace_silencers.rb +0 -9
- data/spec/rails-3.0/app_root/config/initializers/inflections.rb +0 -12
- data/spec/rails-3.0/app_root/config/initializers/mime_types.rb +0 -7
- data/spec/rails-3.0/app_root/config/initializers/secret_token.rb +0 -9
- data/spec/rails-3.0/app_root/config/initializers/session_store.rb +0 -10
- data/spec/rails-3.0/app_root/config/routes.rb +0 -5
- data/spec/rails-3.0/app_root/lib/tasks/.gitkeep +0 -0
- data/spec/rails-3.0/app_root/log/.gitkeep +0 -0
- data/spec/rails-3.0/app_root/script/rails +0 -6
- data/spec/rails-3.0/rcov.opts +0 -2
- data/spec/rails-3.0/spec/spec_helper.rb +0 -23
- data/spec/rails-3.2/.rspec +0 -2
- data/spec/rails-3.2/.ruby-version +0 -1
- data/spec/rails-3.2/Gemfile +0 -16
- data/spec/rails-3.2/Gemfile.lock +0 -135
- data/spec/rails-3.2/Rakefile +0 -12
- data/spec/rails-3.2/app_root/.gitignore +0 -4
- data/spec/rails-3.2/app_root/config/application.rb +0 -33
- data/spec/rails-3.2/app_root/config/boot.rb +0 -15
- data/spec/rails-3.2/app_root/config/environment.rb +0 -7
- data/spec/rails-3.2/app_root/config/environments/test.rb +0 -37
- data/spec/rails-3.2/app_root/config/initializers/backtrace_silencers.rb +0 -9
- data/spec/rails-3.2/app_root/config/initializers/inflections.rb +0 -12
- data/spec/rails-3.2/app_root/config/initializers/mime_types.rb +0 -7
- data/spec/rails-3.2/app_root/config/initializers/secret_token.rb +0 -9
- data/spec/rails-3.2/app_root/config/initializers/session_store.rb +0 -10
- data/spec/rails-3.2/app_root/config/routes.rb +0 -5
- data/spec/rails-3.2/app_root/log/.gitignore +0 -1
- data/spec/rails-3.2/rcov.opts +0 -2
- data/spec/rails-3.2/spec/spec_helper.rb +0 -25
- data/spec/rails-4.1/.rspec +0 -2
- data/spec/rails-4.1/.ruby-version +0 -1
- data/spec/rails-4.1/Gemfile +0 -17
- data/spec/rails-4.1/Gemfile.lock +0 -138
- data/spec/rails-4.1/Rakefile +0 -12
- data/spec/rails-4.1/app_root/.gitignore +0 -16
- data/spec/rails-4.1/app_root/bin/bundle +0 -3
- data/spec/rails-4.1/app_root/bin/rails +0 -8
- data/spec/rails-4.1/app_root/bin/rake +0 -8
- data/spec/rails-4.1/app_root/bin/spring +0 -18
- data/spec/rails-4.1/app_root/config/application.rb +0 -28
- data/spec/rails-4.1/app_root/config/boot.rb +0 -4
- data/spec/rails-4.1/app_root/config/environment.rb +0 -5
- data/spec/rails-4.1/app_root/config/environments/development.rb +0 -37
- data/spec/rails-4.1/app_root/config/environments/production.rb +0 -83
- data/spec/rails-4.1/app_root/config/environments/test.rb +0 -39
- data/spec/rails-4.1/app_root/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/rails-4.1/app_root/config/initializers/cookies_serializer.rb +0 -3
- data/spec/rails-4.1/app_root/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/rails-4.1/app_root/config/initializers/inflections.rb +0 -16
- data/spec/rails-4.1/app_root/config/initializers/mime_types.rb +0 -4
- data/spec/rails-4.1/app_root/config/initializers/session_store.rb +0 -3
- data/spec/rails-4.1/app_root/config/initializers/wrap_parameters.rb +0 -14
- data/spec/rails-4.1/app_root/config/routes.rb +0 -3
- data/spec/rails-4.1/app_root/config/secrets.yml +0 -22
- data/spec/rails-4.1/rcov.opts +0 -2
- data/spec/rails-4.1/spec/spec_helper.rb +0 -31
- data/spec/shared/app_root/app/controllers/application_controller.rb +0 -5
- data/spec/shared/app_root/app/models/allow_setting_id_on_create.rb +0 -21
- data/spec/shared/app_root/app/models/forum.rb +0 -11
- data/spec/shared/app_root/app/models/post.rb +0 -11
- data/spec/shared/app_root/app/models/profile.rb +0 -8
- data/spec/shared/app_root/app/models/topic.rb +0 -14
- data/spec/shared/app_root/app/models/user.rb +0 -13
- data/spec/shared/app_root/config/database.travis_ci.yml +0 -6
- data/spec/shared/app_root/db/migrate/001_create_test_tables.rb +0 -45
@@ -0,0 +1,15 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Runtime dependencies
|
4
|
+
gem 'activerecord', '~>4.2.0'
|
5
|
+
gem 'pg'
|
6
|
+
|
7
|
+
# Development dependencies
|
8
|
+
gem 'rake'
|
9
|
+
gem 'database_cleaner'
|
10
|
+
gem 'rspec'
|
11
|
+
gem 'has_defaults' # used by test models
|
12
|
+
gem 'gemika'
|
13
|
+
|
14
|
+
# Gem under test
|
15
|
+
gem 'edge_rider', :path => '..'
|
@@ -0,0 +1,66 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
edge_rider (0.3.2)
|
5
|
+
activerecord
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activemodel (4.2.7.1)
|
11
|
+
activesupport (= 4.2.7.1)
|
12
|
+
builder (~> 3.1)
|
13
|
+
activerecord (4.2.7.1)
|
14
|
+
activemodel (= 4.2.7.1)
|
15
|
+
activesupport (= 4.2.7.1)
|
16
|
+
arel (~> 6.0)
|
17
|
+
activesupport (4.2.7.1)
|
18
|
+
i18n (~> 0.7)
|
19
|
+
json (~> 1.7, >= 1.7.7)
|
20
|
+
minitest (~> 5.1)
|
21
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
22
|
+
tzinfo (~> 1.1)
|
23
|
+
arel (6.0.3)
|
24
|
+
builder (3.2.2)
|
25
|
+
database_cleaner (1.5.3)
|
26
|
+
diff-lcs (1.2.5)
|
27
|
+
gemika (0.3.2)
|
28
|
+
has_defaults (0.4.4)
|
29
|
+
activerecord
|
30
|
+
i18n (0.7.0)
|
31
|
+
json (1.8.3)
|
32
|
+
minitest (5.9.1)
|
33
|
+
pg (0.19.0)
|
34
|
+
rake (11.3.0)
|
35
|
+
rspec (3.5.0)
|
36
|
+
rspec-core (~> 3.5.0)
|
37
|
+
rspec-expectations (~> 3.5.0)
|
38
|
+
rspec-mocks (~> 3.5.0)
|
39
|
+
rspec-core (3.5.3)
|
40
|
+
rspec-support (~> 3.5.0)
|
41
|
+
rspec-expectations (3.5.0)
|
42
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
43
|
+
rspec-support (~> 3.5.0)
|
44
|
+
rspec-mocks (3.5.0)
|
45
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
46
|
+
rspec-support (~> 3.5.0)
|
47
|
+
rspec-support (3.5.0)
|
48
|
+
thread_safe (0.3.5)
|
49
|
+
tzinfo (1.2.2)
|
50
|
+
thread_safe (~> 0.1)
|
51
|
+
|
52
|
+
PLATFORMS
|
53
|
+
ruby
|
54
|
+
|
55
|
+
DEPENDENCIES
|
56
|
+
activerecord (~> 4.2.0)
|
57
|
+
database_cleaner
|
58
|
+
edge_rider!
|
59
|
+
gemika
|
60
|
+
has_defaults
|
61
|
+
pg
|
62
|
+
rake
|
63
|
+
rspec
|
64
|
+
|
65
|
+
BUNDLED WITH
|
66
|
+
1.12.5
|
@@ -0,0 +1,15 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Runtime dependencies
|
4
|
+
gem 'activerecord', '~>5.1.1'
|
5
|
+
gem 'mysql2'
|
6
|
+
|
7
|
+
# Development dependencies
|
8
|
+
gem 'rake'
|
9
|
+
gem 'database_cleaner'
|
10
|
+
gem 'rspec'
|
11
|
+
gem 'has_defaults' # used by test models
|
12
|
+
gem 'gemika'
|
13
|
+
|
14
|
+
# Gem under test
|
15
|
+
gem 'edge_rider', :path => '..'
|
@@ -0,0 +1,63 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
edge_rider (0.3.2)
|
5
|
+
activerecord
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activemodel (5.1.1)
|
11
|
+
activesupport (= 5.1.1)
|
12
|
+
activerecord (5.1.1)
|
13
|
+
activemodel (= 5.1.1)
|
14
|
+
activesupport (= 5.1.1)
|
15
|
+
arel (~> 8.0)
|
16
|
+
activesupport (5.1.1)
|
17
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
18
|
+
i18n (~> 0.7)
|
19
|
+
minitest (~> 5.1)
|
20
|
+
tzinfo (~> 1.1)
|
21
|
+
arel (8.0.0)
|
22
|
+
concurrent-ruby (1.0.5)
|
23
|
+
database_cleaner (1.6.1)
|
24
|
+
diff-lcs (1.3)
|
25
|
+
gemika (0.3.2)
|
26
|
+
has_defaults (0.4.4)
|
27
|
+
activerecord
|
28
|
+
i18n (0.8.1)
|
29
|
+
minitest (5.10.2)
|
30
|
+
mysql2 (0.4.6)
|
31
|
+
rake (12.0.0)
|
32
|
+
rspec (3.6.0)
|
33
|
+
rspec-core (~> 3.6.0)
|
34
|
+
rspec-expectations (~> 3.6.0)
|
35
|
+
rspec-mocks (~> 3.6.0)
|
36
|
+
rspec-core (3.6.0)
|
37
|
+
rspec-support (~> 3.6.0)
|
38
|
+
rspec-expectations (3.6.0)
|
39
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
40
|
+
rspec-support (~> 3.6.0)
|
41
|
+
rspec-mocks (3.6.0)
|
42
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
43
|
+
rspec-support (~> 3.6.0)
|
44
|
+
rspec-support (3.6.0)
|
45
|
+
thread_safe (0.3.6)
|
46
|
+
tzinfo (1.2.3)
|
47
|
+
thread_safe (~> 0.1)
|
48
|
+
|
49
|
+
PLATFORMS
|
50
|
+
ruby
|
51
|
+
|
52
|
+
DEPENDENCIES
|
53
|
+
activerecord (~> 5.1.1)
|
54
|
+
database_cleaner
|
55
|
+
edge_rider!
|
56
|
+
gemika
|
57
|
+
has_defaults
|
58
|
+
mysql2
|
59
|
+
rake
|
60
|
+
rspec
|
61
|
+
|
62
|
+
BUNDLED WITH
|
63
|
+
1.15.0
|
@@ -0,0 +1,15 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Runtime dependencies
|
4
|
+
gem 'activerecord', '~>5.1.1'
|
5
|
+
gem 'pg'
|
6
|
+
|
7
|
+
# Development dependencies
|
8
|
+
gem 'rake'
|
9
|
+
gem 'database_cleaner'
|
10
|
+
gem 'has_defaults' # used by test models
|
11
|
+
gem 'rspec'
|
12
|
+
gem 'gemika'
|
13
|
+
|
14
|
+
# Gem under test
|
15
|
+
gem 'edge_rider', :path => '..'
|
@@ -0,0 +1,63 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
edge_rider (0.3.2)
|
5
|
+
activerecord
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activemodel (5.1.1)
|
11
|
+
activesupport (= 5.1.1)
|
12
|
+
activerecord (5.1.1)
|
13
|
+
activemodel (= 5.1.1)
|
14
|
+
activesupport (= 5.1.1)
|
15
|
+
arel (~> 8.0)
|
16
|
+
activesupport (5.1.1)
|
17
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
18
|
+
i18n (~> 0.7)
|
19
|
+
minitest (~> 5.1)
|
20
|
+
tzinfo (~> 1.1)
|
21
|
+
arel (8.0.0)
|
22
|
+
concurrent-ruby (1.0.5)
|
23
|
+
database_cleaner (1.6.1)
|
24
|
+
diff-lcs (1.3)
|
25
|
+
gemika (0.3.2)
|
26
|
+
has_defaults (0.4.4)
|
27
|
+
activerecord
|
28
|
+
i18n (0.8.1)
|
29
|
+
minitest (5.10.2)
|
30
|
+
pg (0.20.0)
|
31
|
+
rake (12.0.0)
|
32
|
+
rspec (3.6.0)
|
33
|
+
rspec-core (~> 3.6.0)
|
34
|
+
rspec-expectations (~> 3.6.0)
|
35
|
+
rspec-mocks (~> 3.6.0)
|
36
|
+
rspec-core (3.6.0)
|
37
|
+
rspec-support (~> 3.6.0)
|
38
|
+
rspec-expectations (3.6.0)
|
39
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
40
|
+
rspec-support (~> 3.6.0)
|
41
|
+
rspec-mocks (3.6.0)
|
42
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
43
|
+
rspec-support (~> 3.6.0)
|
44
|
+
rspec-support (3.6.0)
|
45
|
+
thread_safe (0.3.6)
|
46
|
+
tzinfo (1.2.3)
|
47
|
+
thread_safe (~> 0.1)
|
48
|
+
|
49
|
+
PLATFORMS
|
50
|
+
ruby
|
51
|
+
|
52
|
+
DEPENDENCIES
|
53
|
+
activerecord (~> 5.1.1)
|
54
|
+
database_cleaner
|
55
|
+
edge_rider!
|
56
|
+
gemika
|
57
|
+
has_defaults
|
58
|
+
pg
|
59
|
+
rake
|
60
|
+
rspec
|
61
|
+
|
62
|
+
BUNDLED WITH
|
63
|
+
1.15.0
|
data/lib/edge_rider.rb
CHANGED
@@ -6,7 +6,13 @@ module EdgeRider
|
|
6
6
|
qualified_column_name = EdgeRider::Util.qualify_column_name(self, column_name)
|
7
7
|
if respond_to?(:pluck) # Rails 3.2+
|
8
8
|
scope = scoped({})
|
9
|
-
|
9
|
+
if distinct
|
10
|
+
if ActiveRecord::VERSION::MAJOR < 5
|
11
|
+
scope = scope.uniq
|
12
|
+
else
|
13
|
+
scope = scope.distinct
|
14
|
+
end
|
15
|
+
end
|
10
16
|
scope.pluck(qualified_column_name)
|
11
17
|
else # Rails 2
|
12
18
|
select = distinct ? "DISTINCT #{qualified_column_name}" : qualified_column_name
|
@@ -8,7 +8,7 @@ module EdgeRider
|
|
8
8
|
def collect_ids
|
9
9
|
collect do |obj|
|
10
10
|
case obj
|
11
|
-
when
|
11
|
+
when Integer then obj
|
12
12
|
when ActiveRecord::Base then obj.id
|
13
13
|
else raise Uncollectable, "Cannot collect an id from #{obj.inspect}"
|
14
14
|
end
|
@@ -41,7 +41,7 @@ module EdgeRider
|
|
41
41
|
::ActiveRecord::Associations::HasManyAssociation.send(:include, ActiveRecordScope)
|
42
42
|
::ActiveRecord::Associations::HasManyThroughAssociation.send(:include, ActiveRecordScope)
|
43
43
|
|
44
|
-
module
|
44
|
+
module Integer
|
45
45
|
|
46
46
|
def collect_ids
|
47
47
|
[self]
|
@@ -49,7 +49,7 @@ module EdgeRider
|
|
49
49
|
|
50
50
|
end
|
51
51
|
|
52
|
-
::
|
52
|
+
::Integer.send(:include, Integer)
|
53
53
|
|
54
54
|
end
|
55
55
|
end
|
@@ -2,24 +2,11 @@ module EdgeRider
|
|
2
2
|
module Development
|
3
3
|
extend self
|
4
4
|
|
5
|
-
def drop_all_tables
|
6
|
-
connection = ::ActiveRecord::Base.connection
|
7
|
-
connection.tables.each do |table|
|
8
|
-
connection.drop_table table
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def migrate_test_database
|
13
|
-
print "\033[30m" # dark gray text
|
14
|
-
drop_all_tables
|
15
|
-
::ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate")
|
16
|
-
print "\033[0m"
|
17
|
-
end
|
18
|
-
|
19
5
|
def selects_star_with_conditions_pattern(table, conditions)
|
20
6
|
table = Regexp.quote(table)
|
21
7
|
conditions = Regexp.quote(conditions) unless conditions.is_a?(Regexp)
|
22
|
-
|
8
|
+
quote = '[`"]?'
|
9
|
+
/\ASELECT (#{quote}#{table}#{quote}\.)?\* FROM #{quote}#{table}#{quote}\s+WHERE \(?#{conditions}\)?\s*\z/
|
23
10
|
end
|
24
11
|
|
25
12
|
end
|
data/lib/edge_rider/util.rb
CHANGED
@@ -41,7 +41,7 @@ module EdgeRider
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def define_association(owner, association, target, options)
|
44
|
-
if
|
44
|
+
if active_record_version < 4
|
45
45
|
owner.send association, target, options
|
46
46
|
else
|
47
47
|
# Reduce the options hash to the given keys and store the remainder in
|
@@ -53,8 +53,37 @@ module EdgeRider
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
+
def active_record_version
|
57
|
+
ActiveRecord::VERSION::MAJOR
|
58
|
+
end
|
59
|
+
|
56
60
|
def activerecord2?
|
57
|
-
|
61
|
+
active_record_version < 3
|
62
|
+
end
|
63
|
+
|
64
|
+
def rspec_version
|
65
|
+
if defined?(Spec)
|
66
|
+
1
|
67
|
+
else
|
68
|
+
require 'rspec/version'
|
69
|
+
RSpec::Version::STRING.to_i
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def rspec_root
|
74
|
+
if rspec_version == 1
|
75
|
+
Spec
|
76
|
+
else
|
77
|
+
RSpec
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def rspec_path
|
82
|
+
if rspec_version == 1
|
83
|
+
'spec'
|
84
|
+
else
|
85
|
+
'rspec'
|
86
|
+
end
|
58
87
|
end
|
59
88
|
|
60
89
|
end
|
data/lib/edge_rider/version.rb
CHANGED
File without changes
|
@@ -26,7 +26,7 @@ describe EdgeRider::CollectIds do
|
|
26
26
|
|
27
27
|
end
|
28
28
|
|
29
|
-
context 'when called on
|
29
|
+
context 'when called on an Integer' do
|
30
30
|
|
31
31
|
it 'should return the number as an array with a single element' do
|
32
32
|
5.collect_ids.should == [5]
|
@@ -42,7 +42,7 @@ describe EdgeRider::CollectIds do
|
|
42
42
|
|
43
43
|
end
|
44
44
|
|
45
|
-
context 'when called on an array of
|
45
|
+
context 'when called on an array of Integers' do
|
46
46
|
|
47
47
|
it 'should return the list itself' do
|
48
48
|
[1, 3].collect_ids.should == [1, 3]
|
File without changes
|
File without changes
|
@@ -41,13 +41,14 @@ describe EdgeRider::Scoped do
|
|
41
41
|
it 'can be used to add conditions to a has_many association' do
|
42
42
|
forum = Forum.create!
|
43
43
|
thema = Topic.create! :subject => 'Thema', :trashed => false, :forum => forum
|
44
|
+
other_topic = Topic.create! :subject => 'Other', :trashed => false, :forum => forum
|
44
45
|
trashed_thema = Topic.create! :subject => 'Thema', :trashed => true, :forum => forum
|
45
46
|
|
46
47
|
has_many_scope = forum.active_topics
|
47
48
|
# In Rails 3, #scoped on associations does not take parameters but turns
|
48
49
|
# an association into a real scope.
|
49
50
|
has_many_scope = has_many_scope.scoped if ActiveRecord::VERSION::MAJOR == 3
|
50
|
-
has_many_scope.scoped(:conditions => { :subject => 'Thema' }).should =~ [ thema ]
|
51
|
+
has_many_scope.scoped(:conditions => { :subject => 'Thema' }).to_a.should =~ [ thema ]
|
51
52
|
end
|
52
53
|
|
53
54
|
end
|
@@ -9,7 +9,7 @@ describe EdgeRider::ToIdQuery do
|
|
9
9
|
Forum.create!(:id => 2, :name => 'Name 2')
|
10
10
|
Forum.create!(:id => 3, :name => 'Name 2')
|
11
11
|
scope = Forum.scoped(:conditions => { :name => 'Name 2' })
|
12
|
-
scope.to_id_query.to_sql.should =~ EdgeRider::Development.selects_star_with_conditions_pattern('forums',
|
12
|
+
scope.to_id_query.to_sql.should =~ EdgeRider::Development.selects_star_with_conditions_pattern('forums', /["`]?forums["`]?\.["`]?id["`]? IN \(2,\s*3\)/)
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'should resolve and lose any JOINs' do
|
@@ -20,8 +20,8 @@ describe EdgeRider::ToIdQuery do
|
|
20
20
|
Topic.create!(:id => 101, :forum_id => 1)
|
21
21
|
Topic.create!(:id => 102, :forum_id => 2)
|
22
22
|
Topic.create!(:id => 103, :forum_id => 3)
|
23
|
-
scope = Topic.scoped(:joins => :forum, :conditions =>
|
24
|
-
scope.to_id_query.to_sql.should =~ EdgeRider::Development.selects_star_with_conditions_pattern('topics',
|
23
|
+
scope = Topic.scoped(:joins => :forum, :conditions => "forums.name = 'A'")
|
24
|
+
scope.to_id_query.to_sql.should =~ EdgeRider::Development.selects_star_with_conditions_pattern('topics', /["`]?topics["`]?\.["`]?id["`]? IN \(100,\s*101,\s*103\)/)
|
25
25
|
end
|
26
26
|
|
27
27
|
end
|
@@ -6,7 +6,7 @@ describe EdgeRider::ToSql do
|
|
6
6
|
|
7
7
|
it "should return the SQL the scope would produce" do
|
8
8
|
scope = Forum.scoped(:conditions => { :name => 'Name' })
|
9
|
-
scope.to_sql.should =~ EdgeRider::Development.selects_star_with_conditions_pattern('forums', "`forums
|
9
|
+
scope.to_sql.should =~ EdgeRider::Development.selects_star_with_conditions_pattern('forums', /["`]?forums["`]?\.["`]?name["`]? = 'Name'/)
|
10
10
|
end
|
11
11
|
|
12
12
|
end
|