Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with integration tests under Rails 6 #335

Open
legacy370 opened this issue Feb 16, 2023 · 1 comment
Open

Problem with integration tests under Rails 6 #335

legacy370 opened this issue Feb 16, 2023 · 1 comment
Labels
can't replicate The issue described can't be replicated, and requires additional information

Comments

@legacy370
Copy link

legacy370 commented Feb 16, 2023

Configuration

  • Sorcery Version: 0.16.4
  • Ruby Version: 2.6.6
  • Framework: ruby on rails v 6.0
  • Platform: Ubuntu

Expected Behavior

Integration tests should work with the login method

Actual Behavior

All tests work under Rails 5.4.
Under Rails 6.0 , tests that inherit from ActionController::TestCase work just fine.
However, tests that inherit from ActionDispatch::IntegrationTest do not work. The result is Filter chain halted as :require_login rendered or redirected

Steps to Reproduce

  1. Here's a test example:
require 'test_helper'

class ImportAliyotTest < ActionDispatch::IntegrationTest
  include Sorcery::TestHelpers::Rails::Integration
  include Sorcery::TestHelpers::Rails::Controller

  setup do
    user = users(:one) 
    authenticate_user(user)
    @current_user = user
    @cutid = user.tenant.id    
  end

And here's the test_helper

require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require 'capybara/rails'

class ActiveSupport::TestCase
  include Sorcery::TestHelpers::Rails::Integration
  include Sorcery::TestHelpers::Rails::Controller
  # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
  fixtures :all
  Capybara.server = :puma # Until your setup is working
  Capybara.default_driver = :selenium_chrome


  # Add more helper methods to be used by all tests here...
  def login_user(user)
    # post the login and follow through
    post "/sessions", params: {
      email: user.email,
      password: user.password
    }
    puts user.inspect
    follow_redirect!
  end

  def authenticate_user(user = users(:one))
    post sessions_url, params: {
      email: user.email,
      password: "hac56wsn"
    }
    assert_equal session[:user_id].to_i, user.id
  end  
end
@willnet
Copy link
Member

willnet commented Jun 5, 2024

@legacy370 Based on the information provided, it seems difficult to identify the cause of the issue. Could you provide complete, unabridged code that reproduces the problem?

@willnet willnet added the can't replicate The issue described can't be replicated, and requires additional information label Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
can't replicate The issue described can't be replicated, and requires additional information
Projects
None yet
Development

No branches or pull requests

2 participants