Add authentification helper to RSpec config
This commit is contained in:
parent
8b3b8352e5
commit
3744bf6858
|
|
@ -0,0 +1,8 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module AuthHelpers
|
||||
def apply_authentication_headers_for(user)
|
||||
user_headers = user.create_new_auth_token
|
||||
@request.headers.merge!(user_headers)
|
||||
end
|
||||
end
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
||||
require 'spec_helper'
|
||||
require 'auth_helpers'
|
||||
|
||||
ENV['RAILS_ENV'] ||= 'test'
|
||||
require File.expand_path('../config/environment', __dir__)
|
||||
# Prevent database truncation if the environment is production
|
||||
|
|
@ -61,6 +62,8 @@ RSpec.configure do |config|
|
|||
# arbitrary gems may also be filtered via:
|
||||
# config.filter_gems_from_backtrace("gem name")
|
||||
config.include FactoryBot::Syntax::Methods
|
||||
config.include Devise::Test::ControllerHelpers, type: :controller
|
||||
config.include AuthHelpers
|
||||
end
|
||||
|
||||
Shoulda::Matchers.configure do |config|
|
||||
|
|
|
|||
Loading…
Reference in New Issue