activerecord-deprecated_finders 0.0.1 → 0.0.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.
- data/activerecord-deprecated_finders.gemspec +1 -1
- data/activerecord-deprecated_finders.gemspec.erb +21 -0
- data/lib/active_record/deprecated_finders/association_builder.rb +2 -3
- data/lib/active_record/deprecated_finders/relation.rb +3 -4
- data/lib/active_record/deprecated_finders/version.rb +1 -1
- data/test/associations_test.rb +1 -16
- data/test/finder_options_test.rb +0 -6
- data/test/scoped_test.rb +0 -5
- metadata +4 -3
@@ -8,7 +8,7 @@ Gem::Specification.new do |gem|
|
|
8
8
|
gem.summary = %q{This gem contains deprecated finder APIs extracted from Active Record.}
|
9
9
|
gem.homepage = "https://github.com/rails/activerecord-deprecated_finders"
|
10
10
|
|
11
|
-
gem.files = [".gitignore",".travis.yml","Gemfile","LICENSE","README.md","Rakefile","activerecord-deprecated_finders.gemspec","lib/active_record/deprecated_finders.rb","lib/active_record/deprecated_finders/association_builder.rb","lib/active_record/deprecated_finders/base.rb","lib/active_record/deprecated_finders/collection_proxy.rb","lib/active_record/deprecated_finders/dynamic_matchers.rb","lib/active_record/deprecated_finders/relation.rb","lib/active_record/deprecated_finders/version.rb","test/associations_test.rb","test/calculate_test.rb","test/default_scope_test.rb","test/dynamic_methods_test.rb","test/find_in_batches_test.rb","test/finder_options_test.rb","test/finder_test.rb","test/helper.rb","test/scope_test.rb","test/scoped_test.rb","test/update_all_test.rb","test/with_scope_test.rb"]
|
11
|
+
gem.files = [".gitignore",".travis.yml","Gemfile","LICENSE","README.md","Rakefile","activerecord-deprecated_finders.gemspec","activerecord-deprecated_finders.gemspec.erb","lib/active_record/deprecated_finders.rb","lib/active_record/deprecated_finders/association_builder.rb","lib/active_record/deprecated_finders/base.rb","lib/active_record/deprecated_finders/collection_proxy.rb","lib/active_record/deprecated_finders/dynamic_matchers.rb","lib/active_record/deprecated_finders/relation.rb","lib/active_record/deprecated_finders/version.rb","test/associations_test.rb","test/calculate_test.rb","test/default_scope_test.rb","test/dynamic_methods_test.rb","test/find_in_batches_test.rb","test/finder_options_test.rb","test/finder_test.rb","test/helper.rb","test/scope_test.rb","test/scoped_test.rb","test/update_all_test.rb","test/with_scope_test.rb"]
|
12
12
|
gem.test_files = ["test/associations_test.rb","test/calculate_test.rb","test/default_scope_test.rb","test/dynamic_methods_test.rb","test/find_in_batches_test.rb","test/finder_options_test.rb","test/finder_test.rb","test/helper.rb","test/scope_test.rb","test/scoped_test.rb","test/update_all_test.rb","test/with_scope_test.rb"]
|
13
13
|
gem.executables = []
|
14
14
|
gem.name = "activerecord-deprecated_finders"
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/active_record/deprecated_finders/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Jon Leighton"]
|
6
|
+
gem.email = ["j@jonathanleighton.com"]
|
7
|
+
gem.description = %q{This gem contains deprecated finder APIs extracted from Active Record.}
|
8
|
+
gem.summary = %q{This gem contains deprecated finder APIs extracted from Active Record.}
|
9
|
+
gem.homepage = "https://github.com/rails/activerecord-deprecated_finders"
|
10
|
+
|
11
|
+
gem.files = [<%= files.map(&:inspect).join ',' %>]
|
12
|
+
gem.test_files = [<%= test_files.map(&:inspect).join ',' %>]
|
13
|
+
gem.executables = [<%= executables.map(&:inspect).join ',' %>]
|
14
|
+
gem.name = "activerecord-deprecated_finders"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = ActiveRecord::DeprecatedFinders::VERSION
|
17
|
+
|
18
|
+
gem.add_development_dependency 'minitest', '>= 3'
|
19
|
+
gem.add_development_dependency 'activerecord', '~> 4.0.0.beta'
|
20
|
+
gem.add_development_dependency 'sqlite3', '~> 1.3'
|
21
|
+
end
|
@@ -9,7 +9,6 @@ module ActiveRecord::Associations::Builder
|
|
9
9
|
def initialize(options)
|
10
10
|
options[:includes] = options.delete(:include) if options[:include]
|
11
11
|
options[:where] = options.delete(:conditions) if options[:conditions]
|
12
|
-
options[:extending] = options.delete(:extend) if options[:extend]
|
13
12
|
|
14
13
|
@options = options
|
15
14
|
end
|
@@ -34,9 +33,9 @@ module ActiveRecord::Associations::Builder
|
|
34
33
|
|
35
34
|
class Association
|
36
35
|
DEPRECATED_OPTIONS = [:readonly, :order, :limit, :group, :having,
|
37
|
-
:offset, :select, :uniq, :include, :conditions
|
36
|
+
:offset, :select, :uniq, :include, :conditions]
|
38
37
|
|
39
|
-
self.valid_options += [:select, :conditions, :include, :
|
38
|
+
self.valid_options += [:select, :conditions, :include, :readonly]
|
40
39
|
|
41
40
|
def initialize_with_deprecated_options(model, name, scope, options)
|
42
41
|
if scope.is_a?(Hash)
|
@@ -4,7 +4,7 @@ require 'active_support/core_ext/module/aliasing'
|
|
4
4
|
module ActiveRecord
|
5
5
|
class Relation
|
6
6
|
module DeprecatedMethods
|
7
|
-
VALID_FIND_OPTIONS = [ :conditions, :include, :joins, :limit, :offset,
|
7
|
+
VALID_FIND_OPTIONS = [ :conditions, :include, :joins, :limit, :offset,
|
8
8
|
:order, :select, :readonly, :group, :having, :from, :lock ]
|
9
9
|
|
10
10
|
# The silence_deprecation arg is for internal use, where we have already output a
|
@@ -19,13 +19,12 @@ module ActiveRecord
|
|
19
19
|
finders = options.dup
|
20
20
|
finders.delete_if { |key, value| value.nil? && key != :limit }
|
21
21
|
|
22
|
-
((VALID_FIND_OPTIONS - [:conditions, :include
|
22
|
+
((VALID_FIND_OPTIONS - [:conditions, :include]) & finders.keys).each do |finder|
|
23
23
|
relation = relation.send(finder, finders[finder])
|
24
24
|
end
|
25
25
|
|
26
26
|
relation = relation.where(finders[:conditions]) if options.has_key?(:conditions)
|
27
27
|
relation = relation.includes(finders[:include]) if options.has_key?(:include)
|
28
|
-
relation = relation.extending(finders[:extend]) if options.has_key?(:extend)
|
29
28
|
|
30
29
|
relation
|
31
30
|
end
|
@@ -76,7 +75,7 @@ module ActiveRecord
|
|
76
75
|
if options.except(:distinct).present?
|
77
76
|
ActiveSupport::Deprecation.warn(
|
78
77
|
"Relation#calculate with finder options is deprecated. Please build " \
|
79
|
-
"a scope and then call
|
78
|
+
"a scope and then call calculate on it instead."
|
80
79
|
)
|
81
80
|
|
82
81
|
apply_finder_options(options.except(:distinct), true)
|
data/test/associations_test.rb
CHANGED
@@ -8,12 +8,9 @@ describe 'associations' do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
it 'translates hash scope options into scopes' do
|
11
|
-
extension = Module.new
|
12
|
-
|
13
11
|
assert_deprecated do
|
14
12
|
@klass.has_many :comments, readonly: 'a', order: 'b', limit: 'c', group: 'd', having: 'e',
|
15
|
-
offset: 'f', select: 'g', uniq: 'h', include: 'i', conditions: 'j'
|
16
|
-
extend: extension
|
13
|
+
offset: 'f', select: 'g', uniq: 'h', include: 'i', conditions: 'j'
|
17
14
|
end
|
18
15
|
|
19
16
|
scope = @klass.new.comments
|
@@ -28,7 +25,6 @@ describe 'associations' do
|
|
28
25
|
scope.uniq_value.must_equal 'h'
|
29
26
|
scope.includes_values.must_equal ['i']
|
30
27
|
scope.where_values.must_include 'j'
|
31
|
-
scope.extensions.must_equal [extension]
|
32
28
|
end
|
33
29
|
|
34
30
|
it 'supports proc where values' do
|
@@ -46,17 +42,6 @@ describe 'associations' do
|
|
46
42
|
@klass.new(title: 'omg').comments.where_values.must_include 'omg'
|
47
43
|
end
|
48
44
|
|
49
|
-
it 'allows an extend option plus a block extension' do
|
50
|
-
mod = Module.new { def foo; 'foo'; end }
|
51
|
-
ActiveSupport::Deprecation.silence do
|
52
|
-
@klass.has_many(:comments, extend: mod) { def bar; 'bar'; end }
|
53
|
-
end
|
54
|
-
|
55
|
-
obj = @klass.new
|
56
|
-
obj.comments.foo.must_equal 'foo'
|
57
|
-
obj.comments.bar.must_equal 'bar'
|
58
|
-
end
|
59
|
-
|
60
45
|
it "allows a declaration with a scope with no options" do
|
61
46
|
ActiveSupport::Deprecation.silence do
|
62
47
|
@klass.has_many :comments, -> { limit 5 }
|
data/test/finder_options_test.rb
CHANGED
@@ -39,12 +39,6 @@ describe 'apply_finder_options' do
|
|
39
39
|
scope.offset_value.must_equal 5
|
40
40
|
end
|
41
41
|
|
42
|
-
it 'supports :extend' do
|
43
|
-
mod = Module.new
|
44
|
-
scope = Post.scoped.apply_finder_options(:extend => mod)
|
45
|
-
scope.extensions.must_include mod
|
46
|
-
end
|
47
|
-
|
48
42
|
it "does not support :references (as it's new in 4.0)" do
|
49
43
|
lambda { Post.scoped.apply_finder_options(references: :foo) }.must_raise ArgumentError
|
50
44
|
end
|
data/test/scoped_test.rb
CHANGED
@@ -9,11 +9,6 @@ describe 'scoped' do
|
|
9
9
|
assert_deprecated { Post.scoped(include: :foo) }.includes_values.must_equal [:foo]
|
10
10
|
end
|
11
11
|
|
12
|
-
it 'accepts a deprecated extend option' do
|
13
|
-
mod = Module.new
|
14
|
-
assert_deprecated { Post.scoped(extend: mod) }.extensions.must_equal [mod]
|
15
|
-
end
|
16
|
-
|
17
12
|
it 'is deprecated' do
|
18
13
|
assert_deprecated { Post.scoped }
|
19
14
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-deprecated_finders
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
@@ -73,6 +73,7 @@ files:
|
|
73
73
|
- README.md
|
74
74
|
- Rakefile
|
75
75
|
- activerecord-deprecated_finders.gemspec
|
76
|
+
- activerecord-deprecated_finders.gemspec.erb
|
76
77
|
- lib/active_record/deprecated_finders.rb
|
77
78
|
- lib/active_record/deprecated_finders/association_builder.rb
|
78
79
|
- lib/active_record/deprecated_finders/base.rb
|
@@ -112,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
113
|
version: '0'
|
113
114
|
requirements: []
|
114
115
|
rubyforge_project:
|
115
|
-
rubygems_version: 1.8.
|
116
|
+
rubygems_version: 1.8.24
|
116
117
|
signing_key:
|
117
118
|
specification_version: 3
|
118
119
|
summary: This gem contains deprecated finder APIs extracted from Active Record.
|