Skip to content

Commit

Permalink
code cleanup: detect db type via helpers rather than custom code
Browse files Browse the repository at this point in the history
  • Loading branch information
ronen committed Apr 20, 2016
1 parent 9544962 commit 792351d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions spec/named_schemas_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ def connection
end

before(:each) do
newdb = case connection.adapter_name
when /^mysql/i then "CREATE SCHEMA IF NOT EXISTS schema_plus_views_test2"
when /^postgresql/i then "CREATE SCHEMA schema_plus_views_test2"
when /^sqlite/i then "ATTACH ':memory:' AS schema_plus_views_test2"
newdb = case
when SchemaDev::Rspec::Helpers.mysql? then "CREATE SCHEMA IF NOT EXISTS schema_plus_views_test2"
when SchemaDev::Rspec::Helpers.postgresql? then "CREATE SCHEMA schema_plus_views_test2"
when SchemaDev::Rspec::Helpers.sqlite3? then "ATTACH ':memory:' AS schema_plus_views_test2"
end
begin
ActiveRecord::Base.connection.execute newdb
Expand All @@ -28,10 +28,10 @@ class User < ::ActiveRecord::Base ; end
end

connection.execute 'DROP TABLE IF EXISTS schema_plus_views_test2.users'
connection.execute 'CREATE TABLE schema_plus_views_test2.users (id ' + case connection.adapter_name
when /^mysql/i then "integer primary key auto_increment"
when /^postgresql/i then "serial primary key"
when /^sqlite/i then "integer primary key autoincrement"
connection.execute 'CREATE TABLE schema_plus_views_test2.users (id ' + case
when SchemaDev::Rspec::Helpers.mysql? then "integer primary key auto_increment"
when SchemaDev::Rspec::Helpers.postgresql? then "serial primary key"
when SchemaDev::Rspec::Helpers.sqlite3? then "integer primary key autoincrement"
end + ", login varchar(255))"
end

Expand Down

0 comments on commit 792351d

Please sign in to comment.