File: scope_test.rb

package info (click to toggle)
ruby-activerecord-deprecated-finders 1.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 188 kB
  • ctags: 94
  • sloc: ruby: 1,026; makefile: 2
file content (17 lines) | stat: -rw-r--r-- 434 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
require 'helper'

describe 'scope' do
  before do
    @klass = Class.new(ActiveRecord::Base)
  end

  it 'supports a finder hash' do
    assert_deprecated { @klass.scope :foo, conditions: :foo }
    @klass.foo.where_values.must_equal [:foo]
  end

  it 'supports a finder hash inside a callable' do
    @klass.scope :foo, ->(v) { { conditions: v } }
    assert_deprecated { @klass.foo(:bar) }.where_values.must_equal [:bar]
  end
end