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.
@@ -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
@@ -1,3 +1,3 @@
1
1
  module AfterCommitQueue
2
- VERSION = "0.0.3"
2
+ VERSION = "1.0.0"
3
3
  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
Binary file
@@ -95,3 +95,25 @@ Migrating to CreateServers (20120622135717)
95
95
   (1.0ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
96
96
   (0.1ms) SELECT version FROM "schema_migrations"
97
97
   (1.1ms) INSERT INTO "schema_migrations" (version) VALUES ('20120622135717')
98
+ Connecting to database specified by database.yml
99
+  (0.1ms) select sqlite_version(*)
100
+  (1.3ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
101
+  (0.0ms) PRAGMA index_list("schema_migrations")
102
+  (1.2ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
103
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
104
+ Migrating to CreateServers (20120622135717)
105
+  (0.0ms) begin transaction
106
+  (0.4ms) CREATE TABLE "servers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "state" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
107
+  (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES ('20120622135717')
108
+  (1.0ms) commit transaction
109
+  (0.3ms) select sqlite_version(*)
110
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
111
+  (0.0ms) PRAGMA index_list("servers")
112
+  (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
113
+  (0.2ms) select sqlite_version(*)
114
+  (1.3ms) CREATE TABLE "servers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "state" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
115
+  (1.1ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
116
+  (0.0ms) PRAGMA index_list("schema_migrations")
117
+  (0.9ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
118
+  (0.1ms) SELECT version FROM "schema_migrations"
119
+  (0.8ms) INSERT INTO "schema_migrations" (version) VALUES ('20120622135717')
@@ -316,3 +316,22 @@ Connecting to database specified by database.yml
316
316
   (0.1ms) begin transaction
317
317
  SQL (0.3ms) 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
   (1.0ms) commit transaction
319
+ Connecting to database specified by database.yml
320
+  (0.0ms) begin transaction
321
+ SQL (8.9ms) 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
+  (0.6ms) commit transaction
323
+  (0.0ms) begin transaction
324
+  (0.3ms) UPDATE "servers" SET "state" = 'turned_off', "updated_at" = '2012-10-24 13:26:25.609680' WHERE "servers"."id" = 1
325
+  (0.9ms) commit transaction
326
+  (0.0ms) begin transaction
327
+ SQL (0.4ms) 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
+  (0.9ms) rollback transaction
329
+  (0.0ms) begin transaction
330
+ SQL (0.3ms) 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]]
331
+  (0.7ms) commit transaction
332
+  (0.0ms) begin transaction
333
+  (0.4ms) UPDATE "servers" SET "state" = 'crashed', "updated_at" = '2012-10-24 13:26:25.619583' WHERE "servers"."id" = 2
334
+  (0.8ms) commit transaction
335
+  (0.0ms) begin transaction
336
+ SQL (0.4ms) 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]]
337
+  (1.0ms) 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.3
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-08-01 00:00:00.000000000 Z
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: 3808905130846087768
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: 3808905130846087768
122
+ hash: -1256316430185347687
123
123
  requirements: []
124
124
  rubyforge_project:
125
125
  rubygems_version: 1.8.24