@@ -0,0 +1,9 | |||
|
1 | class FixUsersCustomValues < ActiveRecord::Migration | |
|
2 | def self.up | |
|
3 | CustomValue.update_all("customized_type = 'Principal'", "customized_type = 'User'") | |
|
4 | end | |
|
5 | ||
|
6 | def self.down | |
|
7 | CustomValue.update_all("customized_type = 'User'", "customized_type = 'Principal'") | |
|
8 | end | |
|
9 | end |
@@ -12,19 +12,19 custom_values_007: | |||
|
12 | 12 | id: 7 |
|
13 | 13 | value: Stable |
|
14 | 14 | custom_values_001: |
|
15 |
customized_type: |
|
|
15 | customized_type: Principal | |
|
16 | 16 | custom_field_id: 4 |
|
17 | 17 | customized_id: 3 |
|
18 | 18 | id: 1 |
|
19 | 19 | value: "" |
|
20 | 20 | custom_values_002: |
|
21 |
customized_type: |
|
|
21 | customized_type: Principal | |
|
22 | 22 | custom_field_id: 4 |
|
23 | 23 | customized_id: 4 |
|
24 | 24 | id: 2 |
|
25 | 25 | value: 01 23 45 67 89 |
|
26 | 26 | custom_values_003: |
|
27 |
customized_type: |
|
|
27 | customized_type: Principal | |
|
28 | 28 | custom_field_id: 4 |
|
29 | 29 | customized_id: 2 |
|
30 | 30 | id: 3 |
@@ -18,7 +18,7 | |||
|
18 | 18 | require File.dirname(__FILE__) + '/../test_helper' |
|
19 | 19 | |
|
20 | 20 | class CustomValueTest < ActiveSupport::TestCase |
|
21 | fixtures :custom_fields | |
|
21 | fixtures :custom_fields, :custom_values, :users | |
|
22 | 22 | |
|
23 | 23 | def test_string_field_validation_with_blank_value |
|
24 | 24 | f = CustomField.new(:field_format => 'string') |
@@ -114,4 +114,10 class CustomValueTest < ActiveSupport::TestCase | |||
|
114 | 114 | v = CustomValue.new(:custom_field => field, :value => 'Not empty') |
|
115 | 115 | assert_equal 'Not empty', v.value |
|
116 | 116 | end |
|
117 | ||
|
118 | def test_sti_polymorphic_association | |
|
119 | # Rails uses top level sti class for polymorphic association. See #3978. | |
|
120 | assert !User.find(4).custom_values.empty? | |
|
121 | assert !CustomValue.find(2).customized.nil? | |
|
122 | end | |
|
117 | 123 | end |
General Comments 0
You need to be logged in to leave comments.
Login now