activerecord-deprecated_finders 0.0.1
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/.gitignore +17 -0
 - data/.travis.yml +8 -0
 - data/Gemfile +10 -0
 - data/LICENSE +22 -0
 - data/README.md +15 -0
 - data/Rakefile +28 -0
 - data/activerecord-deprecated_finders.gemspec +21 -0
 - data/lib/active_record/deprecated_finders.rb +10 -0
 - data/lib/active_record/deprecated_finders/association_builder.rb +78 -0
 - data/lib/active_record/deprecated_finders/base.rb +151 -0
 - data/lib/active_record/deprecated_finders/collection_proxy.rb +32 -0
 - data/lib/active_record/deprecated_finders/dynamic_matchers.rb +204 -0
 - data/lib/active_record/deprecated_finders/relation.rb +176 -0
 - data/lib/active_record/deprecated_finders/version.rb +5 -0
 - data/test/associations_test.rb +67 -0
 - data/test/calculate_test.rb +15 -0
 - data/test/default_scope_test.rb +35 -0
 - data/test/dynamic_methods_test.rb +133 -0
 - data/test/find_in_batches_test.rb +18 -0
 - data/test/finder_options_test.rb +86 -0
 - data/test/finder_test.rb +69 -0
 - data/test/helper.rb +37 -0
 - data/test/scope_test.rb +17 -0
 - data/test/scoped_test.rb +20 -0
 - data/test/update_all_test.rb +24 -0
 - data/test/with_scope_test.rb +36 -0
 - metadata +131 -0
 
| 
         @@ -0,0 +1,86 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe 'apply_finder_options' do
         
     | 
| 
      
 4 
     | 
    
         
            +
              before do
         
     | 
| 
      
 5 
     | 
    
         
            +
                @deprecation_behavior = ActiveSupport::Deprecation.behavior
         
     | 
| 
      
 6 
     | 
    
         
            +
                ActiveSupport::Deprecation.behavior = :silence
         
     | 
| 
      
 7 
     | 
    
         
            +
              end
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
              after do
         
     | 
| 
      
 10 
     | 
    
         
            +
                ActiveSupport::Deprecation.behavior = @deprecation_behavior
         
     | 
| 
      
 11 
     | 
    
         
            +
              end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
              it 'is deprecated' do
         
     | 
| 
      
 14 
     | 
    
         
            +
                assert_deprecated { Post.scoped.apply_finder_options(:conditions => 'foo') }
         
     | 
| 
      
 15 
     | 
    
         
            +
              end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              it 'supports :conditions' do
         
     | 
| 
      
 18 
     | 
    
         
            +
                scope = Post.scoped.apply_finder_options(:conditions => 'foo')
         
     | 
| 
      
 19 
     | 
    
         
            +
                scope.where_values.must_equal ['foo']
         
     | 
| 
      
 20 
     | 
    
         
            +
              end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
              it 'supports :include' do
         
     | 
| 
      
 23 
     | 
    
         
            +
                scope = Post.scoped.apply_finder_options(:include => :foo)
         
     | 
| 
      
 24 
     | 
    
         
            +
                scope.includes_values.must_equal [:foo]
         
     | 
| 
      
 25 
     | 
    
         
            +
              end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
              it 'supports :joins' do
         
     | 
| 
      
 28 
     | 
    
         
            +
                scope = Post.scoped.apply_finder_options(:joins => :foo)
         
     | 
| 
      
 29 
     | 
    
         
            +
                scope.joins_values.must_equal [:foo]
         
     | 
| 
      
 30 
     | 
    
         
            +
              end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
              it 'supports :limit' do
         
     | 
| 
      
 33 
     | 
    
         
            +
                scope = Post.scoped.apply_finder_options(:limit => 5)
         
     | 
| 
      
 34 
     | 
    
         
            +
                scope.limit_value.must_equal 5
         
     | 
| 
      
 35 
     | 
    
         
            +
              end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
              it 'supports :offset' do
         
     | 
| 
      
 38 
     | 
    
         
            +
                scope = Post.scoped.apply_finder_options(:offset => 5)
         
     | 
| 
      
 39 
     | 
    
         
            +
                scope.offset_value.must_equal 5
         
     | 
| 
      
 40 
     | 
    
         
            +
              end
         
     | 
| 
      
 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 
     | 
    
         
            +
              it "does not support :references (as it's new in 4.0)" do
         
     | 
| 
      
 49 
     | 
    
         
            +
                lambda { Post.scoped.apply_finder_options(references: :foo) }.must_raise ArgumentError
         
     | 
| 
      
 50 
     | 
    
         
            +
              end
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
              it 'supports :order' do
         
     | 
| 
      
 53 
     | 
    
         
            +
                scope = Post.scoped.apply_finder_options(:order => :foo)
         
     | 
| 
      
 54 
     | 
    
         
            +
                scope.order_values.must_equal [:foo]
         
     | 
| 
      
 55 
     | 
    
         
            +
              end
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
              it 'supports :select' do
         
     | 
| 
      
 58 
     | 
    
         
            +
                scope = Post.scoped.apply_finder_options(:select => :foo)
         
     | 
| 
      
 59 
     | 
    
         
            +
                scope.select_values.must_equal [:foo]
         
     | 
| 
      
 60 
     | 
    
         
            +
              end
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
              it 'supports :readonly' do
         
     | 
| 
      
 63 
     | 
    
         
            +
                scope = Post.scoped.apply_finder_options(:readonly => :foo)
         
     | 
| 
      
 64 
     | 
    
         
            +
                scope.readonly_value.must_equal :foo
         
     | 
| 
      
 65 
     | 
    
         
            +
              end
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
              it 'supports :group' do
         
     | 
| 
      
 68 
     | 
    
         
            +
                scope = Post.scoped.apply_finder_options(:group => :foo)
         
     | 
| 
      
 69 
     | 
    
         
            +
                scope.group_values.must_equal [:foo]
         
     | 
| 
      
 70 
     | 
    
         
            +
              end
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
              it 'supports :having' do
         
     | 
| 
      
 73 
     | 
    
         
            +
                scope = Post.scoped.apply_finder_options(:having => :foo)
         
     | 
| 
      
 74 
     | 
    
         
            +
                scope.having_values.must_equal [:foo]
         
     | 
| 
      
 75 
     | 
    
         
            +
              end
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
              it 'supports :from' do
         
     | 
| 
      
 78 
     | 
    
         
            +
                scope = Post.scoped.apply_finder_options(:from => :foo)
         
     | 
| 
      
 79 
     | 
    
         
            +
                scope.from_value.must_equal [:foo, nil]
         
     | 
| 
      
 80 
     | 
    
         
            +
              end
         
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
              it 'supports :lock' do
         
     | 
| 
      
 83 
     | 
    
         
            +
                scope = Post.scoped.apply_finder_options(:lock => true)
         
     | 
| 
      
 84 
     | 
    
         
            +
                scope.lock_value.must_equal true
         
     | 
| 
      
 85 
     | 
    
         
            +
              end
         
     | 
| 
      
 86 
     | 
    
         
            +
            end
         
     | 
    
        data/test/finder_test.rb
    ADDED
    
    | 
         @@ -0,0 +1,69 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe 'finders' do
         
     | 
| 
      
 4 
     | 
    
         
            +
              before do
         
     | 
| 
      
 5 
     | 
    
         
            +
                @posts = 3.times.map { |i| Post.create id: i + 1 }
         
     | 
| 
      
 6 
     | 
    
         
            +
              end
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              after do
         
     | 
| 
      
 9 
     | 
    
         
            +
                Post.delete_all
         
     | 
| 
      
 10 
     | 
    
         
            +
              end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              it 'supports find(:all) with no options' do
         
     | 
| 
      
 13 
     | 
    
         
            +
                assert_deprecated { Post.find(:all) }.must_equal @posts
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              it 'supports find(:all) with options' do
         
     | 
| 
      
 17 
     | 
    
         
            +
                assert_deprecated { Post.find(:all, conditions: 'id >= 2') }.must_equal [@posts[1], @posts[2]]
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              it 'supports all with options' do
         
     | 
| 
      
 21 
     | 
    
         
            +
                assert_deprecated { Post.all(conditions: 'id >= 2') }.must_equal [@posts[1], @posts[2]]
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
              it 'returns an array from all when there are options' do
         
     | 
| 
      
 25 
     | 
    
         
            +
                posts = ActiveSupport::Deprecation.silence { Post.all(conditions: 'id >= 2') }
         
     | 
| 
      
 26 
     | 
    
         
            +
                posts.class.must_equal Array
         
     | 
| 
      
 27 
     | 
    
         
            +
              end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
              it 'returns a relation from all when there are no options' do
         
     | 
| 
      
 30 
     | 
    
         
            +
                posts = Post.all
         
     | 
| 
      
 31 
     | 
    
         
            +
                posts.is_a?(ActiveRecord::Relation).must_equal true
         
     | 
| 
      
 32 
     | 
    
         
            +
              end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
              it 'deprecates #all on a relation' do
         
     | 
| 
      
 35 
     | 
    
         
            +
                relation = Post.where('id >= 2')
         
     | 
| 
      
 36 
     | 
    
         
            +
                assert_deprecated { relation.all }.must_equal [@posts[1], @posts[2]]
         
     | 
| 
      
 37 
     | 
    
         
            +
              end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
              it 'supports find(:first) with no options' do
         
     | 
| 
      
 40 
     | 
    
         
            +
                assert_deprecated { Post.order(:id).find(:first) }.must_equal @posts.first
         
     | 
| 
      
 41 
     | 
    
         
            +
              end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
              it 'supports find(:first) with options' do
         
     | 
| 
      
 44 
     | 
    
         
            +
                assert_deprecated { Post.order(:id).find(:first, conditions: 'id >= 2') }.must_equal @posts[1]
         
     | 
| 
      
 45 
     | 
    
         
            +
              end
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
              it 'supports first with options' do
         
     | 
| 
      
 48 
     | 
    
         
            +
                assert_deprecated { Post.order(:id).first(conditions: 'id >= 2') }.must_equal @posts[1]
         
     | 
| 
      
 49 
     | 
    
         
            +
              end
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
              it 'supports find(:last) with no options' do
         
     | 
| 
      
 52 
     | 
    
         
            +
                assert_deprecated { Post.order(:id).find(:last) }.must_equal @posts.last
         
     | 
| 
      
 53 
     | 
    
         
            +
              end
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
              it 'supports find(:last) with options' do
         
     | 
| 
      
 56 
     | 
    
         
            +
                assert_deprecated { Post.order(:id).find(:last, conditions: 'id <= 2') }.must_equal @posts[1]
         
     | 
| 
      
 57 
     | 
    
         
            +
              end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
              it 'supports last with options' do
         
     | 
| 
      
 60 
     | 
    
         
            +
                assert_deprecated { Post.order(:id).last(conditions: 'id <= 2') }.must_equal @posts[1]
         
     | 
| 
      
 61 
     | 
    
         
            +
              end
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
              it 'support find(1) etc with options' do
         
     | 
| 
      
 64 
     | 
    
         
            +
                assert_deprecated do
         
     | 
| 
      
 65 
     | 
    
         
            +
                  Post.find(1, conditions: '1=1').must_equal Post.find(1)
         
     | 
| 
      
 66 
     | 
    
         
            +
                  lambda { Post.find(1, conditions: '0=1') }.must_raise(ActiveRecord::RecordNotFound)
         
     | 
| 
      
 67 
     | 
    
         
            +
                end
         
     | 
| 
      
 68 
     | 
    
         
            +
              end
         
     | 
| 
      
 69 
     | 
    
         
            +
            end
         
     | 
    
        data/test/helper.rb
    ADDED
    
    | 
         @@ -0,0 +1,37 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'bundler/setup'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'minitest/spec'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'minitest/autorun'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'active_record'
         
     | 
| 
      
 5 
     | 
    
         
            +
            require 'active_record/deprecated_finders'
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            ActiveRecord::Schema.verbose = false
         
     | 
| 
      
 10 
     | 
    
         
            +
            ActiveRecord::Schema.define do
         
     | 
| 
      
 11 
     | 
    
         
            +
              create_table :posts do |t|
         
     | 
| 
      
 12 
     | 
    
         
            +
                t.string :title
         
     | 
| 
      
 13 
     | 
    
         
            +
                t.string :category
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              create_table :comments do |t|
         
     | 
| 
      
 17 
     | 
    
         
            +
                t.string :title
         
     | 
| 
      
 18 
     | 
    
         
            +
                t.references :post
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
            end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            class Post < ActiveRecord::Base
         
     | 
| 
      
 23 
     | 
    
         
            +
              has_many :comments
         
     | 
| 
      
 24 
     | 
    
         
            +
            end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
            class Comment < ActiveRecord::Base
         
     | 
| 
      
 27 
     | 
    
         
            +
              def self.lol
         
     | 
| 
      
 28 
     | 
    
         
            +
                "lol"
         
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
            end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
            require 'active_support/testing/deprecation'
         
     | 
| 
      
 33 
     | 
    
         
            +
            ActiveSupport::Deprecation.debug = true
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
            class MiniTest::Spec
         
     | 
| 
      
 36 
     | 
    
         
            +
              include ActiveSupport::Testing::Deprecation
         
     | 
| 
      
 37 
     | 
    
         
            +
            end
         
     | 
    
        data/test/scope_test.rb
    ADDED
    
    | 
         @@ -0,0 +1,17 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe 'scope' do
         
     | 
| 
      
 4 
     | 
    
         
            +
              before do
         
     | 
| 
      
 5 
     | 
    
         
            +
                @klass = Class.new(ActiveRecord::Base)
         
     | 
| 
      
 6 
     | 
    
         
            +
              end
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              it 'supports a finder hash' do
         
     | 
| 
      
 9 
     | 
    
         
            +
                assert_deprecated { @klass.scope :foo, conditions: :foo }
         
     | 
| 
      
 10 
     | 
    
         
            +
                @klass.foo.where_values.must_equal [:foo]
         
     | 
| 
      
 11 
     | 
    
         
            +
              end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
              it 'supports a finder hash inside a callable' do
         
     | 
| 
      
 14 
     | 
    
         
            +
                @klass.scope :foo, ->(v) { { conditions: v } }
         
     | 
| 
      
 15 
     | 
    
         
            +
                assert_deprecated { @klass.foo(:bar) }.where_values.must_equal [:bar]
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
            end
         
     | 
    
        data/test/scoped_test.rb
    ADDED
    
    | 
         @@ -0,0 +1,20 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe 'scoped' do
         
     | 
| 
      
 4 
     | 
    
         
            +
              it 'accepts a deprecated conditions option' do
         
     | 
| 
      
 5 
     | 
    
         
            +
                assert_deprecated { Post.scoped(conditions: :foo) }.where_values.must_equal [:foo]
         
     | 
| 
      
 6 
     | 
    
         
            +
              end
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              it 'accepts a deprecated include option' do
         
     | 
| 
      
 9 
     | 
    
         
            +
                assert_deprecated { Post.scoped(include: :foo) }.includes_values.must_equal [:foo]
         
     | 
| 
      
 10 
     | 
    
         
            +
              end
         
     | 
| 
      
 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 
     | 
    
         
            +
              it 'is deprecated' do
         
     | 
| 
      
 18 
     | 
    
         
            +
                assert_deprecated { Post.scoped }
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,24 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe 'update_all' do
         
     | 
| 
      
 4 
     | 
    
         
            +
              after do
         
     | 
| 
      
 5 
     | 
    
         
            +
                Post.destroy_all
         
     | 
| 
      
 6 
     | 
    
         
            +
              end
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              it 'supports conditions' do
         
     | 
| 
      
 9 
     | 
    
         
            +
                foo = Post.create title: 'foo'
         
     | 
| 
      
 10 
     | 
    
         
            +
                bar = Post.create title: 'bar'
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                assert_deprecated { Post.update_all({ title: 'omg' }, title: 'foo') }
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                foo.reload.title.must_equal 'omg'
         
     | 
| 
      
 15 
     | 
    
         
            +
                bar.reload.title.must_equal 'bar'
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
              it 'supports limit and order' do
         
     | 
| 
      
 19 
     | 
    
         
            +
                posts = 3.times.map { Post.create }
         
     | 
| 
      
 20 
     | 
    
         
            +
                assert_deprecated { Post.update_all({ title: 'omg' }, nil, limit: 2, order: :id) }
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                posts.each(&:reload).map(&:title).must_equal ['omg', 'omg', nil]
         
     | 
| 
      
 23 
     | 
    
         
            +
              end
         
     | 
| 
      
 24 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,36 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe 'with_scope' do
         
     | 
| 
      
 4 
     | 
    
         
            +
              before do
         
     | 
| 
      
 5 
     | 
    
         
            +
                Post.create(id: 1, title: 'foo')
         
     | 
| 
      
 6 
     | 
    
         
            +
                Post.create(id: 2, title: 'bar')
         
     | 
| 
      
 7 
     | 
    
         
            +
              end
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
              after do
         
     | 
| 
      
 10 
     | 
    
         
            +
                Post.delete_all
         
     | 
| 
      
 11 
     | 
    
         
            +
              end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
              it 'applies a scoping' do
         
     | 
| 
      
 14 
     | 
    
         
            +
                assert_deprecated do
         
     | 
| 
      
 15 
     | 
    
         
            +
                  Post.with_scope(find: { conditions: { title: 'foo' } }) do
         
     | 
| 
      
 16 
     | 
    
         
            +
                    assert_equal [1], Post.all.map(&:id)
         
     | 
| 
      
 17 
     | 
    
         
            +
                  end
         
     | 
| 
      
 18 
     | 
    
         
            +
                end
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
              it 'applies an exclusive scoping' do
         
     | 
| 
      
 22 
     | 
    
         
            +
                ActiveSupport::Deprecation.silence do
         
     | 
| 
      
 23 
     | 
    
         
            +
                  Post.with_scope(find: { conditions: { title: 'foo' } }) do
         
     | 
| 
      
 24 
     | 
    
         
            +
                    Post.send(:with_exclusive_scope, find: { conditions: { title: 'bar' } }) do
         
     | 
| 
      
 25 
     | 
    
         
            +
                      assert_equal [2], Post.all.map(&:id)
         
     | 
| 
      
 26 
     | 
    
         
            +
                    end
         
     | 
| 
      
 27 
     | 
    
         
            +
                  end
         
     | 
| 
      
 28 
     | 
    
         
            +
                end
         
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
              it 'gives a deprecation for #with_exclusive_scope' do
         
     | 
| 
      
 32 
     | 
    
         
            +
                assert_deprecated do
         
     | 
| 
      
 33 
     | 
    
         
            +
                  Post.send(:with_exclusive_scope) {}
         
     | 
| 
      
 34 
     | 
    
         
            +
                end
         
     | 
| 
      
 35 
     | 
    
         
            +
              end
         
     | 
| 
      
 36 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,131 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: activerecord-deprecated_finders
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.1
         
     | 
| 
      
 5 
     | 
    
         
            +
              prerelease: 
         
     | 
| 
      
 6 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 7 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 8 
     | 
    
         
            +
            - Jon Leighton
         
     | 
| 
      
 9 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 10 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 11 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2012-12-26 00:00:00.000000000 Z
         
     | 
| 
      
 13 
     | 
    
         
            +
            dependencies:
         
     | 
| 
      
 14 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 15 
     | 
    
         
            +
              name: minitest
         
     | 
| 
      
 16 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 17 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 18 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 19 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 20 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 21 
     | 
    
         
            +
                    version: '3'
         
     | 
| 
      
 22 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 23 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 24 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 25 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 26 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 27 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 28 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 29 
     | 
    
         
            +
                    version: '3'
         
     | 
| 
      
 30 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 31 
     | 
    
         
            +
              name: activerecord
         
     | 
| 
      
 32 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 33 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 34 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 35 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 36 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 37 
     | 
    
         
            +
                    version: 4.0.0.beta
         
     | 
| 
      
 38 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 39 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 40 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 41 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 42 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 43 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 44 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 45 
     | 
    
         
            +
                    version: 4.0.0.beta
         
     | 
| 
      
 46 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 47 
     | 
    
         
            +
              name: sqlite3
         
     | 
| 
      
 48 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 49 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 50 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 51 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 52 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 53 
     | 
    
         
            +
                    version: '1.3'
         
     | 
| 
      
 54 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 55 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 56 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 57 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 58 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 59 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 60 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 61 
     | 
    
         
            +
                    version: '1.3'
         
     | 
| 
      
 62 
     | 
    
         
            +
            description: This gem contains deprecated finder APIs extracted from Active Record.
         
     | 
| 
      
 63 
     | 
    
         
            +
            email:
         
     | 
| 
      
 64 
     | 
    
         
            +
            - j@jonathanleighton.com
         
     | 
| 
      
 65 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 66 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 67 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 68 
     | 
    
         
            +
            files:
         
     | 
| 
      
 69 
     | 
    
         
            +
            - .gitignore
         
     | 
| 
      
 70 
     | 
    
         
            +
            - .travis.yml
         
     | 
| 
      
 71 
     | 
    
         
            +
            - Gemfile
         
     | 
| 
      
 72 
     | 
    
         
            +
            - LICENSE
         
     | 
| 
      
 73 
     | 
    
         
            +
            - README.md
         
     | 
| 
      
 74 
     | 
    
         
            +
            - Rakefile
         
     | 
| 
      
 75 
     | 
    
         
            +
            - activerecord-deprecated_finders.gemspec
         
     | 
| 
      
 76 
     | 
    
         
            +
            - lib/active_record/deprecated_finders.rb
         
     | 
| 
      
 77 
     | 
    
         
            +
            - lib/active_record/deprecated_finders/association_builder.rb
         
     | 
| 
      
 78 
     | 
    
         
            +
            - lib/active_record/deprecated_finders/base.rb
         
     | 
| 
      
 79 
     | 
    
         
            +
            - lib/active_record/deprecated_finders/collection_proxy.rb
         
     | 
| 
      
 80 
     | 
    
         
            +
            - lib/active_record/deprecated_finders/dynamic_matchers.rb
         
     | 
| 
      
 81 
     | 
    
         
            +
            - lib/active_record/deprecated_finders/relation.rb
         
     | 
| 
      
 82 
     | 
    
         
            +
            - lib/active_record/deprecated_finders/version.rb
         
     | 
| 
      
 83 
     | 
    
         
            +
            - test/associations_test.rb
         
     | 
| 
      
 84 
     | 
    
         
            +
            - test/calculate_test.rb
         
     | 
| 
      
 85 
     | 
    
         
            +
            - test/default_scope_test.rb
         
     | 
| 
      
 86 
     | 
    
         
            +
            - test/dynamic_methods_test.rb
         
     | 
| 
      
 87 
     | 
    
         
            +
            - test/find_in_batches_test.rb
         
     | 
| 
      
 88 
     | 
    
         
            +
            - test/finder_options_test.rb
         
     | 
| 
      
 89 
     | 
    
         
            +
            - test/finder_test.rb
         
     | 
| 
      
 90 
     | 
    
         
            +
            - test/helper.rb
         
     | 
| 
      
 91 
     | 
    
         
            +
            - test/scope_test.rb
         
     | 
| 
      
 92 
     | 
    
         
            +
            - test/scoped_test.rb
         
     | 
| 
      
 93 
     | 
    
         
            +
            - test/update_all_test.rb
         
     | 
| 
      
 94 
     | 
    
         
            +
            - test/with_scope_test.rb
         
     | 
| 
      
 95 
     | 
    
         
            +
            homepage: https://github.com/rails/activerecord-deprecated_finders
         
     | 
| 
      
 96 
     | 
    
         
            +
            licenses: []
         
     | 
| 
      
 97 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 98 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 99 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 100 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 101 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 102 
     | 
    
         
            +
              none: false
         
     | 
| 
      
 103 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 104 
     | 
    
         
            +
              - - ! '>='
         
     | 
| 
      
 105 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 106 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 107 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 108 
     | 
    
         
            +
              none: false
         
     | 
| 
      
 109 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 110 
     | 
    
         
            +
              - - ! '>='
         
     | 
| 
      
 111 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 112 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 113 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 114 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 115 
     | 
    
         
            +
            rubygems_version: 1.8.23
         
     | 
| 
      
 116 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 117 
     | 
    
         
            +
            specification_version: 3
         
     | 
| 
      
 118 
     | 
    
         
            +
            summary: This gem contains deprecated finder APIs extracted from Active Record.
         
     | 
| 
      
 119 
     | 
    
         
            +
            test_files:
         
     | 
| 
      
 120 
     | 
    
         
            +
            - test/associations_test.rb
         
     | 
| 
      
 121 
     | 
    
         
            +
            - test/calculate_test.rb
         
     | 
| 
      
 122 
     | 
    
         
            +
            - test/default_scope_test.rb
         
     | 
| 
      
 123 
     | 
    
         
            +
            - test/dynamic_methods_test.rb
         
     | 
| 
      
 124 
     | 
    
         
            +
            - test/find_in_batches_test.rb
         
     | 
| 
      
 125 
     | 
    
         
            +
            - test/finder_options_test.rb
         
     | 
| 
      
 126 
     | 
    
         
            +
            - test/finder_test.rb
         
     | 
| 
      
 127 
     | 
    
         
            +
            - test/helper.rb
         
     | 
| 
      
 128 
     | 
    
         
            +
            - test/scope_test.rb
         
     | 
| 
      
 129 
     | 
    
         
            +
            - test/scoped_test.rb
         
     | 
| 
      
 130 
     | 
    
         
            +
            - test/update_all_test.rb
         
     | 
| 
      
 131 
     | 
    
         
            +
            - test/with_scope_test.rb
         
     |