Initial commit - fresh start

This commit is contained in:
Ubuntu
2025-10-27 04:04:54 +00:00
parent a659275fb6
commit 52ab5d1005
265 changed files with 188424 additions and 64 deletions

View File

@@ -0,0 +1,15 @@
require 'rails_helper'
RSpec.describe Spree::HomeController, type: :controller do
describe 'GET #index' do
subject { get :index }
it 'returns a successful response' do
expect(subject).to be_successful
end
it 'renders the index template' do
expect(subject).to render_template(:index)
end
end
end

View File

@@ -0,0 +1,13 @@
require 'rails_helper'
RSpec.describe 'Home Page', type: :feature do
describe 'visiting the home page' do
before do
visit '/'
end
it 'loads successfully' do
expect(page.status_code).to eq(200)
end
end
end

View File

@@ -0,0 +1,8 @@
RSpec.describe Spree::Product, type: :model do
let(:store) { @default_store }
it 'creates a product' do
product = create(:product, stores: [store])
expect(product).to be_persisted
end
end

23
spec/rails_helper.rb Normal file
View File

@@ -0,0 +1,23 @@
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV['RAILS_ENV'] ||= 'test'
require 'spec_helper'
# Add additional requires below this line. Rails is not loaded until this point!
# Requires supporting ruby files with custom matchers and macros, etc, in
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
# run as spec files by default. This means that files in spec/support that end
# in _spec.rb will both be required and run as specs, causing the specs to be
# run twice. It is recommended that you do not name files matching this glob to
# end with _spec.rb. You can configure this pattern with the --pattern
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
#
# The following line is provided for convenience purposes. It has the downside
# of increasing the boot-up time by auto-requiring all files in the support
# directory. Alternatively, in the individual `*_spec.rb` files, manually
# require only the support files necessary.
#
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
# Checks for pending migrations before tests are run.
# If you are not using ActiveRecord, you can remove this line.
ActiveRecord::Migration.maintain_test_schema!

View File

@@ -0,0 +1,17 @@
require 'spec_helper'
describe 'API V2 Storefront Products Spec', type: :request do
let(:store) { @default_store }
let!(:products) { create_list(:product, 5, stores: [store]) }
describe 'products#index' do
context 'with no params' do
before { get '/api/v2/storefront/products' }
it 'returns all products' do
expect(json_response['data'].count).to eq store.products.available.count
expect(json_response['data'].first).to have_type('product')
end
end
end
end

28
spec/spec_helper.rb Normal file
View File

@@ -0,0 +1,28 @@
# This file was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The generated `.rspec` file contains `--require spec_helper` which will cause
# this file to always be loaded, without a need to explicitly require it in any
# files.
#
# Given that it is always loaded, you are encouraged to keep this file as
# light-weight as possible. Requiring heavyweight dependencies from this file
# will add to the boot time of your test suite on EVERY test run, even for an
# individual file that may not need all of that loaded. Instead, consider making
# a separate helper file that requires the additional dependencies and performs
# the additional setup, and require it from the spec files that actually need
# it.
#
# See https://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../config/environment', __dir__)
require 'dotenv/load'
require 'sidekiq/testing'
require 'spree_dev_tools/rspec/spec_helper'
require 'spree_stripe/factories'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].sort.each { |f| require f }

17
spec/support/devise.rb Normal file
View File

@@ -0,0 +1,17 @@
if defined?(Warden)
include Warden::Test::Helpers
Warden.test_mode!
end
if defined?(Devise)
RSpec.configure do |config|
config.include Devise::Test::ControllerHelpers, type: :controller
config.include Devise::Test::IntegrationHelpers, type: :feature
config.include Devise::Test::IntegrationHelpers, type: :request
config.include Warden::Test::Helpers
config.before :suite do
Warden.test_mode!
end
end
end

View File

@@ -0,0 +1,35 @@
module Spree
module TestingSupport
module AuthHelpers
def login_button
Spree.t(:login)
end
def logout_button
Spree.t(:logout)
end
def log_in(email:, password: nil, remember_me: true, locale: nil, checkout: false)
if checkout
visit "/checkout/#{order.token}"
find('a[href*="/user/sign_in"]').click
else
visit "/user/sign_in?locale=#{locale}"
end
fill_in 'user_email', with: email, wait: 5
fill_in 'user_password', with: password, wait: 5
click_button login_button
expect(page).to have_content 'Signed in successfully'
end
def log_out
visit '/account'
click_on logout_button
expect(page).to have_content 'Signed out successfully'
end
end
end
end