activity_notification 1.2.1 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +15 -5
- data/CHANGELOG.md +13 -2
- data/Gemfile +1 -1
- data/Gemfile.lock +78 -71
- data/README.md +64 -43
- data/activity_notification.gemspec +5 -4
- data/app/controllers/activity_notification/notifications_controller.rb +1 -1
- data/app/controllers/activity_notification/subscriptions_controller.rb +1 -1
- data/gemfiles/Gemfile.rails-4.2 +1 -1
- data/gemfiles/Gemfile.rails-4.2.lock +71 -62
- data/gemfiles/Gemfile.rails-5.0 +1 -1
- data/gemfiles/Gemfile.rails-5.0.lock +74 -67
- data/lib/activity_notification.rb +9 -2
- data/lib/activity_notification/apis/notification_api.rb +142 -76
- data/lib/activity_notification/apis/subscription_api.rb +72 -0
- data/lib/activity_notification/config.rb +12 -0
- data/lib/activity_notification/models/concerns/notifiable.rb +56 -6
- data/lib/activity_notification/models/concerns/notifier.rb +8 -1
- data/lib/activity_notification/models/concerns/subscriber.rb +13 -10
- data/lib/activity_notification/models/concerns/target.rb +7 -5
- data/lib/activity_notification/models/notification.rb +2 -270
- data/lib/activity_notification/models/subscription.rb +3 -101
- data/lib/activity_notification/optional_targets/base.rb +5 -1
- data/lib/activity_notification/orm/active_record.rb +16 -0
- data/lib/activity_notification/orm/active_record/notification.rb +252 -0
- data/lib/activity_notification/orm/active_record/subscription.rb +52 -0
- data/lib/activity_notification/orm/mongoid.rb +63 -0
- data/lib/activity_notification/orm/mongoid/notification.rb +255 -0
- data/lib/activity_notification/orm/mongoid/subscription.rb +73 -0
- data/lib/activity_notification/rails/routes.rb +7 -3
- data/lib/activity_notification/renderable.rb +5 -1
- data/lib/activity_notification/roles/acts_as_notifiable.rb +4 -18
- data/lib/activity_notification/version.rb +1 -1
- data/lib/generators/activity_notification/install_generator.rb +3 -5
- data/lib/generators/templates/activity_notification.rb +9 -4
- data/spec/concerns/apis/notification_api_spec.rb +27 -14
- data/spec/concerns/models/notifiable_spec.rb +10 -8
- data/spec/concerns/models/subscriber_spec.rb +12 -12
- data/spec/concerns/models/target_spec.rb +61 -51
- data/spec/controllers/subscriptions_controller_shared_examples.rb +0 -1
- data/spec/helpers/view_helpers_spec.rb +24 -7
- data/spec/models/notification_spec.rb +63 -52
- data/spec/models/subscription_spec.rb +6 -3
- data/spec/optional_targets/amazon_sns_spec.rb +8 -5
- data/spec/optional_targets/base_spec.rb +3 -1
- data/spec/optional_targets/slack_spec.rb +5 -5
- data/spec/rails_app/app/models/comment.rb +1 -1
- data/spec/rails_app/app/views/activity_notification/notifications/users/overriden/custom/_test.html.erb +1 -0
- data/spec/rails_app/config/application.rb +7 -0
- data/spec/rails_app/config/initializers/activity_notification.rb +5 -0
- data/spec/rails_app/config/mongoid.yml +13 -0
- data/spec/rails_app/db/seeds.rb +1 -1
- data/spec/rails_app/lib/custom_optional_targets/console_output.rb +7 -4
- data/spec/rails_app/lib/custom_optional_targets/wrong_target.rb +3 -0
- data/spec/roles/acts_as_notifiable_spec.rb +77 -16
- data/spec/spec_helper.rb +7 -0
- metadata +38 -14
@@ -45,13 +45,15 @@ describe ActivityNotification::ViewHelpers, type: :helper do
|
|
45
45
|
locals: { notification: notification }
|
46
46
|
)
|
47
47
|
end
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
48
|
+
|
49
|
+
if ActivityNotification.config.orm == :active_record
|
50
|
+
it 'handles multiple notifications of active_record' do
|
51
|
+
expect(notifications.to_a.first).to receive(:render).with(self, { fallback: :default })
|
52
|
+
expect(notifications.to_a.last).to receive(:render).with(self, { fallback: :default })
|
53
|
+
render_notification notifications, fallback: :default
|
54
|
+
end
|
53
55
|
end
|
54
|
-
|
56
|
+
|
55
57
|
it 'handles multiple notifications of array' do
|
56
58
|
expect(notification).to receive(:render).with(self, { fallback: :default })
|
57
59
|
expect(notification_2).to receive(:render).with(self, { fallback: :default })
|
@@ -74,7 +76,7 @@ describe ActivityNotification::ViewHelpers, type: :helper do
|
|
74
76
|
expect(render_notification notification)
|
75
77
|
.to eq("Custom template root for default target: #{notification.id}")
|
76
78
|
end
|
77
|
-
|
79
|
+
|
78
80
|
it "renders custom notification view for specified target" do
|
79
81
|
notification.key = 'custom.test'
|
80
82
|
# render activity_notification/notifications/users/custom/test
|
@@ -98,6 +100,21 @@ describe ActivityNotification::ViewHelpers, type: :helper do
|
|
98
100
|
})
|
99
101
|
render_notification notification, layout: 'test'
|
100
102
|
end
|
103
|
+
|
104
|
+
context "with defined overriding_notification_template_key in notifiable model" do
|
105
|
+
it "renders overriden custom notification view" do
|
106
|
+
notification.key = 'custom.test'
|
107
|
+
module AdditionalMethods
|
108
|
+
def overriding_notification_template_key(target, key)
|
109
|
+
'overriden.custom.test'
|
110
|
+
end
|
111
|
+
end
|
112
|
+
notification.notifiable.extend(AdditionalMethods)
|
113
|
+
# render activity_notification/notifications/users/overriden/custom/test
|
114
|
+
expect(render_notification notification, target: :users)
|
115
|
+
.to eq("Overriden custom template root for user target: #{notification.id}")
|
116
|
+
end
|
117
|
+
end
|
101
118
|
end
|
102
119
|
end
|
103
120
|
|
@@ -25,13 +25,13 @@ describe ActivityNotification::Notification, type: :model do
|
|
25
25
|
it "belongs to notification as group_owner" do
|
26
26
|
group_owner = create(:notification, group_owner: nil)
|
27
27
|
group_member = create(:notification, group_owner: group_owner)
|
28
|
-
expect(group_member.reload.group_owner).to eq(group_owner)
|
28
|
+
expect(group_member.reload.group_owner.becomes(ActivityNotification::Notification)).to eq(group_owner)
|
29
29
|
end
|
30
30
|
|
31
31
|
it "has many notifications as group_members" do
|
32
32
|
group_owner = create(:notification, group_owner: nil)
|
33
33
|
group_member = create(:notification, group_owner: group_owner)
|
34
|
-
expect(group_owner.reload.group_members.first).to eq(group_member)
|
34
|
+
expect(group_owner.reload.group_members.first.becomes(ActivityNotification::Notification)).to eq(group_member)
|
35
35
|
end
|
36
36
|
|
37
37
|
it "belongs to notifier" do
|
@@ -42,8 +42,16 @@ describe ActivityNotification::Notification, type: :model do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
describe "with serializable column" do
|
45
|
-
|
46
|
-
|
45
|
+
if ActivityNotification.config.orm == :active_record
|
46
|
+
it "has parameters for hash with symbol" do
|
47
|
+
parameters = {a: 1, b: 2, c: 3}
|
48
|
+
notification = create(:notification, parameters: parameters)
|
49
|
+
expect(notification.reload.parameters).to eq(parameters)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
it "has parameters for hash with string" do
|
54
|
+
parameters = {'a' => 1, 'b' => 2, 'c' => 3}
|
47
55
|
notification = create(:notification, parameters: parameters)
|
48
56
|
expect(notification.reload.parameters).to eq(parameters)
|
49
57
|
end
|
@@ -87,81 +95,81 @@ describe ActivityNotification::Notification, type: :model do
|
|
87
95
|
|
88
96
|
it "works with group_owners_only scope" do
|
89
97
|
notifications = ActivityNotification::Notification.group_owners_only
|
90
|
-
expect(notifications.size).to eq(2)
|
91
|
-
expect(notifications.
|
92
|
-
expect(notifications.
|
98
|
+
expect(notifications.to_a.size).to eq(2)
|
99
|
+
expect(notifications.unopened_only.first).to eq(@unopened_group_owner)
|
100
|
+
expect(notifications.opened_only!.first).to eq(@opened_group_owner)
|
93
101
|
end
|
94
102
|
|
95
103
|
it "works with group_members_only scope" do
|
96
104
|
notifications = ActivityNotification::Notification.group_members_only
|
97
|
-
expect(notifications.size).to eq(2)
|
98
|
-
expect(notifications.
|
99
|
-
expect(notifications.
|
105
|
+
expect(notifications.to_a.size).to eq(2)
|
106
|
+
expect(notifications.unopened_only.first).to eq(@unopened_group_member)
|
107
|
+
expect(notifications.opened_only!.first).to eq(@opened_group_member)
|
100
108
|
end
|
101
109
|
|
102
110
|
it "works with unopened_only scope" do
|
103
111
|
notifications = ActivityNotification::Notification.unopened_only
|
104
|
-
expect(notifications.size).to eq(2)
|
105
|
-
expect(notifications.
|
106
|
-
expect(notifications.
|
112
|
+
expect(notifications.to_a.size).to eq(2)
|
113
|
+
expect(notifications.group_owners_only.first).to eq(@unopened_group_owner)
|
114
|
+
expect(notifications.group_members_only.first).to eq(@unopened_group_member)
|
107
115
|
end
|
108
116
|
|
109
117
|
it "works with unopened_index scope" do
|
110
118
|
notifications = ActivityNotification::Notification.unopened_index
|
111
|
-
expect(notifications.size).to eq(1)
|
119
|
+
expect(notifications.to_a.size).to eq(1)
|
112
120
|
expect(notifications.first).to eq(@unopened_group_owner)
|
113
121
|
end
|
114
122
|
|
115
123
|
it "works with opened_only! scope" do
|
116
124
|
notifications = ActivityNotification::Notification.opened_only!
|
117
|
-
expect(notifications.size).to eq(2)
|
118
|
-
expect(notifications.
|
119
|
-
expect(notifications.
|
125
|
+
expect(notifications.to_a.size).to eq(2)
|
126
|
+
expect(notifications.group_owners_only.first).to eq(@opened_group_owner)
|
127
|
+
expect(notifications.group_members_only.first).to eq(@opened_group_member)
|
120
128
|
end
|
121
129
|
|
122
130
|
context "with opened_only scope" do
|
123
131
|
it "works" do
|
124
132
|
notifications = ActivityNotification::Notification.opened_only(4)
|
125
|
-
expect(notifications.size).to eq(2)
|
126
|
-
expect(notifications.
|
127
|
-
expect(notifications.
|
133
|
+
expect(notifications.to_a.size).to eq(2)
|
134
|
+
expect(notifications.group_owners_only.first).to eq(@opened_group_owner)
|
135
|
+
expect(notifications.group_members_only.first).to eq(@opened_group_member)
|
128
136
|
end
|
129
137
|
|
130
138
|
it "works with limit" do
|
131
139
|
notifications = ActivityNotification::Notification.opened_only(1)
|
132
|
-
expect(notifications.size).to eq(1)
|
140
|
+
expect(notifications.to_a.size).to eq(1)
|
133
141
|
end
|
134
142
|
end
|
135
143
|
|
136
144
|
context "with opened_index scope" do
|
137
145
|
it "works" do
|
138
146
|
notifications = ActivityNotification::Notification.opened_index(4)
|
139
|
-
expect(notifications.size).to eq(1)
|
147
|
+
expect(notifications.to_a.size).to eq(1)
|
140
148
|
expect(notifications.first).to eq(@opened_group_owner)
|
141
149
|
end
|
142
150
|
|
143
151
|
it "works with limit" do
|
144
152
|
notifications = ActivityNotification::Notification.opened_index(0)
|
145
|
-
expect(notifications.size).to eq(0)
|
153
|
+
expect(notifications.to_a.size).to eq(0)
|
146
154
|
end
|
147
155
|
end
|
148
156
|
|
149
157
|
it "works with unopened_index_group_members_only scope" do
|
150
158
|
notifications = ActivityNotification::Notification.unopened_index_group_members_only
|
151
|
-
expect(notifications.size).to eq(1)
|
159
|
+
expect(notifications.to_a.size).to eq(1)
|
152
160
|
expect(notifications.first).to eq(@unopened_group_member)
|
153
161
|
end
|
154
162
|
|
155
163
|
context "with opened_index_group_members_only scope" do
|
156
164
|
it "works" do
|
157
165
|
notifications = ActivityNotification::Notification.opened_index_group_members_only(4)
|
158
|
-
expect(notifications.size).to eq(1)
|
166
|
+
expect(notifications.to_a.size).to eq(1)
|
159
167
|
expect(notifications.first).to eq(@opened_group_member)
|
160
168
|
end
|
161
169
|
|
162
170
|
it "works with limit" do
|
163
171
|
notifications = ActivityNotification::Notification.opened_index_group_members_only(0)
|
164
|
-
expect(notifications.size).to eq(0)
|
172
|
+
expect(notifications.to_a.size).to eq(0)
|
165
173
|
end
|
166
174
|
end
|
167
175
|
end
|
@@ -177,46 +185,46 @@ describe ActivityNotification::Notification, type: :model do
|
|
177
185
|
|
178
186
|
it "works with filtered_by_target scope" do
|
179
187
|
notifications = ActivityNotification::Notification.filtered_by_target(@target_1)
|
180
|
-
expect(notifications.size).to eq(1)
|
188
|
+
expect(notifications.to_a.size).to eq(1)
|
181
189
|
expect(notifications.first).to eq(@notification_1)
|
182
190
|
notifications = ActivityNotification::Notification.filtered_by_target(@target_2)
|
183
|
-
expect(notifications.size).to eq(1)
|
191
|
+
expect(notifications.to_a.size).to eq(1)
|
184
192
|
expect(notifications.first).to eq(@notification_2)
|
185
193
|
end
|
186
194
|
|
187
195
|
it "works with filtered_by_instance scope" do
|
188
196
|
notifications = ActivityNotification::Notification.filtered_by_instance(@notifiable_1)
|
189
|
-
expect(notifications.size).to eq(1)
|
197
|
+
expect(notifications.to_a.size).to eq(1)
|
190
198
|
expect(notifications.first).to eq(@notification_1)
|
191
199
|
notifications = ActivityNotification::Notification.filtered_by_instance(@notifiable_2)
|
192
|
-
expect(notifications.size).to eq(1)
|
200
|
+
expect(notifications.to_a.size).to eq(1)
|
193
201
|
expect(notifications.first).to eq(@notification_2)
|
194
202
|
end
|
195
203
|
|
196
204
|
it "works with filtered_by_type scope" do
|
197
205
|
notifications = ActivityNotification::Notification.filtered_by_type(@notifiable_1.to_class_name)
|
198
|
-
expect(notifications.size).to eq(1)
|
206
|
+
expect(notifications.to_a.size).to eq(1)
|
199
207
|
expect(notifications.first).to eq(@notification_1)
|
200
208
|
notifications = ActivityNotification::Notification.filtered_by_type(@notifiable_2.to_class_name)
|
201
|
-
expect(notifications.size).to eq(1)
|
209
|
+
expect(notifications.to_a.size).to eq(1)
|
202
210
|
expect(notifications.first).to eq(@notification_2)
|
203
211
|
end
|
204
212
|
|
205
213
|
it "works with filtered_by_group scope" do
|
206
214
|
notifications = ActivityNotification::Notification.filtered_by_group(@group_1)
|
207
|
-
expect(notifications.size).to eq(1)
|
215
|
+
expect(notifications.to_a.size).to eq(1)
|
208
216
|
expect(notifications.first).to eq(@notification_1)
|
209
217
|
notifications = ActivityNotification::Notification.filtered_by_group(@group_2)
|
210
|
-
expect(notifications.size).to eq(1)
|
218
|
+
expect(notifications.to_a.size).to eq(1)
|
211
219
|
expect(notifications.first).to eq(@notification_2)
|
212
220
|
end
|
213
221
|
|
214
222
|
it "works with filtered_by_key scope" do
|
215
223
|
notifications = ActivityNotification::Notification.filtered_by_key(@key_1)
|
216
|
-
expect(notifications.size).to eq(1)
|
224
|
+
expect(notifications.to_a.size).to eq(1)
|
217
225
|
expect(notifications.first).to eq(@notification_1)
|
218
226
|
notifications = ActivityNotification::Notification.filtered_by_key(@key_2)
|
219
|
-
expect(notifications.size).to eq(1)
|
227
|
+
expect(notifications.to_a.size).to eq(1)
|
220
228
|
expect(notifications.first).to eq(@notification_2)
|
221
229
|
end
|
222
230
|
|
@@ -224,10 +232,10 @@ describe ActivityNotification::Notification, type: :model do
|
|
224
232
|
context 'with filtered_by_type options' do
|
225
233
|
it "works with filtered_by_options scope" do
|
226
234
|
notifications = ActivityNotification::Notification.filtered_by_options({ filtered_by_type: @notifiable_1.to_class_name })
|
227
|
-
expect(notifications.size).to eq(1)
|
235
|
+
expect(notifications.to_a.size).to eq(1)
|
228
236
|
expect(notifications.first).to eq(@notification_1)
|
229
237
|
notifications = ActivityNotification::Notification.filtered_by_options({ filtered_by_type: @notifiable_2.to_class_name })
|
230
|
-
expect(notifications.size).to eq(1)
|
238
|
+
expect(notifications.to_a.size).to eq(1)
|
231
239
|
expect(notifications.first).to eq(@notification_2)
|
232
240
|
end
|
233
241
|
end
|
@@ -235,10 +243,10 @@ describe ActivityNotification::Notification, type: :model do
|
|
235
243
|
context 'with filtered_by_group options' do
|
236
244
|
it "works with filtered_by_options scope" do
|
237
245
|
notifications = ActivityNotification::Notification.filtered_by_options({ filtered_by_group: @group_1 })
|
238
|
-
expect(notifications.size).to eq(1)
|
246
|
+
expect(notifications.to_a.size).to eq(1)
|
239
247
|
expect(notifications.first).to eq(@notification_1)
|
240
248
|
notifications = ActivityNotification::Notification.filtered_by_options({ filtered_by_group: @group_2 })
|
241
|
-
expect(notifications.size).to eq(1)
|
249
|
+
expect(notifications.to_a.size).to eq(1)
|
242
250
|
expect(notifications.first).to eq(@notification_2)
|
243
251
|
end
|
244
252
|
end
|
@@ -246,33 +254,36 @@ describe ActivityNotification::Notification, type: :model do
|
|
246
254
|
context 'with filtered_by_group_type and :filtered_by_group_id options' do
|
247
255
|
it "works with filtered_by_options scope" do
|
248
256
|
notifications = ActivityNotification::Notification.filtered_by_options({ filtered_by_group_type: 'Article', filtered_by_group_id: @group_2.id.to_s })
|
249
|
-
expect(notifications.size).to eq(1)
|
257
|
+
expect(notifications.to_a.size).to eq(1)
|
250
258
|
expect(notifications.first).to eq(@notification_2)
|
251
259
|
notifications = ActivityNotification::Notification.filtered_by_options({ filtered_by_group_type: 'Article' })
|
252
|
-
expect(notifications.size).to eq(2)
|
260
|
+
expect(notifications.to_a.size).to eq(2)
|
253
261
|
notifications = ActivityNotification::Notification.filtered_by_options({ filtered_by_group_id: @group_2.id.to_s })
|
254
|
-
expect(notifications.size).to eq(2)
|
262
|
+
expect(notifications.to_a.size).to eq(2)
|
255
263
|
end
|
256
264
|
end
|
257
265
|
|
258
266
|
context 'with filtered_by_key options' do
|
259
267
|
it "works with filtered_by_options scope" do
|
260
268
|
notifications = ActivityNotification::Notification.filtered_by_options({ filtered_by_key: @key_1 })
|
261
|
-
expect(notifications.size).to eq(1)
|
269
|
+
expect(notifications.to_a.size).to eq(1)
|
262
270
|
expect(notifications.first).to eq(@notification_1)
|
263
271
|
notifications = ActivityNotification::Notification.filtered_by_options({ filtered_by_key: @key_2 })
|
264
|
-
expect(notifications.size).to eq(1)
|
272
|
+
expect(notifications.to_a.size).to eq(1)
|
265
273
|
expect(notifications.first).to eq(@notification_2)
|
266
274
|
end
|
267
275
|
end
|
268
276
|
|
269
277
|
context 'with custom_filter options' do
|
270
278
|
it "works with filtered_by_options scope" do
|
271
|
-
|
272
|
-
|
273
|
-
|
279
|
+
if ActivityNotification.config.orm == :active_record
|
280
|
+
notifications = ActivityNotification::Notification.filtered_by_options({ custom_filter: ["key = ?", @key_1] })
|
281
|
+
expect(notifications.to_a.size).to eq(1)
|
282
|
+
expect(notifications.first).to eq(@notification_1)
|
283
|
+
end
|
284
|
+
|
274
285
|
notifications = ActivityNotification::Notification.filtered_by_options({ custom_filter: { key: @key_2 } })
|
275
|
-
expect(notifications.size).to eq(1)
|
286
|
+
expect(notifications.to_a.size).to eq(1)
|
276
287
|
expect(notifications.first).to eq(@notification_2)
|
277
288
|
end
|
278
289
|
end
|
@@ -280,7 +291,7 @@ describe ActivityNotification::Notification, type: :model do
|
|
280
291
|
context 'with no options' do
|
281
292
|
it "works with filtered_by_options scope" do
|
282
293
|
notifications = ActivityNotification::Notification.filtered_by_options
|
283
|
-
expect(notifications.size).to eq(2)
|
294
|
+
expect(notifications.to_a.size).to eq(2)
|
284
295
|
end
|
285
296
|
end
|
286
297
|
end
|
@@ -299,14 +310,14 @@ describe ActivityNotification::Notification, type: :model do
|
|
299
310
|
|
300
311
|
it "works with latest_order scope" do
|
301
312
|
notifications = ActivityNotification::Notification.latest_order
|
302
|
-
expect(notifications.size).to eq(4)
|
313
|
+
expect(notifications.to_a.size).to eq(4)
|
303
314
|
expect(notifications.first).to eq(@latest_notification)
|
304
315
|
expect(notifications.last).to eq(@earliest_notification)
|
305
316
|
end
|
306
317
|
|
307
318
|
it "works with earliest_order scope" do
|
308
319
|
notifications = ActivityNotification::Notification.earliest_order
|
309
|
-
expect(notifications.size).to eq(4)
|
320
|
+
expect(notifications.to_a.size).to eq(4)
|
310
321
|
expect(notifications.first).to eq(@earliest_notification)
|
311
322
|
expect(notifications.last).to eq(@latest_notification)
|
312
323
|
end
|
@@ -92,9 +92,12 @@ describe ActivityNotification::Subscription, type: :model do
|
|
92
92
|
|
93
93
|
context 'with custom_filter options' do
|
94
94
|
it "works with filtered_by_options scope" do
|
95
|
-
|
96
|
-
|
97
|
-
|
95
|
+
if ActivityNotification.config.orm == :active_record
|
96
|
+
subscriptions = ActivityNotification::Subscription.filtered_by_options({ custom_filter: ["key = ?", @key_1] })
|
97
|
+
expect(subscriptions.size).to eq(1)
|
98
|
+
expect(subscriptions.first).to eq(@subscription_1)
|
99
|
+
end
|
100
|
+
|
98
101
|
subscriptions = ActivityNotification::Subscription.filtered_by_options({ custom_filter: { key: @key_2 } })
|
99
102
|
expect(subscriptions.size).to eq(1)
|
100
103
|
expect(subscriptions.first).to eq(@subscription_2)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'activity_notification/optional_targets/amazon_sns'
|
2
2
|
describe ActivityNotification::OptionalTarget::AmazonSNS do
|
3
|
-
let(:test_instance) { ActivityNotification::OptionalTarget::AmazonSNS.new }
|
3
|
+
let(:test_instance) { ActivityNotification::OptionalTarget::AmazonSNS.new(skip_initializing_target: true) }
|
4
4
|
|
5
5
|
describe "as public instance methods" do
|
6
6
|
describe "#to_optional_target_name" do
|
@@ -12,16 +12,19 @@ describe ActivityNotification::OptionalTarget::AmazonSNS do
|
|
12
12
|
describe "#initialize_target" do
|
13
13
|
#TODO
|
14
14
|
it "does not raise NotImplementedError" do
|
15
|
-
|
16
|
-
.
|
15
|
+
begin
|
16
|
+
test_instance.initialize_target
|
17
|
+
rescue Aws::Errors::MissingRegionError
|
18
|
+
# Rescue for CI without AWS client configuration
|
19
|
+
end
|
17
20
|
end
|
18
21
|
end
|
19
22
|
|
20
23
|
describe "#notify" do
|
21
24
|
#TODO
|
22
|
-
it "
|
25
|
+
it "does not raise NotImplementedError but NoMethodError" do
|
23
26
|
expect { test_instance.notify(create(:notification)) }
|
24
|
-
.
|
27
|
+
.to raise_error(NoMethodError)
|
25
28
|
end
|
26
29
|
end
|
27
30
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
describe ActivityNotification::OptionalTarget::Base do
|
2
|
-
let(:test_instance) {
|
2
|
+
let(:test_instance) {
|
3
|
+
ActivityNotification::OptionalTarget::Base.new(skip_initializing_target: true)
|
4
|
+
}
|
3
5
|
|
4
6
|
describe "as public instance methods" do
|
5
7
|
describe "#to_optional_target_name" do
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'activity_notification/optional_targets/slack'
|
2
2
|
describe ActivityNotification::OptionalTarget::Slack do
|
3
|
-
let(:test_instance) { ActivityNotification::OptionalTarget::Slack.new }
|
3
|
+
let(:test_instance) { ActivityNotification::OptionalTarget::Slack.new(skip_initializing_target: true) }
|
4
4
|
|
5
5
|
describe "as public instance methods" do
|
6
6
|
describe "#to_optional_target_name" do
|
@@ -11,17 +11,17 @@ describe ActivityNotification::OptionalTarget::Slack do
|
|
11
11
|
|
12
12
|
describe "#initialize_target" do
|
13
13
|
#TODO
|
14
|
-
it "does not raise NotImplementedError" do
|
14
|
+
it "does not raise NotImplementedError but URI::InvalidURIError" do
|
15
15
|
expect { test_instance.initialize_target }
|
16
|
-
.
|
16
|
+
.to raise_error(URI::InvalidURIError)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
describe "#notify" do
|
21
21
|
#TODO
|
22
|
-
it "
|
22
|
+
it "does not raise NotImplementedError but NoMethodError" do
|
23
23
|
expect { test_instance.notify(create(:notification)) }
|
24
|
-
.
|
24
|
+
.to raise_error(NoMethodError)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -7,7 +7,7 @@ class Comment < ActiveRecord::Base
|
|
7
7
|
acts_as_notifiable :users,
|
8
8
|
targets: ->(comment, key) { ([comment.article.user] + comment.article.commented_users.to_a - [comment.user]).uniq },
|
9
9
|
group: :article, notifier: :user, email_allowed: true,
|
10
|
-
parameters: { test_default_param
|
10
|
+
parameters: { 'test_default_param' => '1' },
|
11
11
|
notifiable_path: :article_notifiable_path,
|
12
12
|
printable_name: ->(comment) { "comment \"#{comment.body}\"" },
|
13
13
|
dependent_notifications: :update_group_and_delete_all
|