sub_pub 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -104,7 +104,9 @@ Or install it yourself as:
104
104
  * before_create
105
105
  * after_create
106
106
  * after_commit
107
-
107
+ * after_commit on create
108
+ * after_commit on update
109
+ * after_commit on destroy
108
110
 
109
111
  ## Backlog / To Do
110
112
 
@@ -10,6 +10,14 @@ module SubPub
10
10
  end
11
11
  "
12
12
  end
13
+
14
+ [:create, :update, :destroy].each do |callback|
15
+ class_eval "
16
+ after_commit(on: callback) do
17
+ notify_pub_sub_of_active_record_callback('after_commit_on_#{callback.to_s}')
18
+ end
19
+ "
20
+ end
13
21
  end
14
22
 
15
23
  private
@@ -1,3 +1,3 @@
1
1
  module SubPub
2
- VERSION = "0.0.11"
2
+ VERSION = "0.0.12"
3
3
  end
@@ -8,6 +8,7 @@ describe SubPub do
8
8
 
9
9
  model do
10
10
  has_many :fake_active_record_results
11
+ validate :title, presence: true
11
12
  end
12
13
  end
13
14
 
@@ -156,6 +157,61 @@ describe SubPub do
156
157
  end
157
158
  end
158
159
 
160
+ describe "after commit on create" do
161
+ before do
162
+ class FakeActiveRecordUserSubscriber < SubPub::ActiveRecord::Subscriber
163
+ subscribe_to(FakeActiveRecordUser, 'after_commit_on_create')
164
+
165
+ def on_publish
166
+ FakeActiveRecordResult.create
167
+ end
168
+ end
169
+ end
170
+
171
+ it "successfully calls through to the subscriber" do
172
+ FakeActiveRecordResult.all.size.should == 0
173
+ FakeActiveRecordUser.create
174
+ FakeActiveRecordResult.all.size.should == 1
175
+ end
176
+ end
177
+
178
+ describe "after commit on destroy" do
179
+ before do
180
+ class FakeActiveRecordUserSubscriber < SubPub::ActiveRecord::Subscriber
181
+ subscribe_to(FakeActiveRecordUser, 'after_commit_on_destroy')
182
+
183
+ def on_publish
184
+ FakeActiveRecordResult.create
185
+ end
186
+ end
187
+ end
188
+
189
+ it "successfully calls through to the subscriber" do
190
+ FakeActiveRecordResult.all.size.should == 0
191
+ FakeActiveRecordUser.create.destroy
192
+ FakeActiveRecordResult.all.size.should == 1
193
+ end
194
+ end
195
+
196
+ describe "after commit on update" do
197
+ before do
198
+ class FakeActiveRecordUserSubscriber < SubPub::ActiveRecord::Subscriber
199
+ subscribe_to(FakeActiveRecordUser, 'after_commit_on_update')
200
+
201
+ def on_publish
202
+ FakeActiveRecordResult.create
203
+ end
204
+ end
205
+ end
206
+
207
+ it "successfully calls through to the subscriber" do
208
+ FakeActiveRecordResult.all.size.should == 0
209
+ fake_user = FakeActiveRecordUser.create
210
+ fake_user.update_attributes(title: "ABC")
211
+ FakeActiveRecordResult.all.size.should == 1
212
+ end
213
+ end
214
+
159
215
  describe "before create" do
160
216
  before do
161
217
  class FakeActiveRecordUserSubscriber < SubPub::ActiveRecord::Subscriber
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sub_pub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - zephyr-dev@googlegroups.com
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-04-08 00:00:00.000000000 Z
12
+ date: 2013-05-01 00:00:00.000000000 Z
12
13
  dependencies: []
13
14
  description: In process publish/subscribe for Ruby
14
15
  email:
@@ -51,26 +52,27 @@ files:
51
52
  - sub_pub.gemspec
52
53
  homepage: ''
53
54
  licenses: []
54
- metadata: {}
55
55
  post_install_message:
56
56
  rdoc_options: []
57
57
  require_paths:
58
58
  - lib
59
59
  required_ruby_version: !ruby/object:Gem::Requirement
60
+ none: false
60
61
  requirements:
61
- - - '>='
62
+ - - ! '>='
62
63
  - !ruby/object:Gem::Version
63
64
  version: '0'
64
65
  required_rubygems_version: !ruby/object:Gem::Requirement
66
+ none: false
65
67
  requirements:
66
- - - '>='
68
+ - - ! '>='
67
69
  - !ruby/object:Gem::Version
68
70
  version: '0'
69
71
  requirements: []
70
72
  rubyforge_project:
71
- rubygems_version: 2.0.3
73
+ rubygems_version: 1.8.24
72
74
  signing_key:
73
- specification_version: 4
75
+ specification_version: 3
74
76
  summary: SubPub is a thin wrapper around ActiveSupport::Notifications, which provides
75
77
  an implementation of the Publish/Subscribe pattern.
76
78
  test_files:
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 481a96767b0146b19366dfaa3742685627129bbe
4
- data.tar.gz: 09fffe3067f8e999b3510c3a84f9935f568690ec
5
- SHA512:
6
- metadata.gz: 66d39dd8704aa5429b1c3caca2a73b05b75ffef5b727075e1be7830c9e6e749fc7b93b14a3c22cdfed4a89355148ac8d7aa63c2c577ae7835e0f724c65d86d15
7
- data.tar.gz: 17252d836444d1ad870171354d93d02f44d8cd17b9627ca18b74d9773662e51bc7f602aceeab933bd5d19dae4c328cb09f3ca6159e3ea8bf1b1d1c46eca05353