[#112] Fix failing raw version for postgres
This commit is contained in:
parent
d90102420d
commit
705c0db000
@ -64,7 +64,7 @@ module ChiliProject
|
|||||||
version = ActiveRecord::Base.connection.select_value('SELECT VERSION()')
|
version = ActiveRecord::Base.connection.select_value('SELECT VERSION()')
|
||||||
when :postgresql
|
when :postgresql
|
||||||
version = ActiveRecord::Base.connection.select_value('SELECT version()')
|
version = ActiveRecord::Base.connection.select_value('SELECT version()')
|
||||||
version.match(/^PostgreSQL (\S+)/i)[1] unless raw
|
raw ? version : version.match(/^PostgreSQL (\S+)/i)[1]
|
||||||
when :sqlite
|
when :sqlite
|
||||||
if SQLite3.const_defined? 'SQLITE_VERSION'
|
if SQLite3.const_defined? 'SQLITE_VERSION'
|
||||||
SQLite3::SQLITE_VERSION
|
SQLite3::SQLITE_VERSION
|
||||||
|
@ -36,4 +36,15 @@ class ChiliProject::DatabaseTest < ActiveSupport::TestCase
|
|||||||
should "return a version string" do
|
should "return a version string" do
|
||||||
assert_equal "3.6.12", ChiliProject::Database.version
|
assert_equal "3.6.12", ChiliProject::Database.version
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "return long version string for raw==true" do
|
||||||
|
ChiliProject::Database.stubs(:adapter_name).returns "PostgreSQL"
|
||||||
|
|
||||||
|
raw_version = "PostgreSQL 8.3.11 on x86_64-pc-linux-gnu, compiled by GCC gcc-4.3.real (Debian 4.3.2-1.1) 4.3.2"
|
||||||
|
ActiveRecord::Base.connection.stubs(:select_value).returns raw_version
|
||||||
|
|
||||||
|
assert_equal "8.3.11", ChiliProject::Database.version
|
||||||
|
assert_equal raw_version, ChiliProject::Database.version(true)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user