diff --git a/friendly_promotions/.circleci/config.yml b/friendly_promotions/.circleci/config.yml new file mode 100644 index 00000000000..28d70ebd500 --- /dev/null +++ b/friendly_promotions/.circleci/config.yml @@ -0,0 +1,53 @@ +version: 2.1 + +orbs: + # Required for feature specs. + browser-tools: circleci/browser-tools@1.1 + + # Always take the latest version of the orb, this allows us to + # run specs against Solidus supported versions only without the need + # to change this configuration every time a Solidus version is released + # or goes EOL. + solidusio_extensions: solidusio/extensions@volatile + +jobs: + run-specs-with-sqlite: + executor: solidusio_extensions/sqlite + steps: + - browser-tools/install-chrome + - solidusio_extensions/run-tests + run-specs-with-postgres: + executor: solidusio_extensions/postgres + steps: + - browser-tools/install-chrome + - solidusio_extensions/run-tests + run-specs-with-mysql: + executor: solidusio_extensions/mysql + steps: + - browser-tools/install-chrome + - solidusio_extensions/run-tests + lint-code: + executor: solidusio_extensions/sqlite-memory + steps: + - solidusio_extensions/lint-code + +workflows: + "Run specs on supported Solidus versions": + jobs: + - run-specs-with-sqlite + - run-specs-with-postgres + - run-specs-with-mysql + - lint-code + + "Weekly run specs against master": + triggers: + - schedule: + cron: "0 0 * * 4" # every Thursday + filters: + branches: + only: + - master + jobs: + - run-specs-with-sqlite + - run-specs-with-postgres + - run-specs-with-mysql diff --git a/friendly_promotions/.gem_release.yml b/friendly_promotions/.gem_release.yml new file mode 100644 index 00000000000..8c2591b0dba --- /dev/null +++ b/friendly_promotions/.gem_release.yml @@ -0,0 +1,5 @@ +bump: + recurse: false + file: 'lib/solidus_friendly_promotions/version.rb' + message: Bump SolidusFriendlyPromotions to %{version} + tag: true diff --git a/friendly_promotions/.github/stale.yml b/friendly_promotions/.github/stale.yml new file mode 100644 index 00000000000..0d0b1c994dd --- /dev/null +++ b/friendly_promotions/.github/stale.yml @@ -0,0 +1 @@ +_extends: .github diff --git a/friendly_promotions/.github_changelog_generator b/friendly_promotions/.github_changelog_generator new file mode 100644 index 00000000000..eac0962107b --- /dev/null +++ b/friendly_promotions/.github_changelog_generator @@ -0,0 +1,2 @@ +issues=false +exclude-labels=infrastructure diff --git a/friendly_promotions/.gitignore b/friendly_promotions/.gitignore new file mode 100644 index 00000000000..1ba20966542 --- /dev/null +++ b/friendly_promotions/.gitignore @@ -0,0 +1,21 @@ +*.gem +\#* +*~ +.#* +.DS_Store +.idea +.project +.sass-cache +coverage +Gemfile.lock +Gemfile-local +tmp +nbproject +pkg +*.swp +spec/dummy +spec/examples.txt +/sandbox +.rvmrc +.ruby-version +.ruby-gemset diff --git a/friendly_promotions/.rspec b/friendly_promotions/.rspec new file mode 100644 index 00000000000..83e16f80447 --- /dev/null +++ b/friendly_promotions/.rspec @@ -0,0 +1,2 @@ +--color +--require spec_helper diff --git a/friendly_promotions/.rubocop.yml b/friendly_promotions/.rubocop.yml new file mode 100644 index 00000000000..b075a8f6826 --- /dev/null +++ b/friendly_promotions/.rubocop.yml @@ -0,0 +1,5 @@ +require: + - solidus_dev_support/rubocop + +AllCops: + NewCops: disable diff --git a/friendly_promotions/CHANGELOG.md b/friendly_promotions/CHANGELOG.md new file mode 100644 index 00000000000..825c32f0d03 --- /dev/null +++ b/friendly_promotions/CHANGELOG.md @@ -0,0 +1 @@ +# Changelog diff --git a/friendly_promotions/Gemfile b/friendly_promotions/Gemfile new file mode 100644 index 00000000000..2f2a55c68e6 --- /dev/null +++ b/friendly_promotions/Gemfile @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +source 'https://rubygems.org' +git_source(:github) { |repo| "https://github.com/#{repo}.git" } + +branch = ENV.fetch('SOLIDUS_BRANCH', 'master') +gem 'solidus', github: 'solidusio/solidus', branch: branch + +# The solidus_frontend gem has been pulled out since v3.2 +gem 'solidus_frontend', github: 'solidusio/solidus_frontend' if branch == 'master' +gem 'solidus_frontend' if branch >= 'v3.2' # rubocop:disable Bundler/DuplicatedGem + +# Needed to help Bundler figure out how to resolve dependencies, +# otherwise it takes forever to resolve them. +# See https://github.com/bundler/bundler/issues/6677 +gem 'rails', '>0.a' + + +# Provides basic authentication functionality for testing parts of your engine +gem 'solidus_auth_devise' + +case ENV.fetch('DB', nil) +when 'mysql' + gem 'mysql2' +when 'postgresql' + gem 'pg' +else + gem 'sqlite3' +end + +# While we still support Ruby < 3 we need to workaround a limitation in +# the 'async' gem that relies on the latest ruby, since RubyGems doesn't +# resolve gems based on the required ruby version. +gem 'async', '< 3' if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3') + +gemspec + +# Use a local Gemfile to include development dependencies that might not be +# relevant for the project or for other contributors, e.g. pry-byebug. +# +# We use `send` instead of calling `eval_gemfile` to work around an issue with +# how Dependabot parses projects: https://github.com/dependabot/dependabot-core/issues/1658. +send(:eval_gemfile, 'Gemfile-local') if File.exist? 'Gemfile-local' diff --git a/friendly_promotions/LICENSE b/friendly_promotions/LICENSE new file mode 100644 index 00000000000..375c0dd192b --- /dev/null +++ b/friendly_promotions/LICENSE @@ -0,0 +1,26 @@ +Copyright (c) 2023 Martin Meyerhoff +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name Solidus nor the names of its contributors may be used to + endorse or promote products derived from this software without specific + prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/friendly_promotions/README.md b/friendly_promotions/README.md new file mode 100644 index 00000000000..950e71818ea --- /dev/null +++ b/friendly_promotions/README.md @@ -0,0 +1,73 @@ +# Solidus Friendly Promotions + +[![CircleCI](https://circleci.com/gh/solidusio-contrib/solidus_friendly_promotions.svg?style=shield)](https://circleci.com/gh/solidusio-contrib/solidus_friendly_promotions) +[![codecov](https://codecov.io/gh/solidusio-contrib/solidus_friendly_promotions/branch/master/graph/badge.svg)](https://codecov.io/gh/solidusio-contrib/solidus_friendly_promotions) + + + +## Installation + +Add solidus_friendly_promotions to your Gemfile: + +```ruby +gem 'solidus_friendly_promotions' +``` + +Bundle your dependencies and run the installation generator: + +```shell +bin/rails generate solidus_friendly_promotions:install +``` + +## Usage + + + +## Development + +### Testing the extension + +First bundle your dependencies, then run `bin/rake`. `bin/rake` will default to building the dummy +app if it does not exist, then it will run specs. The dummy app can be regenerated by using +`bin/rake extension:test_app`. + +```shell +bin/rake +``` + +To run [Rubocop](https://github.com/bbatsov/rubocop) static code analysis run + +```shell +bundle exec rubocop +``` + +When testing your application's integration with this extension you may use its factories. +You can load Solidus core factories along with this extension's factories using this statement: + +```ruby +SolidusDevSupport::TestingSupport::Factories.load_for(SolidusFriendlyPromotions::Engine) +``` + +### Running the sandbox + +To run this extension in a sandboxed Solidus application, you can run `bin/sandbox`. The path for +the sandbox app is `./sandbox` and `bin/rails` will forward any Rails commands to +`sandbox/bin/rails`. + +Here's an example: + +``` +$ bin/rails server +=> Booting Puma +=> Rails 6.0.2.1 application starting in development +* Listening on tcp://127.0.0.1:3000 +Use Ctrl-C to stop +``` + +### Releasing new versions + +Please refer to the [dedicated page](https://github.com/solidusio/solidus/wiki/How-to-release-extensions) in the Solidus wiki. + +## License + +Copyright (c) 2023 Martin Meyerhoff, released under the New BSD License. diff --git a/friendly_promotions/Rakefile b/friendly_promotions/Rakefile new file mode 100644 index 00000000000..c08aa46816c --- /dev/null +++ b/friendly_promotions/Rakefile @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +require 'solidus_dev_support/rake_tasks' +SolidusDevSupport::RakeTasks.install + +task default: 'extension:specs' diff --git a/friendly_promotions/app/assets/javascripts/spree/backend/solidus_friendly_promotions.js b/friendly_promotions/app/assets/javascripts/spree/backend/solidus_friendly_promotions.js new file mode 100644 index 00000000000..8aa3b014409 --- /dev/null +++ b/friendly_promotions/app/assets/javascripts/spree/backend/solidus_friendly_promotions.js @@ -0,0 +1,2 @@ +// Placeholder manifest file. +// the installer will append this file to the app vendored assets here: vendor/assets/javascripts/spree/backend/all.js' \ No newline at end of file diff --git a/friendly_promotions/app/assets/javascripts/spree/frontend/solidus_friendly_promotions.js b/friendly_promotions/app/assets/javascripts/spree/frontend/solidus_friendly_promotions.js new file mode 100644 index 00000000000..a79f2e948dd --- /dev/null +++ b/friendly_promotions/app/assets/javascripts/spree/frontend/solidus_friendly_promotions.js @@ -0,0 +1,2 @@ +// Placeholder manifest file. +// the installer will append this file to the app vendored assets here: vendor/assets/javascripts/spree/frontend/all.js' \ No newline at end of file diff --git a/friendly_promotions/app/assets/stylesheets/spree/backend/solidus_friendly_promotions.css b/friendly_promotions/app/assets/stylesheets/spree/backend/solidus_friendly_promotions.css new file mode 100644 index 00000000000..e3c236629e3 --- /dev/null +++ b/friendly_promotions/app/assets/stylesheets/spree/backend/solidus_friendly_promotions.css @@ -0,0 +1,4 @@ +/* +Placeholder manifest file. +the installer will append this file to the app vendored assets here: 'vendor/assets/stylesheets/spree/backend/all.css' +*/ diff --git a/friendly_promotions/app/assets/stylesheets/spree/frontend/solidus_friendly_promotions.css b/friendly_promotions/app/assets/stylesheets/spree/frontend/solidus_friendly_promotions.css new file mode 100644 index 00000000000..da236237c52 --- /dev/null +++ b/friendly_promotions/app/assets/stylesheets/spree/frontend/solidus_friendly_promotions.css @@ -0,0 +1,4 @@ +/* +Placeholder manifest file. +the installer will append this file to the app vendored assets here: 'vendor/assets/stylesheets/spree/frontend/all.css' +*/ diff --git a/friendly_promotions/bin/console b/friendly_promotions/bin/console new file mode 100755 index 00000000000..5170bfc2daa --- /dev/null +++ b/friendly_promotions/bin/console @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby + +# frozen_string_literal: true + +require "bundler/setup" +require "solidus_friendly_promotions" + +# You can add fixtures and/or initialization code here to make experimenting +# with your gem easier. You can also use a different console, if you like. +$LOAD_PATH.unshift(*Dir["#{__dir__}/../app/*"]) + +# (If you use this, don't forget to add pry to your Gemfile!) +# require "pry" +# Pry.start + +require "irb" +IRB.start(__FILE__) diff --git a/friendly_promotions/bin/rails b/friendly_promotions/bin/rails new file mode 100755 index 00000000000..6dbbbc36e77 --- /dev/null +++ b/friendly_promotions/bin/rails @@ -0,0 +1,7 @@ +#!/usr/bin/env ruby + +if %w[g generate].include? ARGV.first + exec "#{__dir__}/rails-engine", *ARGV +else + exec "#{__dir__}/rails-sandbox", *ARGV +end diff --git a/friendly_promotions/bin/rails-engine b/friendly_promotions/bin/rails-engine new file mode 100755 index 00000000000..00cd82aeace --- /dev/null +++ b/friendly_promotions/bin/rails-engine @@ -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/solidus_friendly_promotions/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' diff --git a/friendly_promotions/bin/rails-sandbox b/friendly_promotions/bin/rails-sandbox new file mode 100755 index 00000000000..ad2df04d0e7 --- /dev/null +++ b/friendly_promotions/bin/rails-sandbox @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby + +app_root = 'sandbox' + +unless File.exist? "#{app_root}/bin/rails" + warn 'Creating the sandbox app...' + Dir.chdir "#{__dir__}/.." do + system "#{__dir__}/sandbox" or begin + warn 'Automatic creation of the sandbox app failed' + exit 1 + end + end +end + +Dir.chdir app_root +exec 'bin/rails', *ARGV diff --git a/friendly_promotions/bin/rake b/friendly_promotions/bin/rake new file mode 100755 index 00000000000..1e6eacd34e8 --- /dev/null +++ b/friendly_promotions/bin/rake @@ -0,0 +1,7 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("rake", "rake") diff --git a/friendly_promotions/bin/sandbox b/friendly_promotions/bin/sandbox new file mode 100755 index 00000000000..bf577b65c23 --- /dev/null +++ b/friendly_promotions/bin/sandbox @@ -0,0 +1,78 @@ +#!/usr/bin/env bash + +set -e +test -z "${DEBUG+empty_string}" || set -x + +test "$DB" = "sqlite" && export DB="sqlite3" + +if [ -z "$SOLIDUS_BRANCH" ] +then + echo "~~> Use 'export SOLIDUS_BRANCH=[master|v3.2|...]' to control the Solidus branch" + SOLIDUS_BRANCH="master" +fi +echo "~~> Using branch $SOLIDUS_BRANCH of solidus" + +if [ -z "$SOLIDUS_FRONTEND" ] +then + echo "~~> Use 'export SOLIDUS_FRONTEND=[solidus_frontend|solidus_starter_frontend]' to control the Solidus frontend" + SOLIDUS_FRONTEND="solidus_frontend" +fi +echo "~~> Using branch $SOLIDUS_FRONTEND as the solidus frontend" + +extension_name="solidus_friendly_promotions" + +# Stay away from the bundler env of the containing extension. +function unbundled { + ruby -rbundler -e'b = proc {system *ARGV}; Bundler.respond_to?(:with_unbundled_env) ? Bundler.with_unbundled_env(&b) : Bundler.with_clean_env(&b)' -- $@ +} + +rm -rf ./sandbox +unbundled bundle exec rails new sandbox \ + --database="${DB:-sqlite3}" \ + --skip-bundle \ + --skip-git \ + --skip-keeps \ + --skip-rc \ + --skip-spring \ + --skip-test \ + --skip-javascript + +if [ ! -d "sandbox" ]; then + echo 'sandbox rails application failed' + exit 1 +fi + +cd ./sandbox +cat <> Gemfile +gem 'solidus', github: 'solidusio/solidus', branch: '$SOLIDUS_BRANCH' +gem 'rails-i18n' +gem 'solidus_i18n' + +gem '$extension_name', path: '..' + +group :test, :development do + platforms :mri do + gem 'pry-byebug' + end +end +RUBY + +unbundled bundle install --gemfile Gemfile + +unbundled bundle exec rake db:drop db:create + +unbundled bundle exec rails generate solidus:install \ + --auto-accept \ + --user_class=Spree::User \ + --enforce_available_locales=true \ + --with-authentication=true \ + --payment-method=none \ + --frontend=${SOLIDUS_FRONTEND} \ + $@ + +unbundled bundle exec rails generate solidus:auth:install --auto-run-migrations +unbundled bundle exec rails generate ${extension_name}:install --auto-run-migrations + +echo +echo "๐Ÿš€ Sandbox app successfully created for $extension_name!" +echo "๐Ÿงช This app is intended for test purposes." diff --git a/friendly_promotions/bin/setup b/friendly_promotions/bin/setup new file mode 100755 index 00000000000..67d919320aa --- /dev/null +++ b/friendly_promotions/bin/setup @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +set -euo pipefail +IFS=$'\n\t' +set -vx + +gem install bundler --conservative +bundle update +bin/rake clobber diff --git a/friendly_promotions/config/locales/en.yml b/friendly_promotions/config/locales/en.yml new file mode 100644 index 00000000000..f341cf450bc --- /dev/null +++ b/friendly_promotions/config/locales/en.yml @@ -0,0 +1,5 @@ +# Sample localization file for English. Add more files in this directory for other locales. +# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. + +en: + hello: Hello world diff --git a/friendly_promotions/config/routes.rb b/friendly_promotions/config/routes.rb new file mode 100644 index 00000000000..59d02443fbd --- /dev/null +++ b/friendly_promotions/config/routes.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +Spree::Core::Engine.routes.draw do + # Add your extension routes here +end diff --git a/friendly_promotions/lib/generators/solidus_friendly_promotions/install/install_generator.rb b/friendly_promotions/lib/generators/solidus_friendly_promotions/install/install_generator.rb new file mode 100644 index 00000000000..31ac0a7c3d7 --- /dev/null +++ b/friendly_promotions/lib/generators/solidus_friendly_promotions/install/install_generator.rb @@ -0,0 +1,41 @@ +# frozen_string_literal: true + +module SolidusFriendlyPromotions + module Generators + class InstallGenerator < Rails::Generators::Base + class_option :auto_run_migrations, type: :boolean, default: false + source_root File.expand_path('templates', __dir__) + + def self.exit_on_failure? + true + end + + def copy_initializer + template 'initializer.rb', 'config/initializers/solidus_friendly_promotions.rb' + end + + def add_javascripts + append_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require spree/frontend/solidus_friendly_promotions\n" + append_file 'vendor/assets/javascripts/spree/backend/all.js', "//= require spree/backend/solidus_friendly_promotions\n" + end + + def add_stylesheets + inject_into_file 'vendor/assets/stylesheets/spree/frontend/all.css', " *= require spree/frontend/solidus_friendly_promotions\n", before: %r{\*/}, verbose: true # rubocop:disable Layout/LineLength + inject_into_file 'vendor/assets/stylesheets/spree/backend/all.css', " *= require spree/backend/solidus_friendly_promotions\n", before: %r{\*/}, verbose: true # rubocop:disable Layout/LineLength + end + + def add_migrations + run 'bin/rails railties:install:migrations FROM=solidus_friendly_promotions' + end + + def run_migrations + run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]')) # rubocop:disable Layout/LineLength + if run_migrations + run 'bin/rails db:migrate' + else + puts 'Skipping bin/rails db:migrate, don\'t forget to run it!' # rubocop:disable Rails/Output + end + end + end + end +end diff --git a/friendly_promotions/lib/generators/solidus_friendly_promotions/install/templates/initializer.rb b/friendly_promotions/lib/generators/solidus_friendly_promotions/install/templates/initializer.rb new file mode 100644 index 00000000000..79e8c8e6990 --- /dev/null +++ b/friendly_promotions/lib/generators/solidus_friendly_promotions/install/templates/initializer.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +SolidusFriendlyPromotions.configure do |config| + # TODO: Remember to change this with the actual preferences you have implemented! + # config.sample_preference = 'sample_value' +end diff --git a/friendly_promotions/lib/solidus_friendly_promotions.rb b/friendly_promotions/lib/solidus_friendly_promotions.rb new file mode 100644 index 00000000000..5ae3dc6fcc7 --- /dev/null +++ b/friendly_promotions/lib/solidus_friendly_promotions.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +require 'solidus_friendly_promotions/configuration' +require 'solidus_friendly_promotions/version' +require 'solidus_friendly_promotions/engine' diff --git a/friendly_promotions/lib/solidus_friendly_promotions/configuration.rb b/friendly_promotions/lib/solidus_friendly_promotions/configuration.rb new file mode 100644 index 00000000000..d00757a289a --- /dev/null +++ b/friendly_promotions/lib/solidus_friendly_promotions/configuration.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +module SolidusFriendlyPromotions + class Configuration + # Define here the settings for this extension, e.g.: + # + # attr_accessor :my_setting + end + + class << self + def configuration + @configuration ||= Configuration.new + end + + alias config configuration + + def configure + yield configuration + end + end +end diff --git a/friendly_promotions/lib/solidus_friendly_promotions/engine.rb b/friendly_promotions/lib/solidus_friendly_promotions/engine.rb new file mode 100644 index 00000000000..1cf24dc3e2c --- /dev/null +++ b/friendly_promotions/lib/solidus_friendly_promotions/engine.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +require 'solidus_core' +require 'solidus_support' + +module SolidusFriendlyPromotions + class Engine < Rails::Engine + include SolidusSupport::EngineExtensions + + isolate_namespace ::Spree + + engine_name 'solidus_friendly_promotions' + + # use rspec for tests + config.generators do |g| + g.test_framework :rspec + end + end +end diff --git a/friendly_promotions/lib/solidus_friendly_promotions/testing_support/factories.rb b/friendly_promotions/lib/solidus_friendly_promotions/testing_support/factories.rb new file mode 100644 index 00000000000..745a01e4c27 --- /dev/null +++ b/friendly_promotions/lib/solidus_friendly_promotions/testing_support/factories.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true + +FactoryBot.define do +end diff --git a/friendly_promotions/lib/solidus_friendly_promotions/version.rb b/friendly_promotions/lib/solidus_friendly_promotions/version.rb new file mode 100644 index 00000000000..eb53a9e9496 --- /dev/null +++ b/friendly_promotions/lib/solidus_friendly_promotions/version.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +module SolidusFriendlyPromotions + VERSION = '0.0.1' +end diff --git a/friendly_promotions/solidus_friendly_promotions.gemspec b/friendly_promotions/solidus_friendly_promotions.gemspec new file mode 100644 index 00000000000..b26ed10cbb0 --- /dev/null +++ b/friendly_promotions/solidus_friendly_promotions.gemspec @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +require_relative 'lib/solidus_friendly_promotions/version' + +Gem::Specification.new do |spec| + spec.name = 'solidus_friendly_promotions' + spec.version = SolidusFriendlyPromotions::VERSION + spec.authors = ['Martin Meyerhoff'] + spec.email = 'mamhoff@gmail.com' + + spec.summary = 'A replacement for Solidus\' promotion system' + spec.description = 'Experimental replacement for the promotion system in Solidus' + spec.homepage = 'https://github.com/solidusio-contrib/solidus_friendly_promotions#readme' + spec.license = 'BSD-3-Clause' + + spec.metadata['homepage_uri'] = spec.homepage + spec.metadata['source_code_uri'] = 'https://github.com/solidusio-contrib/solidus_friendly_promotions' + spec.metadata['changelog_uri'] = 'https://github.com/solidusio-contrib/solidus_friendly_promotions/blob/master/CHANGELOG.md' + + spec.required_ruby_version = Gem::Requirement.new('>= 2.5', '< 4') + + # Specify which files should be added to the gem when it is released. + # The `git ls-files -z` loads the files in the RubyGem that have been added into git. + files = Dir.chdir(__dir__) { `git ls-files -z`.split("\x0") } + + spec.files = files.grep_v(%r{^(test|spec|features)/}) + spec.test_files = files.grep(%r{^(test|spec|features)/}) + spec.bindir = "exe" + spec.executables = files.grep(%r{^exe/}) { |f| File.basename(f) } + spec.require_paths = ["lib"] + + spec.add_dependency 'solidus_core', ['>= 3.0.0', '< 5'] + spec.add_dependency 'solidus_support', '~> 0.5' + + spec.add_development_dependency 'solidus_dev_support', '~> 2.6' +end diff --git a/friendly_promotions/spec/spec_helper.rb b/friendly_promotions/spec/spec_helper.rb new file mode 100644 index 00000000000..62c1bab47b0 --- /dev/null +++ b/friendly_promotions/spec/spec_helper.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +# Configure Rails Environment +ENV['RAILS_ENV'] = 'test' + +# Run Coverage report +require 'solidus_dev_support/rspec/coverage' + +# Create the dummy app if it's still missing. +dummy_env = "#{__dir__}/dummy/config/environment.rb" +system 'bin/rake extension:test_app' unless File.exist? dummy_env +require dummy_env + +# Requires factories and other useful helpers defined in spree_core. +require 'solidus_dev_support/rspec/feature_helper' + +# Requires supporting ruby files with custom matchers and macros, etc, +# in spec/support/ and its subdirectories. +Dir["#{__dir__}/support/**/*.rb"].sort.each { |f| require f } + +# Requires factories defined in Solidus core and this extension. +# See: lib/solidus_friendly_promotions/testing_support/factories.rb +SolidusDevSupport::TestingSupport::Factories.load_for(SolidusFriendlyPromotions::Engine) + +RSpec.configure do |config| + config.infer_spec_type_from_file_location! + config.use_transactional_fixtures = false + + if Spree.solidus_gem_version < Gem::Version.new('2.11') + config.extend Spree::TestingSupport::AuthorizationHelpers::Request, type: :system + end +end