diff options
author | Robert Speicher <rspeicher@gmail.com> | 2016-02-15 22:13:47 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2016-02-15 22:13:47 +0300 |
commit | 447568d15f9ec2d47a15fc04aeb2cb507cd6a55c (patch) | |
tree | 92e9a5d34f93e63535661ffb89f59db28b59cdac /spec | |
parent | c29517aaf420b0d83f21d468b371260f4887cf00 (diff) |
Fix undefined method `postgresql?` during migration
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/database_spec.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/lib/gitlab/database_spec.rb b/spec/lib/gitlab/database_spec.rb index bd8688fefa1..d0a447753b7 100644 --- a/spec/lib/gitlab/database_spec.rb +++ b/spec/lib/gitlab/database_spec.rb @@ -1,5 +1,9 @@ require 'spec_helper' +class MigrationTest + include Gitlab::Database +end + describe Gitlab::Database, lib: true do # These are just simple smoke tests to check if the methods work (regardless # of what they may return). @@ -34,4 +38,32 @@ describe Gitlab::Database, lib: true do 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 |