From a03fa68bfab050cda85cf9bd787b6a163dd38a2e Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Tue, 22 May 2012 16:26:05 +1000 Subject: [PATCH] Remove sandbox_generator, replace with Rails template The rails template's code is much simpler and allows us to enforce specific gem requirements that the dummy application should never have. This fixes the sandbox's requirement of spree_signup_path as pointed out by BDQ here: https://github.com/spree/spree/pull/1512#issuecomment-5621353 --- Rakefile | 9 ++-- .../spree/sandbox/sandbox_generator.rb | 45 ------------------- .../spree/sandbox/templates/rails/routes.rb | 3 -- core/lib/spree/core.rb | 1 - sandbox.rb | 10 +++++ 5 files changed, 13 insertions(+), 55 deletions(-) delete mode 100644 core/lib/generators/spree/sandbox/sandbox_generator.rb delete mode 100644 core/lib/generators/spree/sandbox/templates/rails/routes.rb create mode 100644 sandbox.rb diff --git a/Rakefile b/Rakefile index f33f6ffe554..040b6d0b141 100644 --- a/Rakefile +++ b/Rakefile @@ -96,10 +96,7 @@ end desc "Creates a sandbox application for simulating the Spree code in a deployed Rails app" task :sandbox do - require 'spree_core' - - Spree::SandboxGenerator.start ["--lib_name=spree"] - Spree::InstallGenerator.start ["--auto-accept"] - - cmd = "bundle exec rake assets:precompile:nondigest"; puts cmd; system cmd + FileUtils.rm_r("sandbox") + puts "Running Sandbox generator..." + exec("rails new sandbox -m sandbox.rb") end diff --git a/core/lib/generators/spree/sandbox/sandbox_generator.rb b/core/lib/generators/spree/sandbox/sandbox_generator.rb deleted file mode 100644 index 2c67d0342c3..00000000000 --- a/core/lib/generators/spree/sandbox/sandbox_generator.rb +++ /dev/null @@ -1,45 +0,0 @@ -require "rails/generators/rails/app/app_generator" - -module Spree - class SandboxGenerator < Spree::DummyGenerator - desc "Creates blank Rails application, installs Spree and all sample data" - - def self.source_paths - paths = self.superclass.source_paths - paths.unshift File.expand_path('../templates', __FILE__) - paths.flatten - end - - def drop_database - say "dropping database" - inside dummy_path do - quietly do - rake 'db:drop -f sandbox/Rakefile' - end - end - end - - def use_spree_auth_devise - inside dummy_path do - File.open("Gemfile", "a+") do |f| - f.write %Q{gem 'spree_auth_devise', :git => "git://github.com/radar/spree_auth_devise"} - end - end - run 'bundle install' - end - - protected - def dummy_path - 'sandbox' - end - - def gemfile_path - '../../../Gemfile' - end - - def module_name - 'Sandbox' - end - - end -end diff --git a/core/lib/generators/spree/sandbox/templates/rails/routes.rb b/core/lib/generators/spree/sandbox/templates/rails/routes.rb deleted file mode 100644 index 1c8c7310a7f..00000000000 --- a/core/lib/generators/spree/sandbox/templates/rails/routes.rb +++ /dev/null @@ -1,3 +0,0 @@ -Rails.application.routes.draw do - mount Spree::Core::Engine => "/" -end diff --git a/core/lib/spree/core.rb b/core/lib/spree/core.rb index 775a4768c60..eb2780ba378 100644 --- a/core/lib/spree/core.rb +++ b/core/lib/spree/core.rb @@ -95,7 +95,6 @@ def self.config(&block) require 'spree/core/engine' require 'generators/spree/dummy/dummy_generator' -require 'generators/spree/sandbox/sandbox_generator' ActiveRecord::Base.class_eval do include Spree::Core::CalculatedAdjustments diff --git a/sandbox.rb b/sandbox.rb new file mode 100644 index 00000000000..f0a7d1c9b2a --- /dev/null +++ b/sandbox.rb @@ -0,0 +1,10 @@ +# Used in the sandbox rake task in Rakefile +gem('spree', :path => "..") +gem('spree_auth_devise', :path => "~/Sites/gems/spree_auth_devise") +gem('devise-encryptable', '0.1.1') +puts "Running Spree installer..." +generate("spree:install --auto-accept") +puts "Precompilign assets..." +rake("assets:precompile:nondigest") +puts "Done!" +