I am writing thinking-Sphinx test cases. i have following test case
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.
Is there any specific reason why update_column is not taking affect with thinking sphinx because everywhere else update_column is working just fine.
If you're using SQL-backed indices (and it seems you are, if you're calling index
?), then you can't use transactional fixtures for tests which involve Sphinx/Thinking Sphinx, because Sphinx's indexing happens via separate connections to your database, and the transaction that's operating within the scope of your test isn't available.
The documentation covers the possibility of using DatabaseCleaner and using the deletion approach for tests that involve Sphinx - though the example is for RSpec, and it looks like you're using a different testing library, so I'm not quite sure of the specifics of how to implement this in your case.