Skip to content
This repository
Browse code

add presentation translation to option type

  • Loading branch information...
commit 69e3b8d459131a0106dc5a9f56106ae1f6587e35 1 parent ffc020c
Bounmy Stéphane sbounmy authored
1  .gitignore
@@ -11,3 +11,4 @@ spec/dummy
11 11 .rvmrc
12 12 .bundle
13 13 .sass-cache
  14 +Gemfile.lock
29 Gemfile.lock
@@ -61,11 +61,10 @@ GEM
61 61 multi_json (~> 1.0)
62 62 acts_as_list (0.1.4)
63 63 addressable (2.2.7)
64   - archive-tar-minitar (0.5.2)
65 64 arel (2.2.3)
66 65 awesome_print (1.0.2)
67 66 bcrypt-ruby (3.0.1)
68   - braintree (2.15.0)
  67 + braintree (2.16.0)
69 68 builder (>= 2.0.0)
70 69 builder (3.0.0)
71 70 cancan (1.6.7)
@@ -76,7 +75,7 @@ GEM
76 75 rack-test (>= 0.5.4)
77 76 selenium-webdriver (~> 2.0)
78 77 xpath (~> 0.1.4)
79   - childprocess (0.3.1)
  78 + childprocess (0.3.2)
80 79 ffi (~> 1.0.6)
81 80 cocaine (0.2.1)
82 81 coffee-rails (3.1.1)
@@ -86,7 +85,6 @@ GEM
86 85 coffee-script-source
87 86 execjs
88 87 coffee-script-source (1.3.1)
89   - columnize (0.3.6)
90 88 deface (0.8.0)
91 89 nokogiri (~> 1.5.0)
92 90 rails (>= 3.0.9)
@@ -100,7 +98,7 @@ GEM
100 98 erubis (2.7.0)
101 99 execjs (1.3.0)
102 100 multi_json (~> 1.0)
103   - factory_girl (3.1.0)
  101 + factory_girl (3.1.1)
104 102 activesupport (>= 3.0.0)
105 103 ffaker (1.12.1)
106 104 ffi (1.0.11)
@@ -123,8 +121,6 @@ GEM
123 121 addressable (~> 2.2.6)
124 122 libwebsocket (0.1.3)
125 123 addressable
126   - linecache19 (0.5.12)
127   - ruby_core_source (>= 0.1.4)
128 124 mail (2.3.3)
129 125 i18n (>= 0.4.0)
130 126 mime-types (~> 1.16)
@@ -137,7 +133,7 @@ GEM
137 133 mime-types (1.18)
138 134 money (3.7.1)
139 135 i18n (~> 0.4)
140   - multi_json (1.2.0)
  136 + multi_json (1.3.2)
141 137 mysql2 (0.3.11)
142 138 nested_set (1.6.8)
143 139 activerecord (>= 3.0.0)
@@ -197,19 +193,9 @@ GEM
197 193 activesupport (>= 3.0)
198 194 railties (>= 3.0)
199 195 rspec (~> 2.9.0)
200   - ruby-debug-base19 (0.11.25)
201   - columnize (>= 0.3.1)
202   - linecache19 (>= 0.5.11)
203   - ruby_core_source (>= 0.1.4)
204   - ruby-debug19 (0.11.6)
205   - columnize (>= 0.3.1)
206   - linecache19 (>= 0.5.11)
207   - ruby-debug-base19 (>= 0.11.19)
208   - ruby_core_source (0.1.5)
209   - archive-tar-minitar (>= 0.5.2)
210 196 rubyzip (0.9.7)
211   - sass (3.1.15)
212   - selenium-webdriver (2.21.0)
  197 + sass (3.1.16)
  198 + selenium-webdriver (2.21.2)
213 199 childprocess (>= 0.2.5)
214 200 ffi (~> 1.0)
215 201 libwebsocket (~> 0.1.3)
@@ -237,7 +223,7 @@ GEM
237 223 hike (~> 1.2)
238 224 rack (~> 1.0)
239 225 tilt (~> 1.1, != 1.3.0)
240   - sqlite3 (1.3.5)
  226 + sqlite3 (1.3.6)
241 227 state_machine (1.1.1)
242 228 stringex (1.3.2)
243 229 thor (0.14.6)
@@ -263,7 +249,6 @@ DEPENDENCIES
263 249 mysql2
264 250 routing-filter!
265 251 rspec-rails (~> 2.7)
266   - ruby-debug19
267 252 spree_auth (~> 1.0.3)
268 253 spree_multi_lingual!
269 254 sqlite3
5 app/models/option_type_decorator.rb
... ... @@ -0,0 +1,5 @@
  1 +module Spree
  2 + OptionType.class_eval do
  3 + translates :presentation
  4 + end
  5 +end
13 app/overrides/option_type_add_language_dropdown.rb
... ... @@ -0,0 +1,13 @@
  1 +Deface::Override.new(
  2 + :virtual_path => "spree/admin/option_types/index",
  3 + :insert_before => "div#new_option_type",
  4 + :text => '<%= render "spree/admin/shared/language_dropdown", :object => Spree::OptionType.new -%>',
  5 + :name => "option_type_add_language_dropdown"
  6 +)
  7 +
  8 +Deface::Override.new(
  9 + :virtual_path => "spree/admin/option_types/edit",
  10 + :insert_before => "fieldset",
  11 + :text => '<%= render "spree/admin/shared/language_dropdown", :object => @option_type -%>',
  12 + :name => "option_type_add_language_dropdown"
  13 +)
10 db/migrate/20120421183338_add_translations_to_option_types.rb
... ... @@ -0,0 +1,10 @@
  1 +class AddTranslationsToOptionTypes < ActiveRecord::Migration
  2 + def up
  3 + Spree::OptionType.create_translation_table!({:presentation => :string},
  4 + {:migrate_data => true})
  5 + end
  6 +
  7 + def down
  8 + Spree::OptionType.drop_translation_table!
  9 + end
  10 +end
4 lib/spree_multi_lingual/engine.rb
@@ -21,10 +21,6 @@ def self.activate
21 21 Dir.glob(File.join(File.dirname(__FILE__), "../../app/**/*_decorator*.rb")) do |c|
22 22 Rails.configuration.cache_classes ? require(c) : load(c)
23 23 end
24   -
25   - Dir.glob(File.join(File.dirname(__FILE__), "../../app/overrides/*.rb")) do |c|
26   - Rails.configuration.cache_classes ? require(c) : load(c)
27   - end
28 24 end
29 25
30 26 # after rails config/initializers loading, setup spree_multi_lingual's language by getting
24 spec/requests/option_types_spec.rb
... ... @@ -0,0 +1,24 @@
  1 +require 'spec_helper'
  2 +
  3 +feature "OptionType multi lingual", :js => true do
  4 + background do
  5 + sign_in_as! Factory(:admin_user)
  6 + visit spree.admin_option_types_path
  7 + end
  8 +
  9 + scenario "create successfully" do
  10 + click_link "new_option_type_link"
  11 + page.should have_button("Create")
  12 +
  13 + select "fr", :from => "spree_multi_lingual_dropdown"
  14 +
  15 + fill_in "option_type_name", :with => "size"
  16 + fill_in "option_type_presentation_fr", :with => "Taille"
  17 +
  18 + select "en", :from => "spree_multi_lingual_dropdown"
  19 + fill_in "option_type_presentation", :with => "Size"
  20 +
  21 + click_button "Create"
  22 + page.should have_content("successfully created!")
  23 + end
  24 +end

0 comments on commit 69e3b8d

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