diff options
-rw-r--r-- | db/migrate/20091010093521_fix_users_custom_values.rb | 9 | ||||
-rw-r--r-- | test/fixtures/custom_values.yml | 6 | ||||
-rw-r--r-- | test/unit/custom_value_test.rb | 8 |
3 files changed, 19 insertions, 4 deletions
diff --git a/db/migrate/20091010093521_fix_users_custom_values.rb b/db/migrate/20091010093521_fix_users_custom_values.rb new file mode 100644 index 000000000..923c78fc0 --- /dev/null +++ b/db/migrate/20091010093521_fix_users_custom_values.rb @@ -0,0 +1,9 @@ +class FixUsersCustomValues < ActiveRecord::Migration + def self.up + CustomValue.update_all("customized_type = 'Principal'", "customized_type = 'User'") + end + + def self.down + CustomValue.update_all("customized_type = 'User'", "customized_type = 'Principal'") + end +end diff --git a/test/fixtures/custom_values.yml b/test/fixtures/custom_values.yml index 4e3eee4f9..783aa75c9 100644 --- a/test/fixtures/custom_values.yml +++ b/test/fixtures/custom_values.yml @@ -12,19 +12,19 @@ custom_values_007: id: 7 value: Stable custom_values_001: - customized_type: User + customized_type: Principal custom_field_id: 4 customized_id: 3 id: 1 value: "" custom_values_002: - customized_type: User + customized_type: Principal custom_field_id: 4 customized_id: 4 id: 2 value: 01 23 45 67 89 custom_values_003: - customized_type: User + customized_type: Principal custom_field_id: 4 customized_id: 2 id: 3 diff --git a/test/unit/custom_value_test.rb b/test/unit/custom_value_test.rb index 08492ef58..332c92644 100644 --- a/test/unit/custom_value_test.rb +++ b/test/unit/custom_value_test.rb @@ -18,7 +18,7 @@ require File.dirname(__FILE__) + '/../test_helper' class CustomValueTest < ActiveSupport::TestCase - fixtures :custom_fields + fixtures :custom_fields, :custom_values, :users def test_string_field_validation_with_blank_value f = CustomField.new(:field_format => 'string') @@ -114,4 +114,10 @@ class CustomValueTest < ActiveSupport::TestCase v = CustomValue.new(:custom_field => field, :value => 'Not empty') assert_equal 'Not empty', v.value end + + def test_sti_polymorphic_association + # Rails uses top level sti class for polymorphic association. See #3978. + assert !User.find(4).custom_values.empty? + assert !CustomValue.find(2).customized.nil? + end end |