Skip to content

Commit

Permalink
Reshuffle frontend and core
Browse files Browse the repository at this point in the history
This is a combination of 27 commits.

* Move search base fron frontend to core
* Move Spree::Money from frontend to core
* move mailers to core
* Move mailer views to core
* Require core not models in frontend gemspec
* Fix require in product_filter_spec
* frontend stuff now lives at lib/spree/frontend
* Core engine is now once again for isolating the engine namespace
* Move user class extensions to core
* Move UserBanners to Core
* Frontend now prepends routes to core
* Rename Core references in Frontend to Frontend
* Fix spree_frontend gemspec
* Fix spree_core.gemspec
* Remove unnecessary scopes file
* Rename spree/core.rb inside frontend to spree/frontend.rb
* Fix ControllerHelpers reference in Spree::BaseController
* Fix require to action_callbacks withn Admin::ResourceController
* Fix module reference for ControllerHelpers inside Spree::StoreController
* Fix testing_support requires within spec_helper
* Fix requires in frontend.rb
* Moved ControllerHelpers back into Core.
* This is because API no longer depends on frontend
* Move SSL requirement into core from frontend
* Add require for cancan inside core.rb
* Add frontend to travis
* Add spree_core.rb
* Add frontend to Rakefile
  • Loading branch information
radar committed Feb 7, 2013
1 parent e1e175c commit b31124c
Show file tree
Hide file tree
Showing 56 changed files with 160 additions and 189 deletions.
18 changes: 15 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ end

desc "Generates a dummy app for testing for every Spree engine"
task :test_app do
require File.expand_path('../models/lib/generators/spree/install/install_generator', __FILE__)
%w(api core dash promo models).each do |engine|
require File.expand_path('../core/lib/generators/spree/install/install_generator', __FILE__)
%w(api core dash frontend promo).each do |engine|
ENV['LIB_NAME'] = File.join('spree', engine)
ENV['DUMMY_PATH'] = File.expand_path("../#{engine}/spec/dummy", __FILE__)
Rake::Task['common:test_app'].execute
Expand All @@ -30,7 +30,7 @@ task :clean do
puts "Deleting pkg directory.."
FileUtils.rm_rf("pkg")

%w(api cmd core dash promo models).each do |gem_name|
%w(api cmd core dash frontend promo).each do |gem_name|
puts "Cleaning #{gem_name}:"
puts " Deleting #{gem_name}/Gemfile"
FileUtils.rm_f("#{gem_name}/Gemfile")
Expand All @@ -46,7 +46,11 @@ end
namespace :gem do
desc "run rake gem for all gems"
task :build do
<<<<<<< HEAD
%w(core api dash promo sample cmd models testing_support).each do |gem_name|
=======
%w(core api dash frontend promo sample cmd).each do |gem_name|
>>>>>>> ee4b70b... Add frontend to Rakefile
puts "########################### #{gem_name} #########################"
puts "Deleting #{gem_name}/pkg"
FileUtils.rm_rf("#{gem_name}/pkg")
Expand All @@ -63,7 +67,11 @@ namespace :gem do
task :install do
version = File.read(File.expand_path("../SPREE_VERSION", __FILE__)).strip

<<<<<<< HEAD
%w(core api dash promo sample cmd models testing_support).each do |gem_name|
=======
%w(core api dash frontend promo sample cmd).each do |gem_name|
>>>>>>> ee4b70b... Add frontend to Rakefile
puts "########################### #{gem_name} #########################"
puts "Deleting #{gem_name}/pkg"
FileUtils.rm_rf("#{gem_name}/pkg")
Expand All @@ -82,7 +90,11 @@ namespace :gem do
task :release do
version = File.read(File.expand_path("../SPREE_VERSION", __FILE__)).strip

<<<<<<< HEAD
%w(core api dash promo sample cmd models testing_support).each do |gem_name|
=======
%w(core api dash frontend promo sample cmd).each do |gem_name|
>>>>>>> ee4b70b... Add frontend to Rakefile
puts "########################### #{gem_name} #########################"
cmd = "cd #{gem_name}/pkg && gem push spree_#{gem_name}-#{version}.gem"; puts cmd; system cmd
end
Expand Down
1 change: 0 additions & 1 deletion api/Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
eval(File.read(File.dirname(__FILE__) + '/../common_spree_dependencies.rb'))

gem 'spree_models', :path => "../models"
gem 'spree_core', :path => "../core"

gemspec
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions core/app/models/spree/taxon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def applicable_filters
# fs << ProductFilters.taxons_below(self)
## unless it's a root taxon? left open for demo purposes

fs << ProductFilters.price_filter if ProductFilters.respond_to?(:price_filter)
fs << ProductFilters.brand_filter if ProductFilters.respond_to?(:brand_filter)
fs << Spree::Core::ProductFilters.price_filter if Spree::Core::ProductFilters.respond_to?(:price_filter)
fs << Spree::Core::ProductFilters.brand_filter if Spree::Core::ProductFilters.respond_to?(:brand_filter)
fs
end

Expand Down
4 changes: 4 additions & 0 deletions core/config/routes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Spree::Core::Engine.routes.draw do
# These routes now come from the Spree::Frontend component.
# Look in frontend/config/routes.rb for the routes.
end
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//= require jquery
//= require jquery_ujs
<% if options[:lib_name] == 'spree' %>
//= require admin/spree_core
//= require admin/spree_frontend
//= require admin/spree_promo
<% else %>
//= require admin/<%= options[:lib_name].gsub("/", "_") %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//= require jquery
//= require jquery_ujs
<% if options[:lib_name] == 'spree' %>
//= require store/spree_core
//= require store/spree_frontend
//= require store/spree_promo
<% else %>
//= require store/<%= options[:lib_name].gsub("/", "_") %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* the top of the compiled file, but it's generally better to create a new file per style scope.
*
<% if options[:lib_name] == 'spree' %>
*= require admin/spree_core
*= require admin/spree_frontend
*= require admin/spree_promo
<% else %>
*= require admin/<%= options[:lib_name].gsub("/", "_") %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* the top of the compiled file, but it's generally better to create a new file per style scope.
*
<% if options[:lib_name] == 'spree' %>
*= require store/spree_core
*= require store/spree_frontend
*= require store/spree_promo
<% else %>
*= require store/<%= options[:lib_name].gsub("/", "_") %>
Expand Down
3 changes: 3 additions & 0 deletions core/lib/spree/core.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'rails/all'
require 'cancan'
require 'state_machine'
require 'paperclip'
require 'kaminari'
Expand Down Expand Up @@ -37,6 +38,8 @@ def self.config(&block)
require 'spree/core/version'
require 'spree/core/engine'

require 'spree/money'

require 'spree/core/delegate_belongs_to'
require 'spree/core/ext/active_record'
require 'spree/core/permalinks'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'spree/core/ssl_requirement'

module Spree
module Core
module ControllerHelpers
Expand Down
File renamed without changes.
7 changes: 2 additions & 5 deletions core/lib/spree/core/engine.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
require 'rabl'

module Spree
def self.table_name_prefix
"spree_"
end

module Core
class Engine < ::Rails::Engine
engine_name 'spree_core'
isolate_namespace Spree
engine_name 'spree'

config.autoload_paths += %W(#{config.root}/lib)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion core/spec/models/spree/product_filter_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'spec_helper'
require 'spree/models/product_filters'
require 'spree/core/product_filters'

describe 'product filters' do
# Regression test for #1709
Expand Down
26 changes: 25 additions & 1 deletion core/spec/models/spree/product_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,32 @@
end

context "when prototype with option types is supplied" do
def build_option_type_with_values(name, values)
ot = FactoryGirl.create(:option_type, :name => name)
values.each do |val|
ot.option_values.create({:name => val.downcase, :presentation => val}, :without_protection => true)
end
ot
end

let(:product_attributes) do
# FactoryGirl.attributes_for is un-deprecated!
# https://github.com/thoughtbot/factory_girl/issues/274#issuecomment-3592054
FactoryGirl.attributes_for(:simple_product)
end

include_context "product prototype"
let(:prototype) do
size = build_option_type_with_values("size", %w(Small Medium Large))
FactoryGirl.create(:prototype, :name => "Size", :option_types => [ size ])
end

let(:option_values_hash) do
hash = {}
prototype.option_types.each do |i|
hash[i.id.to_s] = i.option_value_ids
end
hash
end

before { @product.prototype_id = prototype.id }

Expand Down
69 changes: 0 additions & 69 deletions core/spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,72 +56,3 @@

config.include Paperclip::Shoulda::Matchers
end

shared_context "custom products" do
before(:each) do
configure_spree_preferences do |config|
config.allow_backorders = true
end

taxonomy = FactoryGirl.create(:taxonomy, :name => 'Categories')
root = taxonomy.root
clothing_taxon = FactoryGirl.create(:taxon, :name => 'Clothing', :parent_id => root.id)
bags_taxon = FactoryGirl.create(:taxon, :name => 'Bags', :parent_id => root.id)
mugs_taxon = FactoryGirl.create(:taxon, :name => 'Mugs', :parent_id => root.id)

taxonomy = FactoryGirl.create(:taxonomy, :name => 'Brands')
root = taxonomy.root
apache_taxon = FactoryGirl.create(:taxon, :name => 'Apache', :parent_id => root.id)
rails_taxon = FactoryGirl.create(:taxon, :name => 'Ruby on Rails', :parent_id => root.id)
ruby_taxon = FactoryGirl.create(:taxon, :name => 'Ruby', :parent_id => root.id)

FactoryGirl.create(:custom_product, :name => 'Ruby on Rails Ringer T-Shirt', :price => '19.99', :taxons => [rails_taxon, clothing_taxon])
FactoryGirl.create(:custom_product, :name => 'Ruby on Rails Mug', :price => '15.99', :taxons => [rails_taxon, mugs_taxon])
FactoryGirl.create(:custom_product, :name => 'Ruby on Rails Tote', :price => '15.99', :taxons => [rails_taxon, bags_taxon])
FactoryGirl.create(:custom_product, :name => 'Ruby on Rails Bag', :price => '22.99', :taxons => [rails_taxon, bags_taxon])
FactoryGirl.create(:custom_product, :name => 'Ruby on Rails Baseball Jersey', :price => '19.99', :taxons => [rails_taxon, clothing_taxon])
FactoryGirl.create(:custom_product, :name => 'Ruby on Rails Stein', :price => '16.99', :taxons => [rails_taxon, mugs_taxon])
FactoryGirl.create(:custom_product, :name => 'Ruby on Rails Jr. Spaghetti', :price => '19.99', :taxons => [rails_taxon, clothing_taxon])
FactoryGirl.create(:custom_product, :name => 'Ruby Baseball Jersey', :price => '19.99', :taxons => [ruby_taxon, clothing_taxon])
FactoryGirl.create(:custom_product, :name => 'Apache Baseball Jersey', :price => '19.99', :taxons => [apache_taxon, clothing_taxon])
end
end



shared_context "product prototype" do

def build_option_type_with_values(name, values)
ot = FactoryGirl.create(:option_type, :name => name)
values.each do |val|
ot.option_values.create({:name => val.downcase, :presentation => val}, :without_protection => true)
end
ot
end

let(:product_attributes) do
# FactoryGirl.attributes_for is un-deprecated!
# https://github.com/thoughtbot/factory_girl/issues/274#issuecomment-3592054
FactoryGirl.attributes_for(:base_product)
end

let(:prototype) do
size = build_option_type_with_values("size", %w(Small Medium Large))
FactoryGirl.create(:prototype, :name => "Size", :option_types => [ size ])
end

let(:option_values_hash) do
hash = {}
prototype.option_types.each do |i|
hash[i.id.to_s] = i.option_value_ids
end
hash
end

end



PAYMENT_STATES = Spree::Payment.state_machine.states.keys unless defined? PAYMENT_STATES
SHIPMENT_STATES = Spree::Shipment.state_machine.states.keys unless defined? SHIPMENT_STATES
ORDER_STATES = Spree::Order.state_machine.states.keys unless defined? ORDER_STATES
7 changes: 3 additions & 4 deletions core/spree_core.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@ version = File.read(File.expand_path("../../SPREE_VERSION", __FILE__)).strip

Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = 'spree_models'
s.name = 'spree_core'
s.version = version
s.summary = 'ActiveRecord models for Spree.'
s.description = 'Required dependency for Spree'
s.summary = 'The barebones necessary for Spree.'
s.description = 'The barebones necessary for Spree.'

s.required_ruby_version = '>= 1.8.7'
s.author = 'Sean Schofield'
s.email = '[email protected]'
s.homepage = 'http://spreecommerce.com'
s.license = %q{BSD-3}
s.rubyforge_project = 'spree_core'

s.files = Dir['LICENSE', 'README.md', 'app/**/*', 'config/**/*', 'lib/**/*', 'db/**/*', 'vendor/**/*']
s.require_path = 'lib'
Expand Down
2 changes: 1 addition & 1 deletion frontend/Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
eval(File.read(File.dirname(__FILE__) + '/../common_spree_dependencies.rb'))

gem 'spree_models', :path => '../models'
gem 'spree_core', :path => '../core'
gem 'spree_api', :path => '../api'

gemspec
4 changes: 2 additions & 2 deletions frontend/app/assets/stylesheets/store/spree_core.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This is a manifest file that includes stylesheets for spree_core
* This is a manifest file that includes stylesheets for spree_frontend
*= require normalize
*= require skeleton
*= require store/screen
*/
*/
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'spree/core/action_callbacks'
require 'spree/frontend/action_callbacks'

class Spree::Admin::ResourceController < Spree::Admin::BaseController
helper_method :new_object_url, :edit_object_url, :object_url, :collection_url
Expand Down
2 changes: 1 addition & 1 deletion frontend/config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Spree::Core::Engine.routes.draw do
Spree::Core::Engine.routes.prepend do

root :to => 'home#index'

Expand Down
65 changes: 0 additions & 65 deletions frontend/lib/spree/core/scopes.rb

This file was deleted.

Loading

0 comments on commit b31124c

Please sign in to comment.