Permalink
Browse files

spree 1-3-stable support

  • Loading branch information...
1 parent e50af35 commit e39b7860ae583c1dfe46892872f63e1d4bedcdd4 @sbounmy sbounmy committed Dec 11, 2012
View
@@ -2,6 +2,12 @@ source 'http://rubygems.org'
group :test do
gem 'ffaker'
+ gem 'debugger'
+ if ENV['USE_LOCAL_SPREE']
+ gem 'spree_core', :path => '~/code/spree'
+ else
+ gem 'spree_core', :git => 'git://github.com/spree/spree', :branch => '1-3-stable'
+ end
end
gemspec
@@ -10,7 +10,7 @@ def locale_suffix(locale)
private
def set_user_language
- I18n.locale = Rails.application.config.i18n.default_locale.to_sym
+ I18n.locale = (Rails.application.config.i18n.default_locale || 'en').to_sym
end
end
@@ -1,4 +1,4 @@
-Spree::Core::ControllerHelpers.module_eval do
+Spree::Core::ControllerHelpers::Common.module_eval do
private
# Internal : Set user I18n.locale
@@ -10,6 +10,7 @@
# or I18n.locale set by rack-locale for example
# or Spree::Config[:default_locale]
# or Rails.application.config.i18n.default_locale
+
def set_user_language
locale = params[:locale] || session[:locale] || I18n.locale || Spree::Config[:default_locale] || Rails.application.config.i18n.default_locale
locale = I18n.default_locale unless locale && I18n.available_locales.include?(locale.to_sym)
@@ -1,21 +1,16 @@
module Spree
Spree::Order.class_eval do
- # Finalizes an in progress order after checkout is complete.
- # Called after transition to complete state when payments will have been processed
- def finalize!
- update_attribute(:completed_at, Time.now)
- update_attribute(:locale, I18n.locale)
- InventoryUnit.assign_opening_inventory(self)
- # lock any optional adjustments (coupon promotions, etc.)
- adjustments.optional.each { |adjustment| adjustment.update_attribute('locked', true) }
- deliver_order_confirmation_email
- self.state_changes.create({
- :previous_state => 'cart',
- :next_state => 'complete',
- :name => 'order' ,
- :user_id => (User.respond_to?(:current) && User.current.try(:id)) || self.user_id
- }, :without_protection => true)
+ # override this to also set current user locale for email i18n
+ def deliver_order_confirmation_email
+ update_attribute(:locale, I18n.locale)
+ begin
+ OrderMailer.confirm_email(self).deliver
+ rescue Exception => e
+ logger.error("#{e.class.name}: #{e.message}")
+ logger.error(e.backtrace * "\n")
+ end
end
+
end
end
@@ -1,13 +1,13 @@
-Spree::Variant.class_eval do
- alias_method :old_price=, :price=
+# Spree::Variant.class_eval do
+# alias_method :old_price=, :price=
- def price=(value)
- write_attribute(:price, value.to_s.tr(',', '.').to_f)
- end
+# def price=(value)
+# write_attribute(:price, value.to_s.tr(',', '.').to_f)
+# end
- [:cost_price, :weight, :height, :width, :depth].each do |attribute|
- define_method("#{attribute}=") do |value|
- write_attribute(attribute, value.to_s.tr(',', '.').to_f)
- end
- end
-end
+# [:cost_price, :weight, :height, :width, :depth].each do |attribute|
+# define_method("#{attribute}=") do |value|
+# write_attribute(attribute, value.to_s.tr(',', '.').to_f)
+# end
+# end
+# end
@@ -3,17 +3,20 @@
describe Spree::Product do
context "using comma as a delimiter" do
it "can assign price attribute" do
+ pending 'this should be handled by spree_core Spree::Variant#parse_price'
product = Spree::Product.new
product.price = "9,99"
product.price.to_f.should == 9.99
end
it "can mass assign a price during creation" do
+ pending 'this should be handled by spree_core Spree::Variant#parse_price'
product = Spree::Product.new(:name => "The Product", :price => "9,99")
product.save!
end
it "can mass assign a price during update" do
+ pending 'this should be handled by spree_core Spree::Variant#parse_price'
product = Spree::Product.create!(:name => "The Product", :price => 19.99)
product.price.should == 19.99
product.update_attributes(:price => "9,99")
@@ -22,6 +25,7 @@
[:cost_price, :weight, :height, :width, :depth].each do |attribute|
it "can assign the #{attribute} attribute" do
+ pending 'this should be handled by spree_core Spree::Variant#parse_price'
product = Spree::Product.new
product.send("#{attribute}=", "9,99")
product.send("#{attribute}").to_f.should == 9.99
@@ -7,7 +7,7 @@ module Spree
I18n.locale = :fr
order = FactoryGirl.create(:order)
order.finalize!
- order.locale.should == :fr
+ order.reload.locale.should == 'fr'
I18n.locale = nil
end
end
@@ -1,13 +1,17 @@
require 'spec_helper'
describe "admin products" do
+ stub_authorization!
+
let!(:product) { FactoryGirl.create(:product) }
it "displays price in correct format" do
+ pending 'this is handled in spree_core Spree::Variant#parse_price'
visit spree.edit_admin_product_path(product)
fill_in "product_price", :with => "9,99"
# No clue WHY we have to set this, it's just necessary. Ugh.
fill_in "product_cost_price", :with => "10"
click_button I18n.t("update")
Nokogiri::HTML(page.body).css("input#product_price")[0]["value"].strip.should == "9,99"
+ I18n.locale = :en
end
end
@@ -1,23 +1,32 @@
require 'spec_helper'
feature "OptionType multi lingual", :js => true do
+ stub_authorization!
+
background do
visit spree.admin_option_types_path
end
- scenario "create successfully" do
+ scenario "update successfully" do
click_link "new_option_type_link"
page.should have_button("Create")
+ fill_in "option_type_presentation", :with => "Size"
+ fill_in "option_type_name", :with => "size"
+
+ click_button "Create"
+
select "fr", :from => "spree_multi_lingual_dropdown"
fill_in "option_type_name", :with => "size"
fill_in "option_type_presentation_fr", :with => "Taille"
- select "en", :from => "spree_multi_lingual_dropdown"
- fill_in "option_type_presentation", :with => "Size"
+ click_button "Update"
+ page.should have_content("successfully updated!")
+ click_icon :edit
- click_button "Create"
- page.should have_content("successfully created!")
+ page.should have_content("Size")
+ select "fr", :from => "spree_multi_lingual_dropdown"
+ page.should have_content("Taille")
end
end
@@ -1,13 +1,16 @@
require 'spec_helper'
feature "Products multi lingual", :js => true do
+ stub_authorization!
+
background do
@product = FactoryGirl.create(:product, :name => "ror mug", :price => 30)
end
scenario "admin should be able to edit product page i18n" do
visit spree.admin_products_path
- click_link "Edit"
+ click_icon :edit
+
# filling some content in name, meta description, keywords
%w(fr en es).each do |locale|
select locale, :from => "spree_multi_lingual_dropdown"
@@ -32,7 +35,7 @@
scenario "product permalink should be editable" do
visit spree.admin_products_path
- click_link "Edit"
+ click_icon :edit
%w(fr en es).each do |locale|
select locale, :from => "spree_multi_lingual_dropdown"
@@ -1,6 +1,8 @@
require 'spec_helper'
feature "Products multi lingual", :js => true do
+ stub_authorization!
+
background do
I18n.stub(:available_locales).and_return [:en, :fr, :es]
end
@@ -17,15 +19,15 @@
fill_in "Name", :with => "Bonjour"
click_button "Update"
- click_link "Edit"
+ click_icon :edit
click_link "fr"
page.should have_content("Bonjour")
click_link "es"
fill_in "Name", :with => "Hola"
click_button "Update"
- click_link "Edit"
+ click_icon :edit
click_link "es"
page.should have_content("Hola")
end
View
@@ -9,8 +9,9 @@
# in spec/support/ and its subdirectories.
Dir[File.join(File.dirname(__FILE__), "support/**/*.rb")].each {|f| require f }
-# Requires factories defined in spree_core
require 'spree/core/testing_support/factories'
+require 'spree/core/testing_support/authorization_helpers'
+require 'spree/core/testing_support/capybara_ext'
RSpec.configure do |config|
# == Mock Framework
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
s.require_path = 'lib'
s.requirements << 'none'
- s.add_dependency 'spree_core', '~> 1.2.0'
+ s.add_dependency 'spree_core', '1.3.0rc1'
s.add_dependency 'i18n'
s.add_dependency 'globalize3', '0.2.0'
s.add_dependency 'easy_globalize3_accessors'

0 comments on commit e39b786

Please sign in to comment.