con_air 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/con_air/connection_handler.rb +2 -11
- data/lib/con_air/version.rb +1 -1
- data/spec/con_air/connection_handler_spec.rb +14 -14
- data/spec/con_air_spec.rb +1 -1
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/test.log +66 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MmUwZjFjMGVlYjI5NDA4MGE4OTI3Yjc2NDM1MTFlNzg1NzU4NGZmYQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZDY3MGQzZTY5ZDc5MzRkMDhhYjNiMGFlODgwNDI1MWQ0MjU3YTM5Ng==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NTI0YmFlOGY0NzRjYWViZDhjZDJlYTU2ZjY4MWIwZDYxYTZkZDQxZGM2M2Vm
|
10
|
+
MzQ5YzMxOTI5Y2UyYzUyZTJlNzc3Zjk4ZDA4NDE3ODBhYmE2ZTMwMDllMjBl
|
11
|
+
MWM5YzVhYWUwOGNmZWVjNzMzZjYxNmE5ODU1MWIyMjUxMDg3NTQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NTBmZmFlZjZhOGU2ZmQzOGVlYTExZjBjN2ZlODFmMGQ2NjlmZmMxZmM0Mjk2
|
14
|
+
ZGNjNWE2ZTY3ZmU4OTUzM2M5YmU0MDZiN2IwYWY0NmNlNWQzODk0OTc2MzAz
|
15
|
+
MjRiNDJkZmJmNTUxZmZiYjBiNzBiMTk2NzJmNWVhMDJiZGRiNmU=
|
@@ -11,18 +11,9 @@ module ConAir
|
|
11
11
|
@swap_class = swap_class
|
12
12
|
|
13
13
|
# Init connections after switching handler
|
14
|
-
|
15
14
|
ActiveRecord::Base.establish_connection
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
def establish_connection(name, spec)
|
20
|
-
if name == swap_class.name
|
21
|
-
@connection_pools[@hijacked_spec] ||= ActiveRecord::ConnectionAdapters::ConnectionPool.new(@hijacked_spec)
|
22
|
-
@class_to_pool[name] = @connection_pools[@hijacked_spec]
|
23
|
-
else
|
24
|
-
super
|
25
|
-
end
|
15
|
+
@connection_pools[@hijacked_spec] ||= ActiveRecord::ConnectionAdapters::ConnectionPool.new(@hijacked_spec)
|
16
|
+
@class_to_pool[@swap_class.name] = @connection_pools[@hijacked_spec]
|
26
17
|
end
|
27
18
|
|
28
19
|
def exist?(config, klass)
|
data/lib/con_air/version.rb
CHANGED
@@ -3,31 +3,31 @@ require "spec_helper"
|
|
3
3
|
describe ConAir::ConnectionHandler do
|
4
4
|
before do
|
5
5
|
@swap_class = double(name: "Swap")
|
6
|
-
@config = double
|
6
|
+
@config = double.as_null_object
|
7
7
|
@spec = double(config: @config)
|
8
|
-
@original_spec = double
|
9
|
-
@handler = ConAir::ConnectionHandler.new(@swap_class, @spec)
|
10
8
|
end
|
11
9
|
|
12
|
-
context "#
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
context "#new" do
|
11
|
+
it "creates pool using passed-in spec" do
|
12
|
+
handler = ConAir::ConnectionHandler.new(@swap_class, @spec)
|
13
|
+
pool = handler.connection_pools[@spec]
|
16
14
|
|
17
|
-
|
18
|
-
|
15
|
+
expect(pool).to be_instance_of(ActiveRecord::ConnectionAdapters::ConnectionPool)
|
16
|
+
expect(pool.spec).to eq(@spec)
|
19
17
|
end
|
20
18
|
|
21
|
-
|
22
|
-
|
23
|
-
expect(ActiveRecord::ConnectionAdapters::ConnectionPool).to receive(:new).with(@original_spec)
|
19
|
+
it "establishes activerecords connection" do
|
20
|
+
expect(ActiveRecord::Base).to receive(:establish_connection)
|
24
21
|
|
25
|
-
|
26
|
-
end
|
22
|
+
ConAir::ConnectionHandler.new(@swap_class, @spec)
|
27
23
|
end
|
28
24
|
end
|
29
25
|
|
30
26
|
context "#exist?" do
|
27
|
+
before do
|
28
|
+
@handler = ConAir::ConnectionHandler.new(@swap_class, @spec)
|
29
|
+
end
|
30
|
+
|
31
31
|
context "when has same config and class to swap" do
|
32
32
|
it "returns true" do
|
33
33
|
expect(@handler.exist?(@config, @swap_class)).to be(true)
|
data/spec/con_air_spec.rb
CHANGED
data/spec/dummy/db/test.sqlite3
CHANGED
Binary file
|
data/spec/dummy/log/test.log
CHANGED
@@ -5,3 +5,69 @@ Connecting to database specified by database.yml
|
|
5
5
|
[1m[35m (17.4ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
6
6
|
[1m[36m (0.1ms)[0m [1mSELECT version FROM "schema_migrations"[0m
|
7
7
|
[1m[35m (17.1ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20131220144142')
|
8
|
+
Connecting to database specified by database.yml
|
9
|
+
[1m[36m (29.5ms)[0m [1mselect sqlite_version(*)[0m
|
10
|
+
[1m[35m (21.4ms)[0m DROP TABLE "users"
|
11
|
+
[1m[36m (17.6ms)[0m [1mCREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) [0m
|
12
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
13
|
+
[1m[36m (17.4ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20131223111850')[0m
|
14
|
+
Connecting to database specified by database.yml
|
15
|
+
[1m[36m (25.0ms)[0m [1mselect sqlite_version(*)[0m
|
16
|
+
[1m[35m (27.5ms)[0m DROP TABLE "users"
|
17
|
+
[1m[36m (4.4ms)[0m [1mCREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) [0m
|
18
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
19
|
+
[1m[36m (5.0ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20131223112540')[0m
|
20
|
+
Connecting to database specified by database.yml
|
21
|
+
[1m[36m (26.1ms)[0m [1mselect sqlite_version(*)[0m
|
22
|
+
[1m[35m (8.7ms)[0m DROP TABLE "users"
|
23
|
+
[1m[36m (5.2ms)[0m [1mCREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) [0m
|
24
|
+
[1m[35m (0.2ms)[0m SELECT version FROM "schema_migrations"
|
25
|
+
[1m[36m (8.1ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20131223112642')[0m
|
26
|
+
Connecting to database specified by database.yml
|
27
|
+
[1m[36m (24.2ms)[0m [1mselect sqlite_version(*)[0m
|
28
|
+
[1m[35m (12.7ms)[0m DROP TABLE "users"
|
29
|
+
[1m[36m (14.7ms)[0m [1mCREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) [0m
|
30
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
31
|
+
[1m[36m (17.4ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20131223112746')[0m
|
32
|
+
Connecting to database specified by database.yml
|
33
|
+
[1m[36m (24.3ms)[0m [1mselect sqlite_version(*)[0m
|
34
|
+
[1m[35m (25.0ms)[0m DROP TABLE "users"
|
35
|
+
[1m[36m (17.3ms)[0m [1mCREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) [0m
|
36
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
37
|
+
[1m[36m (10.2ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20131223112802')[0m
|
38
|
+
Connecting to database specified by database.yml
|
39
|
+
[1m[36m (24.2ms)[0m [1mselect sqlite_version(*)[0m
|
40
|
+
[1m[35m (26.8ms)[0m DROP TABLE "users"
|
41
|
+
[1m[36m (17.4ms)[0m [1mCREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) [0m
|
42
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
43
|
+
[1m[36m (17.4ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20131223113032')[0m
|
44
|
+
Connecting to database specified by database.yml
|
45
|
+
[1m[36m (26.9ms)[0m [1mselect sqlite_version(*)[0m
|
46
|
+
[1m[35m (24.9ms)[0m DROP TABLE "users"
|
47
|
+
[1m[36m (17.5ms)[0m [1mCREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) [0m
|
48
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
49
|
+
[1m[36m (6.7ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20131223113046')[0m
|
50
|
+
Connecting to database specified by database.yml
|
51
|
+
[1m[36m (26.4ms)[0m [1mselect sqlite_version(*)[0m
|
52
|
+
[1m[35m (13.2ms)[0m DROP TABLE "users"
|
53
|
+
[1m[36m (5.3ms)[0m [1mCREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) [0m
|
54
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
55
|
+
[1m[36m (4.4ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20131223113114')[0m
|
56
|
+
Connecting to database specified by database.yml
|
57
|
+
[1m[36m (25.7ms)[0m [1mselect sqlite_version(*)[0m
|
58
|
+
[1m[35m (21.5ms)[0m DROP TABLE "users"
|
59
|
+
[1m[36m (17.4ms)[0m [1mCREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) [0m
|
60
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
61
|
+
[1m[36m (17.4ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20131223113405')[0m
|
62
|
+
Connecting to database specified by database.yml
|
63
|
+
[1m[36m (26.7ms)[0m [1mselect sqlite_version(*)[0m
|
64
|
+
[1m[35m (9.4ms)[0m DROP TABLE "users"
|
65
|
+
[1m[36m (17.5ms)[0m [1mCREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) [0m
|
66
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
67
|
+
[1m[36m (17.2ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20131223113450')[0m
|
68
|
+
Connecting to database specified by database.yml
|
69
|
+
[1m[36m (19.0ms)[0m [1mselect sqlite_version(*)[0m
|
70
|
+
[1m[35m (21.2ms)[0m DROP TABLE "users"
|
71
|
+
[1m[36m (14.0ms)[0m [1mCREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) [0m
|
72
|
+
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
73
|
+
[1m[36m (5.0ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('20131223113501')[0m
|