From 98f99ab3d292387d5bedf4edaf26922adc557024 Mon Sep 17 00:00:00 2001 From: Bounmy Stephane Date: Mon, 9 Apr 2012 18:39:27 +0200 Subject: [PATCH] fixed header_image and locale using I18n.locale set from set_user_language --- .../spree/checkout_controller_decorator.rb | 13 +++++++++++-- spec/controllers/checkout_controller_spec.rb | 11 +++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/controllers/spree/checkout_controller_decorator.rb b/app/controllers/spree/checkout_controller_decorator.rb index 29175a1..c516699 100644 --- a/app/controllers/spree/checkout_controller_decorator.rb +++ b/app/controllers/spree/checkout_controller_decorator.rb @@ -171,6 +171,10 @@ module Spree private + def asset_url(_path) + URI::HTTP.build(:path => ActionController::Base.helpers.asset_path(_path), :host => Spree::Config[:site_url]).to_s + end + def record_log(payment, response) payment.log_entries.create(:details => response.to_yaml) end @@ -197,15 +201,16 @@ module Spree user_action = Spree::PaypalExpress::Config[:paypal_express_local_confirm] == "t" ? "continue" : "commit" end + { :description => "Goods from #{Spree::Config[:site_name]}", # site details... #:page_style => "foobar", # merchant account can set named config - :header_image => "https://#{Spree::Config[:site_url]}#{Spree::Config[:logo]}", + :header_image => asset_url(Spree::Config[:logo]), :background_color => "ffffff", # must be hex only, six chars :header_background_color => "ffffff", :header_border_color => "ffffff", :allow_note => true, - :locale => Spree::Config[:default_locale], + :locale => user_locale, :req_confirm_shipping => false, # for security, might make an option later :user_action => user_action @@ -215,6 +220,10 @@ module Spree } end + def user_locale + I18n.locale.to_s + end + # hook to override paypal site options def paypal_site_opts {:currency => payment_method.preferred_currency} diff --git a/spec/controllers/checkout_controller_spec.rb b/spec/controllers/checkout_controller_spec.rb index e3619a7..4bcfc21 100644 --- a/spec/controllers/checkout_controller_spec.rb +++ b/spec/controllers/checkout_controller_spec.rb @@ -242,6 +242,17 @@ module Spree end + context "#fixed_opts" do + + it "returns hash containing basic settings" do + I18n.locale = :fr + opts = controller.send(:fixed_opts) + opts[:header_image].should == "http://demo.spreecommerce.com/assets/admin/bg/spree_50.png" + opts[:locale].should == "fr" + end + + end + context "order_opts" do it "should return hash containing basic order details" do