jasmine-rails icon indicating copy to clipboard operation
jasmine-rails copied to clipboard

Jasmine runner at '/specs' returned a 302 error: Found

Open ezilocchi opened this issue 12 years ago • 11 comments

I'm using jasmine-rails-0.4.5 and devise-2.2.3 in a standard rails-3.2 app. When I run bundle exec rake spec:javascript, in order to run the jasmine specs, I'm getting the following message: "Jasmine runner at '/specs' returned a 302 error: Found"

Since I'm using devise any request against the server that is not authenticated yet, it's being redirected to the log-in page. So far so good, that is the expected behavior from devise, but jasmine-rails need to access the /specs url in order to run the tests, so when it tries to access this it, it's getting this error: "Jasmine runner at '/specs' returned a 302 error: Found"

In my routes.rb file I added this line: "mount JasmineRails::Engine => "/my_specs" if defined?(JasmineRails)"

ezilocchi avatar Jun 18 '13 20:06 ezilocchi

This is an issue I've seen with Devise as well. Any ideas or PRs would be very much appreciated!

On Jun 18, 2013, at 2:10 PM, Emiliano Zilocchi [email protected] wrote:

I'm using jasmine-rails-0.4.5 and devise-2.2.3 in a standard rails-3.2 app. When I run bundle exec rake spec:javascript, in order to run the jasmine specs, I'm getting the following message: "Jasmine runner at '/specs' returned a 302 error: Found"

Since I'm using devise any request against the server that is not authenticated yet, it's being redirected to the log-in page. So far so good, that is the expected behavior from devise, but jasmine-rails need to access the /specs url in order to run the tests, so when it tries to access this it, it's getting this error: "Jasmine runner at '/specs' returned a 302 error: Found"

In my routes.rb file I added this line: "mount JasmineRails::Engine => "/my_specs" if defined?(JasmineRails)"

— Reply to this email directly or view it on GitHub.

searls avatar Jun 18 '13 20:06 searls

Ran into the same issue. Was able to get around it by mounting the route above the Devise scope

pathouse avatar Jul 09 '13 21:07 pathouse

Kudos @pathouse. I'll leave this open in case a Devise expert wants to grace us with whatever wisdom I lack.

searls avatar Jul 12 '13 04:07 searls

What I currently do, is simply adding a skip_before_filter to the JasmineRails::SpecRunnerController

In config/application.rb

module MyApp
  class Application < Rails::Application
    # rest of the stuff here

    config.to_prepare do
      JasmineRails::SpecRunnerController.skip_before_filter :authenticate_user!
    end
  end
end

One option to make this unnecessary is to add the line skip_before_filter :authenticate_user! to the SpecRunnerController so the authentication is always skipped.

featureenvy avatar Jul 21 '13 13:07 featureenvy

Clever! I imagine that we'd want to do that conditionally (if it exists) and only if that's the standard name of the filter?

On Jul 21, 2013, at 9:42 AM, Andreas Arnold [email protected] wrote:

What I currently do, is simply adding a skip_before_filter to the JasmineRails::SpecRunnerController

In config/application.rb

module MyApp class Application < Rails::Application # rest of the stuff here

config.to_prepare do
  JasmineRails::SpecRunnerController.skip_before_filter :authenticate_user!
end

end end One option to make this unnecessary is to add the line skip_before_filter :authenticate_user! to the SpecRunnerController so the authentication is always skipped.


Reply to this email directly or view it on GitHub.

searls avatar Jul 21 '13 14:07 searls

Thinking about it a bit more, I realize this shouldn't even be necessary. SpecRunnerController inherits from JasmineRails::ApplicationController, so shouldn't even get the authentication filter in the first place.

featureenvy avatar Jul 22 '13 07:07 featureenvy

I'm running into this as well; @featureenvy's solution hasn't worked for me. Digging for one...

trystant avatar Jul 24 '13 19:07 trystant

I am having this issue and I am not using Devise at all. In face I have no form of redirection, it's mostly an empty rails project. Any help?

dnajd avatar Sep 04 '14 20:09 dnajd

Could you provide the project as an example? We can't help without replicating your issue

On Thu, Sep 4, 2014 at 4:52 PM, Don [email protected] wrote:

I am having this issue and I am not using Devise at all. In face I have no form of redirection, it's mostly an empty rails project. Any help?

Reply to this email directly or view it on GitHub: https://github.com/searls/jasmine-rails/issues/46#issuecomment-54543070

searls avatar Sep 04 '14 20:09 searls

I found a solution... I yonked the jem and used this one instead:

https://github.com/pivotal/jasmine-gem

Pivotal rocks and that gem worked right out of the box.

dnajd avatar Sep 04 '14 20:09 dnajd

Ok

On Thu, Sep 4, 2014 at 4:58 PM, Don [email protected] wrote:

I found a solution... I yonked the jem and used this one instead: https://github.com/pivotal/jasmine-gem

Pivotal rocks and that gem worked right out of the box.

Reply to this email directly or view it on GitHub: https://github.com/searls/jasmine-rails/issues/46#issuecomment-54543926

searls avatar Sep 04 '14 20:09 searls