delocalize 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -8,3 +8,11 @@ require File.expand_path(File.join(File.dirname(__FILE__), 'tasks/testing'))
8
8
 
9
9
  desc 'Default: run unit tests.'
10
10
  task :default => :test
11
+
12
+ desc 'Run unit tests against Rails 2 and 3.'
13
+ task :test_all do
14
+ puts "\n * Running tests against Rails 2...\n\n"
15
+ sh "rake test"
16
+ puts "\n * Running tests against Rails 3...\n\n"
17
+ sh "rake test RAILS_VERSION=3"
18
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 0.2.3
@@ -57,7 +57,7 @@ module Delocalize
57
57
  gsub('%a', "(#{Date::ABBR_DAYNAMES.join('|')})"). # short day name
58
58
  gsub('%Y', "(\\d{4})"). # long year
59
59
  gsub('%y', "(\\d{2})"). # short year
60
- gsub('%e', "(\\w?\\d{1,2})"). # short day
60
+ gsub('%e', "(\\s?\\d{1,2})"). # short day
61
61
  gsub('%d', "(\\d{2})"). # full day
62
62
  gsub('%H', "(\\d{2})"). # hour (24)
63
63
  gsub('%M', "(\\d{2})"). # minute
@@ -25,7 +25,7 @@ ActionView::Helpers::InstanceTag.class_eval do
25
25
  hidden_for_integer = field_type == 'hidden' && column.type == :integer
26
26
 
27
27
  # the number will be formatted only if it has no errors
28
- if object.respond_to?(:errors) && !object.errors.invalid?(method_name)
28
+ if object.respond_to?(:errors) && !object.errors[method_name].try(:any?)
29
29
  # we don't format integer hidden fields because this breaks nested_attributes
30
30
  options[:value] = number_with_precision(value, opts) unless hidden_for_integer
31
31
  end
@@ -45,12 +45,7 @@ ActiveRecord::Base.class_eval do
45
45
  value
46
46
  end
47
47
  alias_method_chain :convert_number_column_value, :localization
48
- end
49
-
50
- # The dirty module has been moved to ActiveModel in Rails 3
51
- dirty_module = defined?(ActiveRecord::Dirty) ? ActiveRecord::Dirty : ActiveModel::Dirty
52
48
 
53
- dirty_module.module_eval do
54
49
  def field_changed?(attr, old, value)
55
50
  if column = column_for_attribute(attr)
56
51
  if column.number? && column.null && (old.nil? || old == 0) && value.blank?
@@ -238,9 +238,11 @@ class DelocalizeActionViewTest < ActionView::TestCase
238
238
  end
239
239
 
240
240
  test "doesn't convert the value if field has errors" do
241
+ error_class = Rails.version =~ /^3/ ? 'field_with_errors' : 'fieldWithErrors'
242
+
241
243
  @product = ProductWithValidation.new(:price => 'this is not a number')
242
244
  @product.valid?
243
- assert_dom_equal '<div class="fieldWithErrors"><input id="product_price" name="product[price]" size="30" type="text" value="this is not a number" /></div>',
245
+ assert_dom_equal %(<div class="#{error_class}"><input id="product_price" name="product[price]" size="30" type="text" value="this is not a number" /></div>),
244
246
  text_field(:product, :price)
245
247
  end
246
248
 
@@ -1,7 +1,7 @@
1
1
  # Be sure to restart your server when you modify this file
2
2
 
3
3
  # Specifies gem version of Rails to use when vendor/rails is not present
4
- RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION
4
+ RAILS_GEM_VERSION = '2.3.8' unless defined? RAILS_GEM_VERSION
5
5
 
6
6
  # Bootstrap the Rails environment, frameworks, and default configuration
7
7
  require File.join(File.dirname(__FILE__), 'boot')
@@ -0,0 +1,3 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,44 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ # If you have a Gemfile, require the gems listed there, including any gems
6
+ # you've limited to :test, :development, or :production.
7
+ Bundler.require(:default, Rails.env) if defined?(Bundler)
8
+
9
+ module Rails3App
10
+ class Application < Rails::Application
11
+ # Settings in config/environments/* take precedence over those specified here.
12
+ # Application configuration should go into files in config/initializers
13
+ # -- all .rb files in that directory are automatically loaded.
14
+
15
+ # Custom directories with classes and modules you want to be autoloadable.
16
+ # config.autoload_paths += %W(#{config.root}/extras)
17
+
18
+ # Only load the plugins named here, in the order given (default is alphabetical).
19
+ # :all can be used as a placeholder for all plugins not explicitly named.
20
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
21
+
22
+ # Activate observers that should always be running.
23
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
24
+
25
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
26
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
27
+ # config.time_zone = 'Central Time (US & Canada)'
28
+
29
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
30
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
31
+ # config.i18n.default_locale = :de
32
+
33
+ # JavaScript files you want as :defaults (application.js is always included).
34
+ # config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
35
+
36
+ config.paths.config.database = File.expand_path(File.dirname(__FILE__) + '../../../database.yml')
37
+
38
+ # Configure the default encoding used in templates for Ruby 1.9.
39
+ config.encoding = "utf-8"
40
+
41
+ # Configure sensitive parameters which will be filtered from the log file.
42
+ config.filter_parameters += [:password]
43
+ end
44
+ end
@@ -0,0 +1,13 @@
1
+ require 'rubygems'
2
+
3
+ # Set up gems listed in the Gemfile.
4
+ gemfile = File.expand_path('../../Gemfile', __FILE__)
5
+ begin
6
+ ENV['BUNDLE_GEMFILE'] = gemfile
7
+ require 'bundler'
8
+ Bundler.setup
9
+ rescue Bundler::GemNotFound => e
10
+ STDERR.puts e.message
11
+ STDERR.puts "Try running `bundle install`."
12
+ exit!
13
+ end if File.exist?(gemfile)
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ Rails3App::Application.initialize!
@@ -0,0 +1,35 @@
1
+ Rails3App::Application.configure do
2
+ # Settings specified here will take precedence over those in config/environment.rb
3
+
4
+ # The test environment is used exclusively to run your application's
5
+ # test suite. You never need to work with it otherwise. Remember that
6
+ # your test database is "scratch space" for the test suite and is wiped
7
+ # and recreated between test runs. Don't rely on the data there!
8
+ config.cache_classes = true
9
+
10
+ # Log error messages when you accidentally call methods on nil.
11
+ config.whiny_nils = true
12
+
13
+ # Show full error reports and disable caching
14
+ config.consider_all_requests_local = true
15
+ config.action_controller.perform_caching = false
16
+
17
+ # Raise exceptions instead of rendering exception templates
18
+ config.action_dispatch.show_exceptions = false
19
+
20
+ # Disable request forgery protection in test environment
21
+ config.action_controller.allow_forgery_protection = false
22
+
23
+ # Tell Action Mailer not to deliver emails to the real world.
24
+ # The :test delivery method accumulates sent emails in the
25
+ # ActionMailer::Base.deliveries array.
26
+ config.action_mailer.delivery_method = :test
27
+
28
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
29
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
30
+ # like if you have constraints or database-specific column types
31
+ # config.active_record.schema_format = :sql
32
+
33
+ # Print deprecation notices to the stderr
34
+ config.active_support.deprecation = :stderr
35
+ end
@@ -1,14 +1,15 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  ENV["RAILS_ENV"] = "test"
4
- require File.expand_path(File.join(File.dirname(__FILE__), 'rails_app/config/environment'))
5
- require 'test_help'
4
+ rails_version = ENV["RAILS_VERSION"] || 2
6
5
 
7
- require 'rubygems'
8
- require 'active_record'
9
- require 'active_record/test_case'
10
- require 'action_view'
11
- require 'action_view/test_case'
6
+ if rails_version.to_i == 2
7
+ require File.expand_path(File.join(File.dirname(__FILE__), "rails2_app/config/environment"))
8
+ require 'test_help'
9
+ else
10
+ require File.expand_path(File.join(File.dirname(__FILE__), "rails3_app/config/environment"))
11
+ require 'rails/test_help'
12
+ end
12
13
 
13
14
  I18n.backend.store_translations :de, {
14
15
  :date => {
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 2
9
- version: 0.2.2
8
+ - 3
9
+ version: 0.2.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Clemens Kofler
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-06-26 00:00:00 +02:00
17
+ date: 2010-10-21 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies: []
20
20
 
@@ -80,11 +80,17 @@ specification_version: 3
80
80
  summary: Localized date/time and number parsing
81
81
  test_files:
82
82
  - test/delocalize_test.rb
83
- - test/rails_app/app/controllers/application_controller.rb
84
- - test/rails_app/config/boot.rb
85
- - test/rails_app/config/environment.rb
86
- - test/rails_app/config/environments/test.rb
87
- - test/rails_app/config/initializers/new_rails_defaults.rb
88
- - test/rails_app/config/initializers/session_store.rb
89
- - test/rails_app/config/routes.rb
83
+ - test/rails2_app/app/controllers/application_controller.rb
84
+ - test/rails2_app/config/boot.rb
85
+ - test/rails2_app/config/environment.rb
86
+ - test/rails2_app/config/environments/test.rb
87
+ - test/rails2_app/config/initializers/new_rails_defaults.rb
88
+ - test/rails2_app/config/initializers/session_store.rb
89
+ - test/rails2_app/config/routes.rb
90
+ - test/rails3_app/app/controllers/application_controller.rb
91
+ - test/rails3_app/app/helpers/application_helper.rb
92
+ - test/rails3_app/config/application.rb
93
+ - test/rails3_app/config/boot.rb
94
+ - test/rails3_app/config/environment.rb
95
+ - test/rails3_app/config/environments/test.rb
90
96
  - test/test_helper.rb