Skip to content

Commit

Permalink
Update test environment and doc.
Browse files Browse the repository at this point in the history
- Bump rails_i18n from 0.7.3 to 4.0.1
- Bump dev dependencies and move them to gemspec.
- Removed 2 year old capybara connection hack and re-introduced
database_cleaner.
- Update spec syntax.
- Update README.
- Use .add_routes
- Add badges for Travis and Code Climate.

Fixes #377
  • Loading branch information
futhr authored and radar committed Mar 4, 2014
1 parent 7b38ab5 commit 2dd951e
Show file tree
Hide file tree
Showing 22 changed files with 174 additions and 138 deletions.
1 change: 1 addition & 0 deletions .rspec
@@ -0,0 +1 @@
--color
3 changes: 2 additions & 1 deletion .travis.yml
@@ -1,9 +1,10 @@
language: ruby
before_script:
- sh -e /etc/init.d/xvfb start
- export DISPLAY=:99.0
- bundle exec rake test_app

script: bundle exec rspec spec
rvm:
- 1.9.3
- 2.0.0
- 2.1.0
15 changes: 0 additions & 15 deletions Gemfile
@@ -1,20 +1,5 @@
source 'http://rubygems.org'

group :assets do
gem 'coffee-rails', '~> 4.0.0'
gem 'sass-rails', '~> 4.0.0'
end

gem 'pg'

group :test do
gem 'rspec'
gem 'i18n-spec', '~> 0.4.0'
gem 'factory_girl_rails', '~> 4.2.1'
gem 'capybara', '~> 2.1.0'
gem 'selenium-webdriver', '~> 2.34'
end

gem 'spree', github: 'spree/spree', branch: 'master'

gemspec
2 changes: 1 addition & 1 deletion LICENSE → LICENSE.md
@@ -1,4 +1,4 @@
Copyright Spree Commerce Inc. and other contributors. (c) 2013 Sean Schofield
Copyright Spree Commerce Inc. and other contributors. (c) 2014 Sean Schofield
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
Expand Down
55 changes: 40 additions & 15 deletions README.md
@@ -1,5 +1,8 @@
# Spree Internationalization

[![Build Status](https://travis-ci.org/spree/spree_i18n.png?branch=master)](https://travis-ci.org/spree/spree_i18n)
[![Code Climate](https://codeclimate.com/github/spree/spree_i18n.png)](https://codeclimate.com/github/spree/spree_i18n)

This is the Internationalization project for [Spree Commerce][1]

See the [official Internationalization documentation][2] for more details.
Expand All @@ -8,10 +11,10 @@ Happy translating!

## Installation

Add the following to your `Gemfile`.
Add the following to your `Gemfile`:

```ruby
gem 'spree_i18n', github: 'spree/spree_i18n'
gem 'spree_i18n', github: 'spree/spree_i18n', branch: 'master'
```

Run `bundle install`
Expand All @@ -34,10 +37,10 @@ This will insert this lines on your spree manifest files:

## Model Translations

We've added support for translating models. The feature uses the [globalize3][3]
We've added support for translating models. The feature uses the [Globalize][3]
gem to localize model data. So far the following models are translatable:

Product, Promotion, OptionType, Taxonomy, Taxon and Property.
Product, Promotion, OptionType, Taxonomy, Taxon and Property.

Start you server and you should see a TRANSLATIONS link or a flag icon on each
admin section that supports this feature.
Expand All @@ -51,7 +54,7 @@ SpreeI18n::Config.available_locales = [:en, :es, :'pt-BR'] # displayed on transl
SpreeI18n::Config.supported_locales = [:en, :'pt-BR'] # displayed on frontend select box
```

ps. please use symbols, not strings. e.g. :'pt-BR' not just 'pt-BR'. Otherwise
ps. please use symbols, not strings. e.g. `:'pt-BR'` not just `'pt-BR'`. Otherwise
you may get unexpected errors

Or if you prefer they're also available on the admin UI general settings section.
Expand All @@ -61,19 +64,41 @@ from your Gemfile, add some records and then add spree_i18n gem back you might g
errors like ``undefined method for nilClass`` because Globalize will try fetch
translations that do not exist.*

## Running the tests
## Contributing

In the spirit of [free software][7], **everyone** is encouraged to help improve this project.

Here are some ways *you* can contribute:

* by using prerelease versions
* by reporting [bugs][8]
* by suggesting new features
* by writing [translations][9]
* by writing or editing documentation
* by writing specifications
* by writing code (*no patch is too small*: fix typos, add comments, clean up inconsistent whitespace)
* by refactoring code
* by resolving [issues][8]
* by reviewing patches

If you would like to run the tests of this project, follow these steps:
Starting point:

1. Clone this repo using `git clone git://github.com/spree/spree_i18n`
2. Change into the directory and run `bundle exec rake test_app` to generate a dummy application.
3. Run `bundle exec rspec spec` to run the tests.
* Fork the repo
* Clone your repo
* Run `bundle install`
* Run `bundle exec rake test_app` to create the test application in `spec/test_app`
* Make your changes
* Ensure specs pass by running `bundle exec rspec spec`
* Submit your pull request

Copyright (c) 2013 Spree Commerce Inc. and other contributors. released under the [New BSD License][6]
Copyright (c) 2014 [Spree Commerce Inc][3]. and other [contributors][5]. released under the [New BSD License][6]

[1]: http://spreecommerce.com
[2]: http://guides.spreecommerce.com/i18n.html
[3]: https://github.com/svenfuchs/globalize3
[6]: https://github.com/spree/spree_i18n/tree/master/LICENSE
[7]: https://github.com/globalize/globalize
[8]: https://github.com/airblade/paper_trail
[3]: https://github.com/globalize/globalize
[4]: https://github.com/spree
[5]: https://github.com/spree/spree_i18n/graphs/contributors
[6]: https://github.com/spree/spree_i18n/blob/master/LICENSE.md
[7]: http://www.fsf.org/licensing/essays/free-sw.html
[8]: https://github.com/spree/spree_i18n/issues
[9]: http://www.localeapp.com/projects/4605
@@ -1,15 +1,15 @@
Spree::Admin::OptionValuesController.class_eval do
def update
option_value = Spree::OptionValue.find(params[:id])
option_value.update update_option_value_attribute
option_value.update update_option_value_attribute
redirect_to spree.edit_admin_option_type_path(option_value.option_type)
end

private
def update_option_value_attribute
params.require(:option_value).permit(permitted_params)
end

def permitted_params
[:name, :presentation,:translations_attributes => [:id,:locale, :name, :presentation]]
end
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/form_builder_globalize_patch.rb
Expand Up @@ -9,7 +9,7 @@ class FormBuilder
#
# Use it like this:
#
# <h1>Editing post</h1>
# <h1>Editing post</h1>
#
# <% form_for(@post) do |f| %>
# <%= f.error_messages %>
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
@@ -1,4 +1,4 @@
Spree::Core::Engine.routes.draw do
Spree::Core::Engine.add_routes do
post '/locale/set', :to => 'locale#set', :defaults => { :format => :json }, :as => :set_locale

namespace :admin do
Expand Down
Expand Up @@ -3,7 +3,7 @@ def up
params = { :name => :string, :presentation => :string }
Spree::OptionValue.create_translation_table!(params, { :migrate_data => true })
end

def down
Spree::OptionValue.drop_translation_table! :migrate_data => true
end
Expand Down
4 changes: 2 additions & 2 deletions lib/generators/spree_i18n/install/install_generator.rb
Expand Up @@ -14,12 +14,12 @@ def add_stylesheets
end

def add_migrations
run 'rake railties:install:migrations FROM=spree_i18n'
run 'bundle exec rake railties:install:migrations FROM=spree_i18n'
end

def run_migrations
if options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask "Would you like to run the migrations now? [Y/n]")
run 'rake db:migrate'
run 'bundle exec rake db:migrate'
else
puts "Skiping rake db:migrate, don't forget to run it!"
end
Expand Down
1 change: 1 addition & 0 deletions lib/spree_i18n.rb
Expand Up @@ -2,3 +2,4 @@
require 'spree_core'
require 'spree_i18n/engine'
require 'spree/i18n_utils'
require 'coffee_script'
2 changes: 1 addition & 1 deletion script/rails
@@ -1,4 +1,4 @@
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
#!/usr/bin/env ruby

ENGINE_ROOT = File.expand_path('../..', __FILE__)
ENGINE_PATH = File.expand_path('../../lib/spree_i18n/engine', __FILE__)
Expand Down
6 changes: 3 additions & 3 deletions spec/controllers/locales_controller_spec.rb
@@ -1,22 +1,22 @@
require 'spec_helper'

describe Spree::HomeController do
before(:each) do
before do
reset_spree_preferences
SpreeI18n::Config.supported_locales = [:en, :es]
end

context "tries not supported fr locale" do
it "falls back do default locale" do
get :index, { use_route: :spree }, { locale: 'fr' }
I18n.locale.should == :en
expect(I18n.locale).to eq :en
end
end

context "tries supported es locale" do
it "falls back do default locale" do
get :index, { use_route: :spree }, { locale: 'es' }
I18n.locale.should == :es
expect(I18n.locale).to eq :es
end
end
end

0 comments on commit 2dd951e

Please sign in to comment.