Sha256: 439c288e7b8208b04a0b04a3673a7672a0e913ed7e018aca14a95169190e984c

Contents?: true

Size: 1.12 KB

Versions: 3

Compression:

Stored size: 1.12 KB

Contents

require File.expand_path('../test_helper', __FILE__)

describe ".synchronize" do
  let(:topics){ Generate(3, :topics) }
  let(:titles){ %w(one two three) }

  setup do
    # update records outside of ActiveRecord knowing about it
    Topic.connection.execute( "UPDATE #{Topic.table_name} SET title='#{titles[0]}_haha' WHERE id=#{topics[0].id}", "Updating record 1 without ActiveRecord" )
    Topic.connection.execute( "UPDATE #{Topic.table_name} SET title='#{titles[1]}_haha' WHERE id=#{topics[1].id}", "Updating record 2 without ActiveRecord" )
    Topic.connection.execute( "UPDATE #{Topic.table_name} SET title='#{titles[2]}_haha' WHERE id=#{topics[2].id}", "Updating record 3 without ActiveRecord" )
  end

  it "reloads data for the specified records" do
    Book.synchronize topics

    actual_titles = topics.map(&:title)
    assert_equal "#{titles[0]}_haha", actual_titles[0], "the first record was not correctly updated"
    assert_equal "#{titles[1]}_haha", actual_titles[1], "the second record was not correctly updated"
    assert_equal "#{titles[2]}_haha", actual_titles[2], "the third record was not correctly updated"
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
activerecord-import-0.4.1 test/synchronize_test.rb
activerecord-import-0.4.0 test/synchronize_test.rb
activerecord-import-rails4-0.5.0 test/synchronize_test.rb