【问题标题】:Update fixture column not working in case of ThinkingSphinx在 ThinkingSphinx 的情况下更新夹具列不起作用
【发布时间】:2016-09-22 06:28:47
【问题描述】:

我正在编写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

在我的情况下 message.update_column 没有生效,相反,如果我在消息夹具中进行相同的更改,那么我得到了我的测试用例 通过。

update_column 没有影响思考狮身人面像有什么具体原因,因为其他地方 update_column 工作得很好。

【问题讨论】:

  • 您是否在测试中使用事务性固定装置?
  • 是的,我正在使用跨国灯具

标签: ruby-on-rails thinking-sphinx


【解决方案1】:

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

The documentation 涵盖了使用 DatabaseCleaner 和对涉及 Sphinx 的测试使用删除方法的可能性 - 尽管该示例适用于 RSpec,而且看起来您使用的是不同的测试库,所以我不太确定在您的案例中如何实现这一点的具体细节。

【讨论】:

  • 我正在使用 rails minitest。我找到的解决方案是:make use_transactional_fixtures = false
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-05-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-12-09
  • 1970-01-01
相关资源
最近更新 更多