Skip to content

Commit

Permalink
Merge pull request #5678 from mamhoff/legacy-promotions-gem
Browse files Browse the repository at this point in the history
Add Legacy promotions gem
  • Loading branch information
kennyadsl authored Mar 6, 2024
2 parents 7d380c9 + 3222e60 commit cb4ec7b
Show file tree
Hide file tree
Showing 12 changed files with 216 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ commands:
- run:
name: "Run Sample Tests"
command: ./bin/build-ci sample
- run:
name: "Run Legacy Promotion Tests"
command: ./bin/build-ci legacy_promotions

- store_artifacts:
path: /tmp/test-artifacts
Expand Down
13 changes: 7 additions & 6 deletions bin/build-ci
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ class Project

def self.all
[
new('admin', weight: 215),
new('api', weight: 50),
new('backend', weight: 215),
new('backend', test_type: :teaspoon, title: "backend JS", weight: 15),
new('core', weight: 220),
new('sample', weight: 22)
new('admin', weight: 102),
new('api', weight: 69),
new('backend', weight: 282),
new('backend', test_type: :teaspoon, title: "backend JS", weight: 18),
new('core', weight: 266),
new('sample', weight: 28),
new('legacy_promotions', weight: 63)
]
end

Expand Down
1 change: 1 addition & 0 deletions bin/rspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ LIBS = %w[
backend
core
sample
legacy_promotions
]

# Ignore line info, e.g. foo/bar.rb:123 would become foo/bar.rb
Expand Down
42 changes: 42 additions & 0 deletions legacy_promotions/Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# frozen_string_literal: true

require 'rubygems'
require 'rake'
require 'rake/testtask'
require 'rspec/core/rake_task'
require 'spree/testing_support/dummy_app/rake_tasks'
require 'bundler/gem_tasks'

RSpec::Core::RakeTask.new
task default: :spec

DummyApp::RakeTasks.new(
gem_root: File.dirname(__FILE__),
lib_name: 'solidus_legacy_promotions'
)

require 'yard/rake/yardoc_task'
YARD::Rake::YardocTask.new(:yard)
# The following workaround can be removed
# once https://github.com/lsegal/yard/pull/1457 is merged.
task('yard:require') { require 'yard' }
task yard: 'yard:require'

namespace :spec do
task :isolated do
spec_files = Dir['spec/**/*_spec.rb']
failed_specs =
spec_files.reject do |file|
puts "rspec #{file}"
system('rspec', file)
end

if !failed_specs.empty?
puts "Failed specs:"
puts failed_specs
exit 1
end
end
end

task test_app: 'db:reset'
13 changes: 13 additions & 0 deletions legacy_promotions/bin/rails
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails gems
# installed from the root of your application.

ENGINE_ROOT = File.expand_path('..', __dir__)
ENGINE_PATH = File.expand_path('../lib/spree/core/engine', __dir__)

# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __dir__)
require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])

require "rails/all"
require "rails/engine/commands"
10 changes: 10 additions & 0 deletions legacy_promotions/lib/solidus_legacy_promotions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

require "solidus_core"
require "solidus_support"

module SolidusLegacyPromotions
VERSION = Spree.solidus_version
end

require "solidus_legacy_promotions/engine"
7 changes: 7 additions & 0 deletions legacy_promotions/lib/solidus_legacy_promotions/engine.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

module SolidusLegacyPromotions
class Engine < ::Rails::Engine
include SolidusSupport::EngineExtensions
end
end
28 changes: 28 additions & 0 deletions legacy_promotions/solidus_legacy_promotions.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# frozen_string_literal: true

require_relative '../core/lib/spree/core/version'

Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = 'solidus_legacy_promotions'
s.version = Spree.solidus_version
s.summary = 'Legacy Solidus promotion system'
s.description = s.summary

s.author = 'Solidus Team'
s.email = 'contact@solidus.io'
s.homepage = 'http://solidus.io'
s.license = 'BSD-3-Clause'

s.metadata['rubygems_mfa_required'] = 'true'

s.files = `git ls-files -z`.split("\x0").reject do |f|
f.match(%r{^(spec|script)/})
end

s.required_ruby_version = '>= 3.0.0'
s.required_rubygems_version = '>= 1.8.23'

s.add_dependency 'solidus_core', s.version
s.add_dependency 'solidus_support'
end
9 changes: 9 additions & 0 deletions legacy_promotions/spec/lib/solidus_legacy_promotions_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

require "spec_helper"

RSpec.describe SolidusLegacyPromotions do
it "has a version number" do
expect(SolidusLegacyPromotions::VERSION).not_to be nil
end
end
51 changes: 51 additions & 0 deletions legacy_promotions/spec/rails_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# frozen_string_literal: true

require 'spec_helper'

ENV["RAILS_ENV"] ||= 'test'

require 'spree/testing_support/dummy_app'
DummyApp.setup(
gem_root: File.expand_path('..', __dir__),
lib_name: 'solidus_legacy_promotions'
)

require 'rspec/rails'
require 'rspec-activemodel-mocks'
require 'database_cleaner'

Dir["./spec/support/**/*.rb"].sort.each { |f| require f }

require 'spree/testing_support/factory_bot'
require 'spree/testing_support/preferences'
require 'spree/testing_support/rake'
require 'spree/testing_support/job_helpers'
require 'cancan/matchers'

ActiveJob::Base.queue_adapter = :test

Spree::TestingSupport::FactoryBot.add_paths_and_load!

RSpec.configure do |config|
config.fixture_path = File.join(__dir__, "fixtures")

config.infer_spec_type_from_file_location!

# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, comment the following line or assign false
# instead of true.
config.use_transactional_fixtures = true

config.before :suite do
FileUtils.rm_rf(Rails.configuration.active_storage.service_configurations[:test][:root]) unless ENV['DISABLE_ACTIVE_STORAGE'] == 'true'
DatabaseCleaner.clean_with :truncation
end

config.before :each do
Rails.cache.clear
end

config.include Spree::TestingSupport::JobHelpers

config.include FactoryBot::Syntax::Methods
end
44 changes: 44 additions & 0 deletions legacy_promotions/spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# frozen_string_literal: true

if ENV["COVERAGE"]
require 'simplecov'
if ENV["COVERAGE_DIR"]
SimpleCov.coverage_dir(ENV["COVERAGE_DIR"])
end
SimpleCov.command_name('solidus:core')
SimpleCov.merge_timeout(3600)
SimpleCov.start('rails')
end

require 'rspec/core'

require 'spree/testing_support/flaky'
require 'spree/testing_support/partial_double_verification'
require 'spree/testing_support/silence_deprecations'
require 'spree/testing_support/preferences'
require 'spree/deprecator'
require 'spree/config'

require "solidus_legacy_promotions"

RSpec.configure do |config|
config.disable_monkey_patching!
config.color = true
config.expect_with :rspec do |c|
c.syntax = :expect
end
config.mock_with :rspec do |c|
c.syntax = :expect
end

config.include Spree::TestingSupport::Preferences

config.filter_run focus: true
config.run_all_when_everything_filtered = true

config.example_status_persistence_file_path = "./spec/examples.txt"

config.order = :random

Kernel.srand config.seed
end
1 change: 1 addition & 0 deletions solidus.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ Gem::Specification.new do |s|
s.add_dependency 'solidus_backend', s.version
s.add_dependency 'solidus_core', s.version
s.add_dependency 'solidus_sample', s.version
s.add_dependency 'solidus_legacy_promotions', s.version
end

0 comments on commit cb4ec7b

Please sign in to comment.