Permalink
Browse files

reset column information after fiddling with `Encoding.default_internal`

This solves order depndent problems in `base_test.rb`. The leaked column
information crashed test cases using the `Weird` class later on:

```
  2) Error:
BasicsTest#test_group_weirds_by_from:
SyntaxError: /Users/senny/Projects/rails/activemodel/lib/active_model/attribute_methods.rb:387: invalid hex escape
... attribute_before_type_cast("\x{A4CA}\x{A4DE}\x{A4A8}", *arg...
...                               ^
/Users/senny/Projects/rails/activemodel/lib/active_model/attribute_methods.rb:387: invalid hex escape
...te_before_type_cast("\x{A4CA}\x{A4DE}\x{A4A8}", *args)
...                               ^
/Users/senny/Projects/rails/activemodel/lib/active_model/attribute_methods.rb:387: invalid hex escape
...e_type_cast("\x{A4CA}\x{A4DE}\x{A4A8}", *args)
...                               ^
    /Users/senny/Projects/rails/activemodel/lib/active_model/attribute_methods.rb:385:in `module_eval'
    /Users/senny/Projects/rails/activemodel/lib/active_model/attribute_methods.rb:385:in `define_proxy_call'
    /Users/senny/Projects/rails/activemodel/lib/active_model/attribute_methods.rb:294:in `block in define_attribute_method'
    /Users/senny/Projects/rails/activemodel/lib/active_model/attribute_methods.rb:285:in `each'
    /Users/senny/Projects/rails/activemodel/lib/active_model/attribute_methods.rb:285:in `define_attribute_method'
    /Users/senny/Projects/rails/activemodel/lib/active_model/attribute_methods.rb:252:in `block in define_attribute_methods'
    /Users/senny/Projects/rails/activemodel/lib/active_model/attribute_methods.rb:252:in `each'
    /Users/senny/Projects/rails/activemodel/lib/active_model/attribute_methods.rb:252:in `define_attribute_methods'
    /Users/senny/Projects/rails/activerecord/lib/active_record/attribute_methods.rb:72:in `block in define_attribute_methods'
    /Users/senny/.rbenv/versions/2.0.0-p353/lib/ruby/2.0.0/mutex_m.rb:73:in `synchronize'
    /Users/senny/.rbenv/versions/2.0.0-p353/lib/ruby/2.0.0/mutex_m.rb:73:in `mu_synchronize'
    /Users/senny/Projects/rails/activerecord/lib/active_record/attribute_methods.rb:69:in `define_attribute_methods'
    /Users/senny/Projects/rails/activerecord/lib/active_record/attribute_methods.rb:174:in `method_missing'
    /Users/senny/Projects/rails/activerecord/lib/active_record/attribute_assignment.rb:45:in `public_send'
    /Users/senny/Projects/rails/activerecord/lib/active_record/attribute_assignment.rb:45:in `_assign_attribute'
    /Users/senny/Projects/rails/activerecord/lib/active_record/attribute_assignment.rb:32:in `block in assign_attributes'
    /Users/senny/Projects/rails/activerecord/lib/active_record/attribute_assignment.rb:26:in `each'
    /Users/senny/Projects/rails/activerecord/lib/active_record/attribute_assignment.rb:26:in `assign_attributes'
    /Users/senny/Projects/rails/activerecord/lib/active_record/core.rb:458:in `init_attributes'
    /Users/senny/Projects/rails/activerecord/lib/active_record/core.rb:191:in `initialize'
    /Users/senny/Projects/rails/activerecord/lib/active_record/inheritance.rb:30:in `new'
    /Users/senny/Projects/rails/activerecord/lib/active_record/inheritance.rb:30:in `new'
    /Users/senny/Projects/rails/activerecord/lib/active_record/persistence.rb:33:in `create'
    test/cases/base_test.rb:646:in `test_group_weirds_by_from'
```
  • Loading branch information...
1 parent fca8b03 commit 6eab530429ed7573550931b259759168065ac0af @senny senny committed Jan 15, 2014
Showing with 1 addition and 0 deletions.
  1. +1 −0 activerecord/test/cases/base_test.rb
@@ -626,6 +626,7 @@ def test_respect_internal_encoding
assert_equal ["EUC-JP"], Weird.columns.map {|c| c.name.encoding.name }.uniq
ensure
silence_warnings { Encoding.default_internal = old_default_internal }
+ Weird.reset_column_information
end
end

0 comments on commit 6eab530

Please sign in to comment.