I attempted to use the pipeline feature and it appears to be functioning properly. However, I encountered an issue with my RSpec tests that I was unable to resolve. Specifically, all of my request tests failed.
It's particularly strange because it works perfectly fine on my local environment. The following aspects are functioning correctly: DB, Redis, migration, test running, and model tests.
Unfortunately, the API request tests are not working as expected. Returns a 401 error.
Gemfile
# frozen_string_literal: true
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '3.0.5'
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem 'rails', '~> 7.0.4', '>= 7.0.4.2'
# Use mysql as the database for Active Record
gem 'mysql2', '~> 0.5'
# Use the Puma web server [https://github.com/puma/puma]
gem 'puma', '~> 5.0'
# Build JSON APIs with ease [https://github.com/rails/jbuilder]
gem 'jbuilder'
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', require: false
# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
gem 'image_processing', '~> 1.2'
gem 'devise'
gem 'devise-jwt'
# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
gem 'rack-cors'
group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem 'debug', platforms: %i[mri mingw x64_mingw]
gem 'dotenv-rails'
gem 'rspec-rails', '~> 6.0.0'
end
gem 'rubocop-rails', require: false
group :test do
gem 'shoulda', '~> 4.0'
end
group :development do
# Speed up commands on slow machines / big apps [https://github.com/rails/spring]
# gem "spring"
end
gem 'factory_bot', '~> 6.2'
gem 'pundit', '~> 2.3'
gem 'friendly_id', '~> 5.5'
gem 'aws-sdk-s3', require: false
gem 'acts_as_paranoid', '~> 0.8.1'
gem 'acts_as_list', '~> 1.1'
gem 'activestorage-validator', '~> 0.2.2'
gem 'state_machines', '~> 0.5.0'
gem 'sidekiq', '~> 7.0'
gem 'kaminari', '~> 1.2'
gem 'paranoia', '~> 2.6'
Test Example Results:
<span>/core/ecommerces POST /create with valid parameters renders a JSON response with the new core_ecommerce</span>
Failure/Error: expect(response).to have_http_status(:created)
<span>expected the response to have status code :created (201) but it was :unauthorized (401)</span>
<span>./spec/requests/core/ecommerces_spec.rb:84:in `block (4 levels) in <main>'</span>