after_commit_queue 0.0.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
data/lib/after_commit_queue.rb
CHANGED
@@ -3,6 +3,7 @@ module AfterCommitQueue
|
|
3
3
|
|
4
4
|
included do
|
5
5
|
after_commit :_run_after_commit_queue
|
6
|
+
after_rollback :_clear_after_commit_queue
|
6
7
|
end
|
7
8
|
|
8
9
|
protected
|
@@ -28,4 +29,8 @@ module AfterCommitQueue
|
|
28
29
|
def _after_commit_queue
|
29
30
|
@after_commit_queue ||= []
|
30
31
|
end
|
32
|
+
|
33
|
+
def _clear_after_commit_queue
|
34
|
+
@after_commit_queue.clear
|
35
|
+
end
|
31
36
|
end
|
@@ -36,4 +36,17 @@ class AfterCommitQueueTest < ActiveSupport::TestCase
|
|
36
36
|
assert !@server.started
|
37
37
|
assert @server.stopped
|
38
38
|
end
|
39
|
+
|
40
|
+
test "clears queue after rollback" do
|
41
|
+
assert !@server.started
|
42
|
+
|
43
|
+
Server.transaction do
|
44
|
+
@server.start!
|
45
|
+
assert !@server.started
|
46
|
+
raise ActiveRecord::Rollback
|
47
|
+
end
|
48
|
+
|
49
|
+
assert @server.__send__(:_after_commit_queue).empty?
|
50
|
+
assert !@server.started
|
51
|
+
end
|
39
52
|
end
|
data/test/dummy/db/test.sqlite3
CHANGED
Binary file
|
@@ -95,3 +95,25 @@ Migrating to CreateServers (20120622135717)
|
|
95
95
|
[1m[35m (1.0ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
96
96
|
[1m[36m (0.1ms)[0m [1mSELECT version FROM "schema_migrations"[0m
|
97
97
|
[1m[35m (1.1ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20120622135717')
|
98
|
+
Connecting to database specified by database.yml
|
99
|
+
[1m[36m (0.1ms)[0m [1mselect sqlite_version(*)[0m
|
100
|
+
[1m[35m (1.3ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
101
|
+
[1m[36m (0.0ms)[0m [1mPRAGMA index_list("schema_migrations")[0m
|
102
|
+
[1m[35m (1.2ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
103
|
+
[1m[36m (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations" [0m
|
104
|
+
Migrating to CreateServers (20120622135717)
|
105
|
+
[1m[35m (0.0ms)[0m begin transaction
|
106
|
+
[1m[36m (0.4ms)[0m [1mCREATE TABLE "servers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "state" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) [0m
|
107
|
+
[1m[35m (0.1ms)[0m INSERT INTO "schema_migrations" ("version") VALUES ('20120622135717')
|
108
|
+
[1m[36m (1.0ms)[0m [1mcommit transaction[0m
|
109
|
+
[1m[35m (0.3ms)[0m select sqlite_version(*)
|
110
|
+
[1m[36m (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations" [0m
|
111
|
+
[1m[35m (0.0ms)[0m PRAGMA index_list("servers")
|
112
|
+
[1m[36m (0.1ms)[0m [1mSELECT "schema_migrations"."version" FROM "schema_migrations" [0m
|
113
|
+
[1m[35m (0.2ms)[0m select sqlite_version(*)
|
114
|
+
[1m[36m (1.3ms)[0m [1mCREATE TABLE "servers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "state" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) [0m
|
115
|
+
[1m[35m (1.1ms)[0m CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
|
116
|
+
[1m[36m (0.0ms)[0m [1mPRAGMA index_list("schema_migrations")[0m
|
117
|
+
[1m[35m (0.9ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
118
|
+
[1m[36m (0.1ms)[0m [1mSELECT version FROM "schema_migrations"[0m
|
119
|
+
[1m[35m (0.8ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('20120622135717')
|
data/test/dummy/log/test.log
CHANGED
@@ -316,3 +316,22 @@ Connecting to database specified by database.yml
|
|
316
316
|
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
317
317
|
[1m[35mSQL (0.3ms)[0m INSERT INTO "servers" ("created_at", "state", "updated_at") VALUES (?, ?, ?) [["created_at", Wed, 01 Aug 2012 10:44:49 UTC +00:00], ["state", "running"], ["updated_at", Wed, 01 Aug 2012 10:44:49 UTC +00:00]]
|
318
318
|
[1m[36m (1.0ms)[0m [1mcommit transaction[0m
|
319
|
+
Connecting to database specified by database.yml
|
320
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
321
|
+
[1m[35mSQL (8.9ms)[0m INSERT INTO "servers" ("created_at", "state", "updated_at") VALUES (?, ?, ?) [["created_at", Wed, 24 Oct 2012 13:26:25 UTC +00:00], ["state", "running"], ["updated_at", Wed, 24 Oct 2012 13:26:25 UTC +00:00]]
|
322
|
+
[1m[36m (0.6ms)[0m [1mcommit transaction[0m
|
323
|
+
[1m[35m (0.0ms)[0m begin transaction
|
324
|
+
[1m[36m (0.3ms)[0m [1mUPDATE "servers" SET "state" = 'turned_off', "updated_at" = '2012-10-24 13:26:25.609680' WHERE "servers"."id" = 1[0m
|
325
|
+
[1m[35m (0.9ms)[0m commit transaction
|
326
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
327
|
+
[1m[35mSQL (0.4ms)[0m INSERT INTO "servers" ("created_at", "state", "updated_at") VALUES (?, ?, ?) [["created_at", Wed, 24 Oct 2012 13:26:25 UTC +00:00], ["state", "running"], ["updated_at", Wed, 24 Oct 2012 13:26:25 UTC +00:00]]
|
328
|
+
[1m[36m (0.9ms)[0m [1mrollback transaction[0m
|
329
|
+
[1m[35m (0.0ms)[0m begin transaction
|
330
|
+
[1m[36mSQL (0.3ms)[0m [1mINSERT INTO "servers" ("created_at", "state", "updated_at") VALUES (?, ?, ?)[0m [["created_at", Wed, 24 Oct 2012 13:26:25 UTC +00:00], ["state", "running"], ["updated_at", Wed, 24 Oct 2012 13:26:25 UTC +00:00]]
|
331
|
+
[1m[35m (0.7ms)[0m commit transaction
|
332
|
+
[1m[36m (0.0ms)[0m [1mbegin transaction[0m
|
333
|
+
[1m[35m (0.4ms)[0m UPDATE "servers" SET "state" = 'crashed', "updated_at" = '2012-10-24 13:26:25.619583' WHERE "servers"."id" = 2
|
334
|
+
[1m[36m (0.8ms)[0m [1mcommit transaction[0m
|
335
|
+
[1m[35m (0.0ms)[0m begin transaction
|
336
|
+
[1m[36mSQL (0.4ms)[0m [1mINSERT INTO "servers" ("created_at", "state", "updated_at") VALUES (?, ?, ?)[0m [["created_at", Wed, 24 Oct 2012 13:26:25 UTC +00:00], ["state", "running"], ["updated_at", Wed, 24 Oct 2012 13:26:25 UTC +00:00]]
|
337
|
+
[1m[35m (1.0ms)[0m commit transaction
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: after_commit_queue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-10-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -110,7 +110,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
110
110
|
version: '0'
|
111
111
|
segments:
|
112
112
|
- 0
|
113
|
-
hash:
|
113
|
+
hash: -1256316430185347687
|
114
114
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
115
|
none: false
|
116
116
|
requirements:
|
@@ -119,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
119
|
version: '0'
|
120
120
|
segments:
|
121
121
|
- 0
|
122
|
-
hash:
|
122
|
+
hash: -1256316430185347687
|
123
123
|
requirements: []
|
124
124
|
rubyforge_project:
|
125
125
|
rubygems_version: 1.8.24
|