Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xet7 committed Nov 2, 2024
1 parent 176b561 commit 7a34fc7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
2 changes: 2 additions & 0 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 18 additions & 4 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@
module AuthenticationHelpers
def sign_in_as(user)
post sign_in_url, params: { email: user.email, password: "Secret1*3*5*" }
follow_redirect! if response.redirect?
@current_user = user
end

def current_user
@current_user
end
end

module ActiveSupport
Expand All @@ -43,15 +48,20 @@ class TestCase

# Add more helper methods to be used by all tests here...
def sign_in_as(user)
if respond_to?(:post)
post(sign_in_url, params: { email: user.email, password: "Secret1*3*5*" })
else
if respond_to?(:session)
session[:user_id] = user.id
else
post sign_in_url, params: { email: user.email, password: "Secret1*3*5*" }
follow_redirect! if response.redirect?
end
user
@current_user = user
end

attr_reader :current_user

def teardown
super if defined?(super)
@current_user = nil
session[:user_id] = nil if respond_to?(:session)
end

Expand Down Expand Up @@ -82,6 +92,10 @@ class ActionDispatch::IntegrationTest
def setup
@current_user = nil
end

def teardown
@current_user = nil
end
end

Shoulda::Matchers.configure do |config|
Expand Down

0 comments on commit 7a34fc7

Please sign in to comment.