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
|