Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

now translate spree promotions

  • Loading branch information...
commit 2ca929e8016dd5251cc0f4b2bf53a05a961fa34e 1 parent 53bbb92
@sbounmy sbounmy authored
View
4 app/models/promotion_decorator.rb
@@ -0,0 +1,4 @@
+# Defining this in parent class Spree::Activator was raising undefined method association_class for nil
+Spree::Promotion.class_eval do
+ translates :name, :description, :code, :path
+end
View
6 app/overrides/promotions_add_language_dropdown.rb
@@ -0,0 +1,6 @@
+Deface::Override.new(
+ :virtual_path => "spree/admin/promotions/_form",
+ :insert_top => "#general_fields",
+ :text => '<%= render "spree/admin/shared/language_dropdown", :object => @promotion -%>',
+ :name => "promotion_add_language_dropdown"
+)
View
8 db/migrate/20130408193806_add_translation_to_promotions.rb
@@ -0,0 +1,8 @@
+class AddTranslationToPromotions < ActiveRecord::Migration
+ def up
+ Spree::Promotion.create_translation_table!( { :name => :string, :description => :string, :code => :string, :path => :string }, { :migrate_data => true } )
+ end
+ def down
+ Spree::Promotion.drop_translation_table!
+ end
+end
View
1  lib/spree_multi_lingual.rb
@@ -1,4 +1,5 @@
require 'spree_core'
+require 'spree_promo'
require 'spree_multi_lingual/engine'
require "globalize3"
require "easy_globalize3_accessors"
View
34 spec/requests/promotion_spec.rb
@@ -0,0 +1,34 @@
+require 'spec_helper'
+
+feature "Promotions multi lingual", :js => true do
+ stub_authorization!
+
+ background do
+ I18n.stub(:available_locales).and_return [:en, :fr, :es]
+ end
+
+ scenario "admin should be able to create promotion" do
+ visit spree.new_admin_promotion_path
+
+ fill_in "Name", :with => "Free Shipping"
+
+ select 'fr', :from => 'spree_multi_lingual_dropdown'
+
+ fill_in "promotion_name_fr", :with => "Livraison Gratuite"
+
+ click_button "Create"
+ first("input#promotion_name")[:value].should == "Free Shipping"
+
+ select 'fr', :from => 'spree_multi_lingual_dropdown'
+ first("input#promotion_name_fr")[:value].should == "Livraison Gratuite"
+ end
+
+ scenario 'user should be able to checkout with code' do
+ pending
+ end
+
+ scenario 'user should be able to checkout with path' do
+ pending
+ end
+
+end
View
1  spree_multi_lingual.gemspec
@@ -17,6 +17,7 @@ Gem::Specification.new do |s|
s.requirements << 'none'
s.add_dependency 'spree_core', '~> 1.3'
+ s.add_dependency 'spree_promo', '~> 1.3'
s.add_dependency 'i18n'
s.add_dependency 'globalize3', '0.2.0'
s.add_dependency 'easy_globalize3_accessors'

0 comments on commit 2ca929e

Please sign in to comment.
Something went wrong with that request. Please try again.