Permalink
Browse files

add presentation translation to option type

  • Loading branch information...
1 parent ffc020c commit 69e3b8d459131a0106dc5a9f56106ae1f6587e35 @sbounmy sbounmy committed Apr 21, 2012
View
1 .gitignore
@@ -11,3 +11,4 @@ spec/dummy
.rvmrc
.bundle
.sass-cache
+Gemfile.lock
View
29 Gemfile.lock
@@ -61,11 +61,10 @@ GEM
multi_json (~> 1.0)
acts_as_list (0.1.4)
addressable (2.2.7)
- archive-tar-minitar (0.5.2)
arel (2.2.3)
awesome_print (1.0.2)
bcrypt-ruby (3.0.1)
- braintree (2.15.0)
+ braintree (2.16.0)
builder (>= 2.0.0)
builder (3.0.0)
cancan (1.6.7)
@@ -76,7 +75,7 @@ GEM
rack-test (>= 0.5.4)
selenium-webdriver (~> 2.0)
xpath (~> 0.1.4)
- childprocess (0.3.1)
+ childprocess (0.3.2)
ffi (~> 1.0.6)
cocaine (0.2.1)
coffee-rails (3.1.1)
@@ -86,7 +85,6 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.3.1)
- columnize (0.3.6)
deface (0.8.0)
nokogiri (~> 1.5.0)
rails (>= 3.0.9)
@@ -100,7 +98,7 @@ GEM
erubis (2.7.0)
execjs (1.3.0)
multi_json (~> 1.0)
- factory_girl (3.1.0)
+ factory_girl (3.1.1)
activesupport (>= 3.0.0)
ffaker (1.12.1)
ffi (1.0.11)
@@ -123,8 +121,6 @@ GEM
addressable (~> 2.2.6)
libwebsocket (0.1.3)
addressable
- linecache19 (0.5.12)
- ruby_core_source (>= 0.1.4)
mail (2.3.3)
i18n (>= 0.4.0)
mime-types (~> 1.16)
@@ -137,7 +133,7 @@ GEM
mime-types (1.18)
money (3.7.1)
i18n (~> 0.4)
- multi_json (1.2.0)
+ multi_json (1.3.2)
mysql2 (0.3.11)
nested_set (1.6.8)
activerecord (>= 3.0.0)
@@ -197,19 +193,9 @@ GEM
activesupport (>= 3.0)
railties (>= 3.0)
rspec (~> 2.9.0)
- ruby-debug-base19 (0.11.25)
- columnize (>= 0.3.1)
- linecache19 (>= 0.5.11)
- ruby_core_source (>= 0.1.4)
- ruby-debug19 (0.11.6)
- columnize (>= 0.3.1)
- linecache19 (>= 0.5.11)
- ruby-debug-base19 (>= 0.11.19)
- ruby_core_source (0.1.5)
- archive-tar-minitar (>= 0.5.2)
rubyzip (0.9.7)
- sass (3.1.15)
- selenium-webdriver (2.21.0)
+ sass (3.1.16)
+ selenium-webdriver (2.21.2)
childprocess (>= 0.2.5)
ffi (~> 1.0)
libwebsocket (~> 0.1.3)
@@ -237,7 +223,7 @@ GEM
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
- sqlite3 (1.3.5)
+ sqlite3 (1.3.6)
state_machine (1.1.1)
stringex (1.3.2)
thor (0.14.6)
@@ -263,7 +249,6 @@ DEPENDENCIES
mysql2
routing-filter!
rspec-rails (~> 2.7)
- ruby-debug19
spree_auth (~> 1.0.3)
spree_multi_lingual!
sqlite3
View
5 app/models/option_type_decorator.rb
@@ -0,0 +1,5 @@
+module Spree
+ OptionType.class_eval do
+ translates :presentation
+ end
+end
View
13 app/overrides/option_type_add_language_dropdown.rb
@@ -0,0 +1,13 @@
+Deface::Override.new(
+ :virtual_path => "spree/admin/option_types/index",
+ :insert_before => "div#new_option_type",
+ :text => '<%= render "spree/admin/shared/language_dropdown", :object => Spree::OptionType.new -%>',
+ :name => "option_type_add_language_dropdown"
+)
+
+Deface::Override.new(
+ :virtual_path => "spree/admin/option_types/edit",
+ :insert_before => "fieldset",
+ :text => '<%= render "spree/admin/shared/language_dropdown", :object => @option_type -%>',
+ :name => "option_type_add_language_dropdown"
+)
View
10 db/migrate/20120421183338_add_translations_to_option_types.rb
@@ -0,0 +1,10 @@
+class AddTranslationsToOptionTypes < ActiveRecord::Migration
+ def up
+ Spree::OptionType.create_translation_table!({:presentation => :string},
+ {:migrate_data => true})
+ end
+
+ def down
+ Spree::OptionType.drop_translation_table!
+ end
+end
View
4 lib/spree_multi_lingual/engine.rb
@@ -21,10 +21,6 @@ def self.activate
Dir.glob(File.join(File.dirname(__FILE__), "../../app/**/*_decorator*.rb")) do |c|
Rails.configuration.cache_classes ? require(c) : load(c)
end
-
- Dir.glob(File.join(File.dirname(__FILE__), "../../app/overrides/*.rb")) do |c|
- Rails.configuration.cache_classes ? require(c) : load(c)
- end
end
# after rails config/initializers loading, setup spree_multi_lingual's language by getting
View
24 spec/requests/option_types_spec.rb
@@ -0,0 +1,24 @@
+require 'spec_helper'
+
+feature "OptionType multi lingual", :js => true do
+ background do
+ sign_in_as! Factory(:admin_user)
+ visit spree.admin_option_types_path
+ end
+
+ scenario "create successfully" do
+ click_link "new_option_type_link"
+ page.should have_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 "Create"
+ page.should have_content("successfully created!")
+ end
+end

0 comments on commit 69e3b8d

Please sign in to comment.