Skip to content

Commit

Permalink
make it testable /w rails 2 and 3 (and check it in although rails 3 t…
Browse files Browse the repository at this point in the history
…ests don't pass)
  • Loading branch information
clemens committed Sep 12, 2010
1 parent e235f77 commit cf4648c
Show file tree
Hide file tree
Showing 25 changed files with 434 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/delocalize/rails_ext/action_view.rb
Expand Up @@ -25,7 +25,7 @@ def to_input_field_tag(field_type, options = {})
hidden_for_integer = field_type == 'hidden' && column.type == :integer

# the number will be formatted only if it has no errors
if object.respond_to?(:errors) && !object.errors.invalid?(method_name)
if object.respond_to?(:errors) && !object.errors[method_name].try(:any?)
# we don't format integer hidden fields because this breaks nested_attributes
options[:value] = number_with_precision(value, opts) unless hidden_for_integer
end
Expand Down
95 changes: 95 additions & 0 deletions log/test.log
@@ -0,0 +1,95 @@
SQL (0.2ms) select sqlite_version(*)
SQL (0.5ms) CREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "released_on" date, "published_at" datetime, "cant_think_of_a_sensible_time_field" time, "price" decimal, "weight" float, "times_sold" integer, "some_value_with_default" decimal(20,2) DEFAULT 0)
SQL (0.2ms)  SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'

SQL (0.1ms) INSERT INTO "products" ("cant_think_of_a_sensible_time_field", "name", "price", "published_at", "released_on", "some_value_with_default", "times_sold", "weight") VALUES (NULL, NULL, 10.0, NULL, NULL, 0.0, NULL, NULL)
SQL (0.1ms) INSERT INTO "products" ("cant_think_of_a_sensible_time_field", "name", "price", "published_at", "released_on", "some_value_with_default", "times_sold", "weight") VALUES (NULL, NULL, NULL, NULL, NULL, 0.0, NULL, 10.0)
SQL (0.2ms) select sqlite_version(*)
SQL (0.4ms) CREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "released_on" date, "published_at" datetime, "cant_think_of_a_sensible_time_field" time, "price" decimal, "weight" float, "times_sold" integer, "some_value_with_default" decimal(20,2) DEFAULT 0)
SQL (0.2ms)  SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'

SQL (0.1ms) INSERT INTO "products" ("cant_think_of_a_sensible_time_field", "name", "price", "published_at", "released_on", "some_value_with_default", "times_sold", "weight") VALUES (NULL, NULL, 10.0, NULL, NULL, 0.0, NULL, NULL)
SQL (0.1ms) INSERT INTO "products" ("cant_think_of_a_sensible_time_field", "name", "price", "published_at", "released_on", "some_value_with_default", "times_sold", "weight") VALUES (NULL, NULL, NULL, NULL, NULL, 0.0, NULL, 10.0)
SQL (0.2ms) select sqlite_version(*)
SQL (0.4ms) CREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "released_on" date, "published_at" datetime, "cant_think_of_a_sensible_time_field" time, "price" decimal, "weight" float, "times_sold" integer, "some_value_with_default" decimal(20,2) DEFAULT 0)
SQL (0.2ms)  SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'

SQL (0.1ms) INSERT INTO "products" ("cant_think_of_a_sensible_time_field", "name", "price", "published_at", "released_on", "some_value_with_default", "times_sold", "weight") VALUES (NULL, NULL, NULL, NULL, NULL, 0.0, NULL, 10.0)
SQL (0.2ms) select sqlite_version(*)
SQL (0.8ms) CREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "released_on" date, "published_at" datetime, "cant_think_of_a_sensible_time_field" time, "price" decimal, "weight" float, "times_sold" integer, "some_value_with_default" decimal(20,2) DEFAULT 0)
SQL (0.2ms)  SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'

SQL (0.1ms) INSERT INTO "products" ("cant_think_of_a_sensible_time_field", "name", "price", "published_at", "released_on", "some_value_with_default", "times_sold", "weight") VALUES (NULL, NULL, NULL, NULL, NULL, 0.0, NULL, 10.0)
SQL (0.2ms) select sqlite_version(*)
SQL (0.7ms) CREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "released_on" date, "published_at" datetime, "cant_think_of_a_sensible_time_field" time, "price" decimal, "weight" float, "times_sold" integer, "some_value_with_default" decimal(20,2) DEFAULT 0)
SQL (0.2ms)  SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'

SQL (0.1ms) INSERT INTO "products" ("cant_think_of_a_sensible_time_field", "name", "price", "published_at", "released_on", "some_value_with_default", "times_sold", "weight") VALUES (NULL, NULL, NULL, NULL, NULL, 0.0, NULL, 10.0)
SQL (0.3ms) select sqlite_version(*)
SQL (0.4ms) CREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "released_on" date, "published_at" datetime, "cant_think_of_a_sensible_time_field" time, "price" decimal, "weight" float, "times_sold" integer, "some_value_with_default" decimal(20,2) DEFAULT 0)
SQL (0.2ms) select sqlite_version(*)
SQL (0.4ms) CREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "released_on" date, "published_at" datetime, "cant_think_of_a_sensible_time_field" time, "price" decimal, "weight" float, "times_sold" integer, "some_value_with_default" decimal(20,2) DEFAULT 0)
SQL (0.2ms) select sqlite_version(*)
SQL (0.5ms) CREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "released_on" date, "published_at" datetime, "cant_think_of_a_sensible_time_field" time, "price" decimal, "weight" float, "times_sold" integer, "some_value_with_default" decimal(20,2) DEFAULT 0)
SQL (0.2ms)  SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'

SQL (0.1ms) INSERT INTO "products" ("cant_think_of_a_sensible_time_field", "name", "price", "published_at", "released_on", "some_value_with_default", "times_sold", "weight") VALUES (NULL, NULL, NULL, NULL, NULL, 0.0, NULL, 10.0)
SQL (0.2ms) select sqlite_version(*)
SQL (0.8ms) CREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "released_on" date, "published_at" datetime, "cant_think_of_a_sensible_time_field" time, "price" decimal, "weight" float, "times_sold" integer, "some_value_with_default" decimal(20,2) DEFAULT 0)
SQL (0.2ms)  SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'

SQL (0.1ms) INSERT INTO "products" ("cant_think_of_a_sensible_time_field", "name", "price", "published_at", "released_on", "some_value_with_default", "times_sold", "weight") VALUES (NULL, NULL, NULL, NULL, NULL, 0.0, NULL, 10.0)
SQL (0.2ms) select sqlite_version(*)
SQL (0.5ms) CREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "released_on" date, "published_at" datetime, "cant_think_of_a_sensible_time_field" time, "price" decimal, "weight" float, "times_sold" integer, "some_value_with_default" decimal(20,2) DEFAULT 0)
SQL (0.2ms)  SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'

SQL (0.1ms) INSERT INTO "products" ("cant_think_of_a_sensible_time_field", "name", "price", "published_at", "released_on", "some_value_with_default", "times_sold", "weight") VALUES (NULL, NULL, 10.0, NULL, NULL, 0.0, NULL, NULL)
SQL (0.1ms) INSERT INTO "products" ("cant_think_of_a_sensible_time_field", "name", "price", "published_at", "released_on", "some_value_with_default", "times_sold", "weight") VALUES (NULL, NULL, NULL, NULL, NULL, 0.0, NULL, 10.0)
SQL (0.2ms) select sqlite_version(*)
SQL (0.4ms) CREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "released_on" date, "published_at" datetime, "cant_think_of_a_sensible_time_field" time, "price" decimal, "weight" float, "times_sold" integer, "some_value_with_default" decimal(20,2) DEFAULT 0)
SQL (0.2ms)  SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'

SQL (0.1ms) INSERT INTO "products" ("cant_think_of_a_sensible_time_field", "name", "price", "published_at", "released_on", "some_value_with_default", "times_sold", "weight") VALUES (NULL, NULL, 10.0, NULL, NULL, 0.0, NULL, NULL)
SQL (0.1ms) INSERT INTO "products" ("cant_think_of_a_sensible_time_field", "name", "price", "published_at", "released_on", "some_value_with_default", "times_sold", "weight") VALUES (NULL, NULL, NULL, NULL, NULL, 0.0, NULL, 10.0)
SQL (0.2ms) select sqlite_version(*)
SQL (0.4ms) CREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "released_on" date, "published_at" datetime, "cant_think_of_a_sensible_time_field" time, "price" decimal, "weight" float, "times_sold" integer, "some_value_with_default" decimal(20,2) DEFAULT 0)
SQL (0.2ms)  SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'

SQL (0.1ms) INSERT INTO "products" ("cant_think_of_a_sensible_time_field", "name", "price", "published_at", "released_on", "some_value_with_default", "times_sold", "weight") VALUES (NULL, NULL, 10.0, NULL, NULL, 0.0, NULL, NULL)
SQL (0.1ms) INSERT INTO "products" ("cant_think_of_a_sensible_time_field", "name", "price", "published_at", "released_on", "some_value_with_default", "times_sold", "weight") VALUES (NULL, NULL, NULL, NULL, NULL, 0.0, NULL, 10.0)
SQL (0.2ms) select sqlite_version(*)
SQL (0.4ms) CREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "released_on" date, "published_at" datetime, "cant_think_of_a_sensible_time_field" time, "price" decimal, "weight" float, "times_sold" integer, "some_value_with_default" decimal(20,2) DEFAULT 0)
SQL (0.2ms)  SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'

SQL (0.1ms) INSERT INTO "products" ("cant_think_of_a_sensible_time_field", "name", "price", "published_at", "released_on", "some_value_with_default", "times_sold", "weight") VALUES (NULL, NULL, 10.0, NULL, NULL, 0.0, NULL, NULL)
SQL (0.1ms) INSERT INTO "products" ("cant_think_of_a_sensible_time_field", "name", "price", "published_at", "released_on", "some_value_with_default", "times_sold", "weight") VALUES (NULL, NULL, NULL, NULL, NULL, 0.0, NULL, 10.0)
SQL (0.2ms) select sqlite_version(*)
SQL (0.4ms) CREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "released_on" date, "published_at" datetime, "cant_think_of_a_sensible_time_field" time, "price" decimal, "weight" float, "times_sold" integer, "some_value_with_default" decimal(20,2) DEFAULT 0)
SQL (0.2ms)  SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'

SQL (0.1ms) INSERT INTO "products" ("cant_think_of_a_sensible_time_field", "name", "price", "published_at", "released_on", "some_value_with_default", "times_sold", "weight") VALUES (NULL, NULL, 10.0, NULL, NULL, 0.0, NULL, NULL)
SQL (0.1ms) INSERT INTO "products" ("cant_think_of_a_sensible_time_field", "name", "price", "published_at", "released_on", "some_value_with_default", "times_sold", "weight") VALUES (NULL, NULL, NULL, NULL, NULL, 0.0, NULL, 10.0)
4 changes: 3 additions & 1 deletion test/delocalize_test.rb
Expand Up @@ -238,9 +238,11 @@ def setup
end

test "doesn't convert the value if field has errors" do
error_class = Rails.version =~ /^3/ ? 'field_with_errors' : 'fieldWithErrors'

@product = ProductWithValidation.new(:price => 'this is not a number')
@product.valid?
assert_dom_equal '<div class="fieldWithErrors"><input id="product_price" name="product[price]" size="30" type="text" value="this is not a number" /></div>',
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>),
text_field(:product, :price)
end

Expand Down
File renamed without changes.
File renamed without changes.
@@ -1,7 +1,7 @@
# Be sure to restart your server when you modify this file

# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION
RAILS_GEM_VERSION = '2.3.8' unless defined? RAILS_GEM_VERSION

# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit cf4648c

Please sign in to comment.