aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/adapters/postgresql/cidr_test.rb
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2015-01-01 10:39:14 -0700
committerSean Griffin <sean@thoughtbot.com>2015-01-01 10:39:14 -0700
commit667b3ef873f5574d69d58f94de288d80615e3660 (patch)
treeeea8b5472ffeeca6b6a75c62e05b27e22f1802d6 /activerecord/test/cases/adapters/postgresql/cidr_test.rb
parentd08dc3795924b58a79d58358697df16602da9110 (diff)
downloadrails-667b3ef873f5574d69d58f94de288d80615e3660.tar.gz
rails-667b3ef873f5574d69d58f94de288d80615e3660.tar.bz2
rails-667b3ef873f5574d69d58f94de288d80615e3660.zip
Stop depending on columns for type information in PG quoting tests
A few of the tests weren't testing anything of value. The IP Address tests are testing the type, not behavior of the connection adapter. There are two CVE regression tests which are important, but don't have a good place to go, so I've left them alone for now, as they call `quote` and the focus right now is removing `column` from `type_cast`
Diffstat (limited to 'activerecord/test/cases/adapters/postgresql/cidr_test.rb')
-rw-r--r--activerecord/test/cases/adapters/postgresql/cidr_test.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/cidr_test.rb b/activerecord/test/cases/adapters/postgresql/cidr_test.rb
new file mode 100644
index 0000000000..54b679d3ab
--- /dev/null
+++ b/activerecord/test/cases/adapters/postgresql/cidr_test.rb
@@ -0,0 +1,25 @@
+require "cases/helper"
+require "ipaddr"
+
+module ActiveRecord
+ module ConnectionAdapters
+ class PostgreSQLAdapter
+ class CidrTest < ActiveRecord::TestCase
+ test "type casting IPAddr for database" do
+ type = OID::Cidr.new
+ ip = IPAddr.new("255.0.0.0/8")
+ ip2 = IPAddr.new("127.0.0.1")
+
+ assert_equal "255.0.0.0/8", type.type_cast_for_database(ip)
+ assert_equal "127.0.0.1/32", type.type_cast_for_database(ip2)
+ end
+
+ test "casting does nothing with non-IPAddr objects" do
+ type = OID::Cidr.new
+
+ assert_equal "foo", type.type_cast_for_database("foo")
+ end
+ end
+ end
+ end
+end