File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
lib/active_record/connection_adapters/postgresql/oid
test/cases/adapters/postgresql Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,12 @@ def serialize(value)
28
28
end
29
29
end
30
30
31
+ # TODO: Remove when IPAddr#== compares IPAddr#prefix. See
32
+ # https://github.com/ruby/ipaddr/issues/21
33
+ def changed? ( old_value , new_value , _new_value_before_type_cast )
34
+ super || old_value . prefix != new_value . prefix
35
+ end
36
+
31
37
def cast_value ( value )
32
38
if value . nil?
33
39
nil
Original file line number Diff line number Diff line change @@ -94,6 +94,18 @@ def test_schema_dump_with_shorthand
94
94
assert_match %r{t\. macaddr\s +"mac_address",\s +default: "ff:ff:ff:ff:ff:ff"} , output
95
95
end
96
96
97
+ def test_cidr_change_prefix
98
+ model = PostgresqlNetworkAddress . create ( cidr_address : "192.168.1.0/24" )
99
+ model . cidr_address = "192.168.1.0/24"
100
+ assert_not_predicate model , :changed?
101
+
102
+ model . cidr_address = "192.168.2.0/24"
103
+ assert_predicate model , :changed?
104
+
105
+ model . cidr_address = "192.168.1.0/25"
106
+ assert_predicate model , :changed?
107
+ end
108
+
97
109
def test_mac_address_change_case_does_not_mark_dirty
98
110
model = PostgresqlNetworkAddress . create ( mac_address : "Ab:Cd:Ef:01:02:03" )
99
111
model . mac_address = model . mac_address . swapcase
You can’t perform that action at this time.
0 commit comments