diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-08-22 14:54:45 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-08-22 14:54:45 -0300 |
commit | 91bd6121d8590268700476d57080ccfcaf6c7c44 (patch) | |
tree | eb178fc64bc85bec4769f6074ce51fdbf9cf3ac6 /activerecord/test/cases | |
parent | 50e47a3711101e4294334ab27b7502dfd0228ef2 (diff) | |
parent | af16fd57933e092067b8e1ff13e2553fc758be27 (diff) | |
download | rails-91bd6121d8590268700476d57080ccfcaf6c7c44.tar.gz rails-91bd6121d8590268700476d57080ccfcaf6c7c44.tar.bz2 rails-91bd6121d8590268700476d57080ccfcaf6c7c44.zip |
Merge pull request #15932 from joseluistorres/issue-11957-uuids
adding the exception RecordNotFound to UUID find #11957
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/adapters/postgresql/uuid_test.rb | 14 | ||||
-rw-r--r-- | activerecord/test/cases/helper.rb | 2 |
2 files changed, 15 insertions, 1 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/uuid_test.rb b/activerecord/test/cases/adapters/postgresql/uuid_test.rb index 66006d718f..6e7920b814 100644 --- a/activerecord/test/cases/adapters/postgresql/uuid_test.rb +++ b/activerecord/test/cases/adapters/postgresql/uuid_test.rb @@ -252,5 +252,19 @@ class PostgresqlUUIDTestInverseOf < ActiveRecord::TestCase comment = post.uuid_comments.create! assert post.uuid_comments.find(comment.id) end + + def test_find_with_uuid + UuidPost.create! + assert_raise ActiveRecord::RecordNotFound do + UuidPost.find(123456) + end + + end + + def test_find_by_with_uuid + UuidPost.create! + assert_nil UuidPost.find_by(id: 789) + end end + end diff --git a/activerecord/test/cases/helper.rb b/activerecord/test/cases/helper.rb index e43b796237..209ef597db 100644 --- a/activerecord/test/cases/helper.rb +++ b/activerecord/test/cases/helper.rb @@ -117,7 +117,7 @@ end def enable_uuid_ossp!(connection) return false unless connection.supports_extensions? - return true if connection.extension_enabled?('uuid-ossp') + return connection.reconnect! if connection.extension_enabled?('uuid-ossp') connection.enable_extension 'uuid-ossp' connection.commit_db_transaction |