Skip to content

Commit

Permalink
itest
Browse files Browse the repository at this point in the history
  • Loading branch information
seuros committed Jan 17, 2024
1 parent 3af1cf8 commit f0f0cc0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
8 changes: 3 additions & 5 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,16 @@
}
}

puts "Testing with #{ActiveRecord::Base.configurations}"

# Configure ActiveRecord
ActiveRecord::Migration.verbose = false
ActiveRecord::Base.table_name_prefix = ENV['DB_PREFIX'].to_s
ActiveRecord::Base.table_name_suffix = ENV['DB_SUFFIX'].to_s
ActiveRecord::Base.establish_connection

def env_db
@env_db ||= if ActiveRecord::Base.respond_to?(:connection_db_config)
ActiveRecord::Base.connection_db_config.adapter
else
ActiveRecord::Base.connection_config[:adapter]
end.to_sym
@env_db ||= ActiveRecord::Base.connection_db_config.adapter.to_sym
end

# Use in specs to skip some tests
Expand Down
5 changes: 2 additions & 3 deletions test/closure_tree/model_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
end
end

describe "multi database support" do
describe 'multi database support' do
it 'should have a different connection for menu items' do
# These 2 models are in the same database
assert_equal Tag.connection, Metal.connection
Expand All @@ -20,5 +20,4 @@
# The hierarchy table is in the same database
assert_equal MenuItem.connection, MenuItemHierarchy.connection
end

end
end
3 changes: 2 additions & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
}
}

puts "Testing with #{ActiveRecord::Base.configurations}"

ENV['WITH_ADVISORY_LOCK_PREFIX'] ||= SecureRandom.hex

ActiveRecord::Base.establish_connection

def env_db
@env_db ||= ActiveRecord::Base.connection_db_config.adapter.to_sym
Expand Down

0 comments on commit f0f0cc0

Please sign in to comment.