Commit c96b31b7 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'rs-gitlab-database-module' into 'master'

Fix undefined method `postgresql?` during migration

See merge request !2820
parents c29517aa 447568d1
...@@ -17,7 +17,7 @@ module Gitlab ...@@ -17,7 +17,7 @@ module Gitlab
end end
def true_value def true_value
if self.class.postgresql? if Gitlab::Database.postgresql?
"'t'" "'t'"
else else
1 1
...@@ -25,7 +25,7 @@ module Gitlab ...@@ -25,7 +25,7 @@ module Gitlab
end end
def false_value def false_value
if self.class.postgresql? if Gitlab::Database.postgresql?
"'f'" "'f'"
else else
0 0
...@@ -47,9 +47,5 @@ module Gitlab ...@@ -47,9 +47,5 @@ module Gitlab
row.first row.first
end end
end end
def connection
self.class.connection
end
end end
end end
require 'spec_helper' require 'spec_helper'
class MigrationTest
include Gitlab::Database
end
describe Gitlab::Database, lib: true do describe Gitlab::Database, lib: true do
# These are just simple smoke tests to check if the methods work (regardless # These are just simple smoke tests to check if the methods work (regardless
# of what they may return). # of what they may return).
...@@ -34,4 +38,32 @@ describe Gitlab::Database, lib: true do ...@@ -34,4 +38,32 @@ describe Gitlab::Database, lib: true do
end end
end end
end end
describe '#true_value' do
it 'returns correct value for PostgreSQL' do
expect(described_class).to receive(:postgresql?).and_return(true)
expect(MigrationTest.new.true_value).to eq "'t'"
end
it 'returns correct value for MySQL' do
expect(described_class).to receive(:postgresql?).and_return(false)
expect(MigrationTest.new.true_value).to eq 1
end
end
describe '#false_value' do
it 'returns correct value for PostgreSQL' do
expect(described_class).to receive(:postgresql?).and_return(true)
expect(MigrationTest.new.false_value).to eq "'f'"
end
it 'returns correct value for MySQL' do
expect(described_class).to receive(:postgresql?).and_return(false)
expect(MigrationTest.new.false_value).to eq 0
end
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment