Giter Club home page Giter Club logo

Comments (8)

gaffneyc avatar gaffneyc commented on June 29, 2024

That is odd. Are you overwriting Sunspot.session in your test environment at all?

from sunspot-queue.

jianbo avatar jianbo commented on June 29, 2024

Hi,
All I did was following, works fine in dev. Is there any config I need to do for Rspec test? Thanks

Rspec:
https://gist.github.com/jianbo/6289664

Sunspot.yml
test:
solr:
hostname: localhost
port: 8981
log_level: WARNING
auto_commit_after_request: true

Sunspot.rb
require "sunspot/queue/sidekiq"
backend = Sunspot::Queue::Sidekiq::Backend.new
Sunspot.session = Sunspot::Queue::SessionProxy.new(Sunspot.session, backend)

from sunspot-queue.

gaffneyc avatar gaffneyc commented on June 29, 2024

@jianbo two questions:

  1. Is sunspot.rb in config/initializers/?
  2. You're tagging your test with :search => true, what definitions do you have around that (e.g. before, after, etc...)

from sunspot-queue.

jianbo avatar jianbo commented on June 29, 2024

Hi,
The sunspot.rb is in my initializers. I copied search => true form
http://stackoverflow.com/questions/6989024/how-can-i-write-a-request-spec-with-capybara-rspec-for-testing-sunspot-solr-sear, and it doesn't have any effect before any after adding that, I also restarted solr for test env.

Thanks

from sunspot-queue.

gaffneyc avatar gaffneyc commented on June 29, 2024

@jianbo I'm guessing you're using sunspot_test that provides the tag for :search => true. It looks like the issue is on this line where sunspot_test is overriding Sunspot.session.

I'm not sure a good way to fix this because of how sunspot_test injects itself into testing. The below code (put in the right place in spec/spec_helper.rb might work but I have no idea.

before(:each, :search => true) do
  backend = Sunspot::Queue::Sidekiq::Backend.new
  Sunspot.session = Sunspot::Queue::SessionProxy.new(Sunspot.session, backend)
end

It looks like it's a strange interaction between sunspot_test (which hasn't been updated in 2 years) and sunspot_queue. Based on what I've seen I don't think this is an issue in sunspot_test itself.

from sunspot-queue.

jianbo avatar jianbo commented on June 29, 2024

Hi, sorry I didn't make it clear. The reindex didn not work before adding sunspot_test and "search => true", I only added now to see if it make any difference.

from sunspot-queue.

gaffneyc avatar gaffneyc commented on June 29, 2024

Hey @jianbo, so based on the little information I have it sounds like it's working fine in development but you're having issues in test mode. Based on that I don't think it's an issue with sunspot-queue and likely something to do with how your test environment is set up.

I would take a look at what is returned by Sunspot.session right before calling Toon.reindex in your test. If it's not an instance of Sunspot::Queue::SessionProxy then something in overwriting our proxy. The only other thing I can think of is that you have might Sidekiq set to run jobs inline, so they would get run immediately and not queued up like in development mode.

If you can track down the issue I'd love to hear what you found, especially if it's an issue inside sunspot-queue that we can fix for everyone else.

from sunspot-queue.

jianbo avatar jianbo commented on June 29, 2024

Its because of this line in my spec_helper.rb :)
require 'sidekiq/testing' # pushes jobs to array called jobs rather than redis

from sunspot-queue.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.