active_record_host_pool 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -67,7 +67,7 @@ module ActiveRecordHostPool
67
67
  end
68
68
 
69
69
  def _pool_key
70
- [@config[:host], @config[:port], @config[:socket]]
70
+ [@config[:host], @config[:port], @config[:socket], @config[:username]]
71
71
  end
72
72
 
73
73
  def _connection_pool
@@ -35,3 +35,13 @@ test_host_2_db_4:
35
35
  host: 127.0.0.1
36
36
  port: 3306
37
37
  reconnect: true
38
+
39
+ test_host_2_db_5:
40
+ adapter: mysql
41
+ encoding: utf8
42
+ database: arhp_test_4
43
+ username: snoopy
44
+ password:
45
+ host: 127.0.0.1
46
+ port: 3306
47
+ reconnect: true
@@ -34,7 +34,7 @@ class ActiveSupport::TestCase
34
34
 
35
35
  def arhp_drop_databases
36
36
  ActiveRecord::Base.configurations.each do |name, conf|
37
- ActiveRecord::Base.connection.execute("DROP DATABASE #{conf['database']}")
37
+ ActiveRecord::Base.connection.execute("DROP DATABASE if exists #{conf['database']}")
38
38
  end
39
39
  end
40
40
 
@@ -60,6 +60,11 @@ class ActiveSupport::TestCase
60
60
  set_table_name "tests"
61
61
  establish_connection("test_host_2_db_4")
62
62
  end
63
+
64
+ class Test5 < ActiveRecord::Base
65
+ set_table_name "tests"
66
+ establish_connection("test_host_2_db_5")
67
+ end
63
68
  EOL
64
69
  end
65
70
 
@@ -15,6 +15,10 @@ class ActiveRecordHostPoolTest < ActiveSupport::TestCase
15
15
  assert(Test1.connection.raw_connection != Test4.connection.raw_connection)
16
16
  end
17
17
 
18
+ def test_models_without_matching_usernames_should_not_share_a_connection
19
+ assert(Test4.connection.raw_connection != Test5.connection.raw_connection)
20
+ end
21
+
18
22
  def test_should_select_on_correct_database
19
23
  action_should_use_correct_database(:select_all, "select 1")
20
24
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record_host_pool
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 0
10
- version: 0.5.0
9
+ - 1
10
+ version: 0.5.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ben Osheroff