更新夹具列在 ThinkingSphinx 的情况下不起作用

Update fixture column not working in case of ThinkingSphinx

我在写thinking-Sphinx测试用例。我有以下测试用例

  test 'z' do

    app = applications(:one)
    message = messages(:two)
    message.update_column(:messagable_id, app.id)
    message.update_column(:comment, 'This is second message')

    ThinkingSphinx::Test.start
    sign_in @user
    ThinkingSphinx::Test.index

    get :index, company_id: @company.id,  qc: 'Messages', q: 'Body | second', format: 'json'
    assert_response :success
    assert_equal decode_json_response(@response)['apps'].count, 2
end

In my case message.update_column is not taking affect, instead if i make the same changes in messages fixture then i got my test case pass.

update_column 没有对 thinking sphinx 产生影响有什么具体原因吗,因为其他地方 update_column 都工作得很好。

如果您正在使用 SQL 支持的索引(如果您正在调用 index,看起来您是这样的?),那么您不能将事务性固定装置用于涉及的测试Sphinx/Thinking Sphinx,因为 Sphinx 的索引是通过与您的数据库的单独连接发生的,并且在您的测试范围内运行的事务不可用。

The documentation 涵盖了使用 DatabaseCleaner 和对涉及 Sphinx 的测试使用删除方法的可能性 - 虽然示例是针对 RSpec 的,但看起来您正在使用不同的测试库, 所以我不太确定在你的情况下如何实现这个的具体细节。