Permalink
Browse files

Add test for ignoring default scope when synchronizing

  • Loading branch information...
jkowens committed Sep 21, 2017
1 parent 9885d15 commit 4913dd33378efbd80c7be4b12bf552866d1dc59a
Showing with 10 additions and 0 deletions.
  1. +2 −0 test/models/topic.rb
  2. +8 −0 test/synchronize_test.rb
View
@@ -13,6 +13,8 @@ class Topic < ActiveRecord::Base
composed_of :description, mapping: [%w(title title), %w(author_name author_name)], allow_nil: true, class_name: "TopicDescription"
default_scope { where(approved: true) }
private
def word_count
View
@@ -30,4 +30,12 @@
assert_equal false, topics[1].changed?, "the second record was dirty"
assert_equal false, topics[2].changed?, "the third record was dirty"
end
it "ignores default scope" do
# update records outside of ActiveRecord knowing about it
Topic.connection.execute( "UPDATE #{Topic.table_name} SET approved='0' WHERE id=#{topics[0].id}", "Updating record 1 without ActiveRecord" )
Topic.synchronize topics
assert_equal false, topics[0].approved
end
end

0 comments on commit 4913dd3

Please sign in to comment.