File: update_all_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 (24 lines) | stat: -rw-r--r-- 583 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
require 'helper'

describe 'update_all' do
  after do
    Post.destroy_all
  end

  it 'supports conditions' do
    foo = Post.create title: 'foo'
    bar = Post.create title: 'bar'

    assert_deprecated { Post.update_all({ title: 'omg' }, title: 'foo') }

    foo.reload.title.must_equal 'omg'
    bar.reload.title.must_equal 'bar'
  end

  it 'supports limit and order' do
    posts = 3.times.map { Post.create }
    assert_deprecated { Post.update_all({ title: 'omg' }, nil, limit: 2, order: :id) }

    posts.each(&:reload).map(&:title).must_equal ['omg', 'omg', nil]
  end
end