diff --git a/.circleci/config.yml b/.circleci/config.yml index a431245..12bb10e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,7 +1,7 @@ version: 2.1 orbs: - # Always take the latest version of the Orb, this allows us to + # 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. diff --git a/.gem_release.yml b/.gem_release.yml new file mode 100644 index 0000000..92b2a12 --- /dev/null +++ b/.gem_release.yml @@ -0,0 +1,5 @@ +bump: + recurse: false + file: 'lib/solidus_static_content/version.rb' + message: Bump SolidusStaticContent to %{version} + branch: true diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 0000000..d9f6563 --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,17 @@ +# Number of days of inactivity before an issue becomes stale +daysUntilStale: 60 +# Number of days of inactivity before a stale issue is closed +daysUntilClose: 7 +# Issues with these labels will never be considered stale +exemptLabels: + - pinned + - security +# Label to use when marking an issue as stale +staleLabel: wontfix +# Comment to post when marking an issue as stale. Set to `false` to disable +markComment: > + This issue has been automatically marked as stale because it has not had + recent activity. It will be closed if no further activity occurs. Thank you + for your contributions. +# Comment to post when closing a stale issue. Set to `false` to disable +closeComment: false \ No newline at end of file diff --git a/.gitignore b/.gitignore index b2ec583..bcd4aea 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,16 @@ +*.gem +\#* +*~ +.#* .DS_Store -nbproject -**.gem +.idea +.project +.sass-cache +coverage Gemfile.lock -spec/dummy/ -.rvmrc tmp -coverage -.bundle +nbproject +pkg +*.swp +spec/dummy +spec/examples.txt diff --git a/.rspec b/.rspec index 84d5793..5052887 100644 --- a/.rspec +++ b/.rspec @@ -1,3 +1 @@ ---colour ---format -progress +--color \ No newline at end of file diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..b0893d3 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,14 @@ +require: + - solidus_dev_support/rubocop + +inherit_gem: + solidus_dev_support: .rubocop.yml + +AllCops: + Exclude: + - spec/dummy/**/* + - vendor/**/* + +Rails/SkipsModelValidations: + Exclude: + - db/migrate/**/* diff --git a/Gemfile b/Gemfile index ac23bbc..28e8aa9 100644 --- a/Gemfile +++ b/Gemfile @@ -1,8 +1,26 @@ -source 'https://rubygems.org/' +# frozen_string_literal: true -gemspec +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 -gem "rails-controller-testing", group: :test +# 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['DB'] +when 'mysql' + gem 'mysql2' +when 'postgresql' + gem 'pg' +else + gem 'sqlite3' +end + +gemspec diff --git a/LICENSE.txt b/LICENSE similarity index 100% rename from LICENSE.txt rename to LICENSE diff --git a/Rakefile b/Rakefile index 61615f4..c08aa46 100644 --- a/Rakefile +++ b/Rakefile @@ -1,29 +1,6 @@ -require 'rake/clean' -require 'bundler/gem_tasks' -require 'rspec/core/rake_task' -require 'spree/testing_support/extension_rake' +# frozen_string_literal: true -test_app_path = 'spec/dummy' +require 'solidus_dev_support/rake_tasks' +SolidusDevSupport::RakeTasks.install -CLOBBER.include test_app_path - -desc 'Generates a dummy app for testing' -directory test_app_path do - ENV['LIB_NAME'] = 'solidus_static_content' - Rake::Task['extension:test_app'].invoke - - # We need to go back to the gem root since extension:test_app changes - # the working directory to be the dummy app. - cd __dir__ -end - -RSpec::Core::RakeTask.new(:specs, [] => FileList[test_app_path]) do |t| - # Ref: https://circleci.com/docs/2.0/configuration-reference/#store_test_results - if ENV['TEST_RESULTS_PATH'] - t.rspec_opts = - "--format progress " \ - "--format RspecJunitFormatter --out #{ENV['TEST_RESULTS_PATH']}" - end -end - -task :default => :specs +task default: 'extension:specs' diff --git a/bin/console b/bin/console index 91ee17d..5965307 100755 --- a/bin/console +++ b/bin/console @@ -1,11 +1,13 @@ #!/usr/bin/env ruby +# frozen_string_literal: true + require "bundler/setup" require "solidus_static_content" # 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/*"] +$LOAD_PATH.unshift(*Dir["#{__dir__}/../app/*"]) # (If you use this, don't forget to add pry to your Gemfile!) # require "pry" diff --git a/bin/rails b/bin/rails index 1334f1f..c535fd2 100755 --- a/bin/rails +++ b/bin/rails @@ -1,11 +1,15 @@ #!/usr/bin/env ruby -unless File.exist? 'spec/dummy/bin/rails' - system "bin/rake", "spec/dummy" or begin +# frozen_string_literal: true + +app_root = 'spec/dummy' + +unless File.exist? "#{app_root}/bin/rails" + system "bin/rake", app_root or begin # rubocop:disable Style/AndOr warn "Automatic creation of the dummy app failed" exit 1 end end -Dir.chdir 'spec/dummy' +Dir.chdir app_root exec 'bin/rails', *ARGV diff --git a/bin/setup b/bin/setup index e97c371..c3563af 100755 --- a/bin/setup +++ b/bin/setup @@ -5,6 +5,4 @@ set -vx gem install bundler --conservative bundle update -bin/rake clobber -bin/rake spec/dummy -bin/rails railties:install:migrations db:migrate db:seed +bundle exec rake extension:test_app diff --git a/config/routes.rb b/config/routes.rb index 1940f1e..45dd40a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Spree::Core::Engine.routes.draw do namespace :admin do resources :pages do diff --git a/lib/generators/solidus_static_content/install/install_generator.rb b/lib/generators/solidus_static_content/install/install_generator.rb index 39ca944..d05ed9b 100644 --- a/lib/generators/solidus_static_content/install/install_generator.rb +++ b/lib/generators/solidus_static_content/install/install_generator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SolidusStaticContent module Generators class InstallGenerator < Rails::Generators::Base @@ -12,11 +14,11 @@ def add_migrations end def run_migrations - run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask 'Would you like to run the migrations now? [Y/n]') + run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]')) if run_migrations run 'bundle exec rake db:migrate' else - puts 'Skipping rake db:migrate, don\'t forget to run it!' + puts 'Skipping rake db:migrate, don\'t forget to run it!' # rubocop:disable Rails/Output end end end diff --git a/lib/spree_static_content/factories.rb b/lib/solidus_static_content/factories.rb similarity index 100% rename from lib/spree_static_content/factories.rb rename to lib/solidus_static_content/factories.rb diff --git a/lib/solidus_static_content/version.rb b/lib/solidus_static_content/version.rb index 8935b8f..9713559 100644 --- a/lib/solidus_static_content/version.rb +++ b/lib/solidus_static_content/version.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module SolidusStaticContent VERSION = '1.0.0' end diff --git a/solidus_static_content.gemspec b/solidus_static_content.gemspec index 6f570e0..a2cc724 100644 --- a/solidus_static_content.gemspec +++ b/solidus_static_content.gemspec @@ -1,55 +1,37 @@ +# frozen_string_literal: true -lib = File.expand_path("../lib", __FILE__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) +$:.push File.expand_path('lib', __dir__) require 'solidus_static_content/version' -Gem::Specification.new do |spec| - spec.name = "solidus_static_content" - spec.version = SolidusStaticContent::VERSION - spec.authors = ["Peter Berkenbosch", "Roman Smirnov"] - spec.email = "peter@pero-ict.nl" - - spec.summary = %q{Extension to manage the static pages for your Solidus store.} - spec.description = %q{Manage the static pages of your Solidus store or replace existing pages with a static version} - spec.homepage = "https://github.com/solidusio-contrib/solidus_static_content#readme" - spec.license = "BSD-3" - - if spec.respond_to?(:metadata) - spec.metadata["homepage_uri"] = spec.homepage - spec.metadata["source_code_uri"] = spec.homepage - spec.metadata["changelog_uri"] = "https://github.com/solidusio-contrib/solidus_static_content/releases" +Gem::Specification.new do |s| + s.name = 'solidus_static_content' + s.version = SolidusStaticContent::VERSION + s.summary = %q{Extension to manage the static pages for your Solidus store.} + s.description = %q{Manage the static pages of your Solidus store or replace existing pages with a static version} + s.license = 'BSD-3-Clause' + + s.author = ["Peter Berkenbosch", "Roman Smirnov"] + s.email = 'peter@pero-ict.nl' + s.homepage = 'https://github.com/solidusio-contrib/solidus_static_content#readme' + + if s.respond_to?(:metadata) + s.metadata["homepage_uri"] = s.homepage if s.homepage + s.metadata["source_code_uri"] = s.homepage if s.homepage + s.metadata["changelog_uri"] = 'https://github.com/solidusio-contrib/solidus_static_content/releases' end - # 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. - spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do + s.required_ruby_version = '~> 2.4' + + s.files = Dir.chdir(File.expand_path(__dir__)) do `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } end - spec.bindir = "exe" - spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } - spec.require_paths = ["lib"] - - spec.add_dependency 'solidus', ['>= 2.3', '< 3'] - spec.add_dependency 'solidus_support' - spec.add_dependency 'deface', '~> 1.0' - - spec.add_development_dependency 'apparition' - spec.add_development_dependency 'capybara', '~> 3.12' - spec.add_development_dependency 'capybara-screenshot' - spec.add_development_dependency 'database_cleaner', '~> 1.5' - spec.add_development_dependency 'factory_bot', '~> 5.1' - spec.add_development_dependency 'ffaker' - spec.add_development_dependency 'mysql2', '~> 0.5.2' - spec.add_development_dependency 'pg', '~> 1.1' - spec.add_development_dependency 'poltergeist', '~> 1.10' - spec.add_development_dependency 'pry-rails' - spec.add_development_dependency 'puma' - spec.add_development_dependency 'rails-controller-testing' - spec.add_development_dependency 'rspec-rails', '~> 4.0.0.beta2' - spec.add_development_dependency 'rspec_junit_formatter' - spec.add_development_dependency 'selenium-webdriver' - spec.add_development_dependency 'simplecov', '~> 0.12' - spec.add_development_dependency 'solidus_auth_devise' - spec.add_development_dependency 'sprockets', '< 4' - spec.add_development_dependency 'sqlite3' + s.test_files = Dir['spec/**/*'] + s.bindir = "exe" + s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) } + s.require_paths = ["lib"] + + s.add_dependency 'solidus_core', ['>= 2.0.0', '< 3'] + s.add_dependency 'solidus_support', '~> 0.4.0' + + s.add_development_dependency 'solidus_dev_support' end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b4cc946..fd4b47f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,21 +1,24 @@ # frozen_string_literal: true -ENV["RAILS_ENV"] = "test" +# Configure Rails Environment +ENV['RAILS_ENV'] = 'test' -require File.expand_path("../dummy/config/environment.rb", __FILE__) +# Run Coverage report +require 'solidus_dev_support/rspec/coverage' -require "rspec/rails" +require File.expand_path('dummy/config/environment.rb', __dir__) -Dir[File.join(File.dirname(__FILE__), "/support/**/*.rb")].each { |file| require file } +# Requires factories and other useful helpers defined in spree_core. +require 'solidus_dev_support/rspec/feature_helper' -require "factory_bot" -require "spree_static_content/factories" -require "spree/testing_support/controller_requests" -require "solidus_support/extension/feature_helper" +# Requires supporting ruby files with custom matchers and macros, etc, +# in spec/support/ and its subdirectories. +Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f } + +# Requires factories defined in lib/solidus_static_content/factories.rb +require 'solidus_static_content/factories' RSpec.configure do |config| - config.include Spree::TestingSupport::ControllerRequests, type: :controller + config.infer_spec_type_from_file_location! + config.use_transactional_fixtures = false end - -# A fix for https://github.com/rspec/rspec-rails/issues/1897 -Capybara.server = :puma, { Silent: true }