activity_notification 0.0.10 → 1.0.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 +6 -0
- data/Gemfile +6 -3
- data/Gemfile.lock +74 -58
- data/README.md +53 -26
- data/activity_notification.gemspec +2 -0
- data/app/controllers/activity_notification/notifications_controller.rb +4 -4
- data/app/mailers/activity_notification/mailer.rb +9 -3
- data/app/views/activity_notification/mailer/default/default.html.erb +9 -4
- data/app/views/activity_notification/mailer/default/default.text.erb +10 -0
- data/app/views/activity_notification/notifications/default/_default.html.erb +173 -34
- data/app/views/activity_notification/notifications/default/_index.html.erb +119 -11
- data/app/views/activity_notification/notifications/default/destroy.js.erb +2 -2
- data/app/views/activity_notification/notifications/default/index.html.erb +25 -14
- data/app/views/activity_notification/notifications/default/open.js.erb +2 -2
- data/app/views/activity_notification/notifications/default/open_all.js.erb +2 -2
- data/app/views/activity_notification/notifications/default/show.html.erb +1 -1
- data/gemfiles/Gemfile.rails-4.2 +0 -2
- data/gemfiles/Gemfile.rails-4.2.lock +3 -3
- data/gemfiles/Gemfile.rails-5.0 +1 -3
- data/lib/activity_notification.rb +10 -9
- data/lib/activity_notification/apis/notification_api.rb +108 -14
- data/lib/activity_notification/common.rb +11 -2
- data/lib/activity_notification/config.rb +13 -13
- data/lib/activity_notification/helpers/view_helpers.rb +26 -4
- data/lib/activity_notification/mailers/helpers.rb +8 -4
- data/lib/activity_notification/models.rb +4 -0
- data/lib/activity_notification/models/concerns/group.rb +32 -0
- data/lib/activity_notification/models/concerns/notifiable.rb +60 -32
- data/lib/activity_notification/models/concerns/notifier.rb +17 -1
- data/lib/activity_notification/models/concerns/target.rb +114 -55
- data/lib/activity_notification/models/notification.rb +26 -25
- data/lib/activity_notification/rails.rb +1 -0
- data/lib/activity_notification/renderable.rb +8 -3
- data/lib/activity_notification/roles/acts_as_common.rb +28 -0
- data/lib/activity_notification/roles/acts_as_group.rb +38 -0
- data/lib/activity_notification/roles/acts_as_notifiable.rb +56 -22
- data/lib/activity_notification/roles/acts_as_notifier.rb +25 -2
- data/lib/activity_notification/roles/acts_as_target.rb +27 -9
- data/lib/activity_notification/version.rb +1 -1
- data/lib/generators/templates/activity_notification.rb +1 -1
- data/spec/concerns/apis/notification_api_spec.rb +361 -2
- data/spec/concerns/common_spec.rb +36 -0
- data/spec/concerns/models/group_spec.rb +61 -0
- data/spec/concerns/models/notifiable_spec.rb +37 -0
- data/spec/concerns/models/notifier_spec.rb +48 -0
- data/spec/concerns/models/target_spec.rb +81 -31
- data/spec/factories/dummy/dummy_group.rb +4 -0
- data/spec/helpers/view_helpers_spec.rb +13 -0
- data/spec/mailers/mailer_spec.rb +8 -1
- data/spec/models/dummy/dummy_group_spec.rb +6 -0
- data/spec/rails_app/app/assets/stylesheets/application.css +15 -0
- data/spec/rails_app/app/assets/stylesheets/reset.css +85 -0
- data/spec/rails_app/app/assets/stylesheets/style.css +244 -0
- data/spec/rails_app/app/controllers/articles_controller.rb +1 -1
- data/spec/rails_app/app/models/admin.rb +2 -1
- data/spec/rails_app/app/models/article.rb +9 -2
- data/spec/rails_app/app/models/comment.rb +8 -2
- data/spec/rails_app/app/models/dummy/dummy_group.rb +4 -0
- data/spec/rails_app/app/models/user.rb +8 -3
- data/spec/rails_app/app/views/articles/_form.html.erb +14 -10
- data/spec/rails_app/app/views/articles/edit.html.erb +8 -6
- data/spec/rails_app/app/views/articles/index.html.erb +59 -67
- data/spec/rails_app/app/views/articles/new.html.erb +7 -5
- data/spec/rails_app/app/views/articles/show.html.erb +47 -36
- data/spec/rails_app/app/views/layouts/_header.html.erb +36 -9
- data/spec/rails_app/app/views/layouts/application.html.erb +8 -6
- data/spec/rails_app/config/environments/development.rb +9 -0
- data/spec/rails_app/config/initializers/activity_notification.rb +1 -1
- data/spec/rails_app/db/schema.rb +14 -20
- data/spec/rails_app/db/seeds.rb +5 -5
- data/spec/rails_app/lib/mailer_previews/mailer_preview.rb +13 -0
- data/spec/roles/acts_as_group_spec.rb +32 -0
- data/spec/roles/acts_as_notifiable_spec.rb +1 -1
- data/spec/roles/acts_as_notifier_spec.rb +15 -0
- data/spec/roles/acts_as_target_spec.rb +1 -1
- metadata +52 -2
@@ -145,6 +145,42 @@ shared_examples_for :common do
|
|
145
145
|
end
|
146
146
|
end
|
147
147
|
end
|
148
|
+
|
149
|
+
describe "#to_class_name" do
|
150
|
+
it "returns resource name" do
|
151
|
+
expect(create(:user).to_class_name).to eq 'User'
|
152
|
+
expect(test_instance.to_class_name).to eq test_instance.class.name
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
describe "#to_resource_name" do
|
157
|
+
it "returns singularized model name (resource name)" do
|
158
|
+
expect(create(:user).to_resource_name).to eq 'user'
|
159
|
+
expect(test_instance.to_resource_name).to eq test_instance.class.name.demodulize.singularize.underscore
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
describe "#to_resources_name" do
|
164
|
+
it "returns pluralized model name (resources name)" do
|
165
|
+
expect(create(:user).to_resources_name).to eq 'users'
|
166
|
+
expect(test_instance.to_resources_name).to eq test_instance.class.name.demodulize.pluralize.underscore
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
describe "#printable_type" do
|
171
|
+
it "returns printable model type name to be humanized" do
|
172
|
+
expect(create(:user).printable_type).to eq 'User'
|
173
|
+
expect(test_instance.printable_type).to eq test_instance.class.name.demodulize.humanize
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
describe "#printable_name" do
|
178
|
+
it "returns printable model name to show in view or email" do
|
179
|
+
user = create(:user)
|
180
|
+
expect(user.printable_name).to eq "User (#{user.id})"
|
181
|
+
expect(test_instance.printable_name).to eq "#{test_instance.printable_type} (#{test_instance.id})"
|
182
|
+
end
|
183
|
+
end
|
148
184
|
end
|
149
185
|
|
150
186
|
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
shared_examples_for :group do
|
2
|
+
let(:test_class_name) { described_class.to_s.underscore.split('/').last.to_sym }
|
3
|
+
let(:test_instance) { create(test_class_name) }
|
4
|
+
|
5
|
+
describe "as public class methods" do
|
6
|
+
describe ".available_as_group?" do
|
7
|
+
it "returns true" do
|
8
|
+
expect(described_class.available_as_group?).to be_truthy
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe ".set_group_class_defaults" do
|
13
|
+
it "set parameter fields as default" do
|
14
|
+
described_class.set_group_class_defaults
|
15
|
+
expect(described_class._printable_notification_group_name).to eq(:printable_name)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "as public instance methods" do
|
21
|
+
before do
|
22
|
+
described_class.set_group_class_defaults
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "#printable_group_name" do
|
26
|
+
context "without any configuration" do
|
27
|
+
it "returns ActivityNotification::Common.printable_name" do
|
28
|
+
expect(test_instance.printable_group_name).to eq(test_instance.printable_name)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context "configured with a field" do
|
33
|
+
it "returns specified value" do
|
34
|
+
described_class._printable_notification_group_name = 'test_printable_name'
|
35
|
+
expect(test_instance.printable_group_name).to eq('test_printable_name')
|
36
|
+
end
|
37
|
+
|
38
|
+
it "returns specified symbol of field" do
|
39
|
+
described_class._printable_notification_group_name = :title
|
40
|
+
expect(test_instance.printable_group_name).to eq(test_instance.title)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "returns specified symbol of method" do
|
44
|
+
module AdditionalMethods
|
45
|
+
def custom_printable_name
|
46
|
+
'test_printable_name'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
test_instance.extend(AdditionalMethods)
|
50
|
+
described_class._printable_notification_group_name = :custom_printable_name
|
51
|
+
expect(test_instance.printable_group_name).to eq('test_printable_name')
|
52
|
+
end
|
53
|
+
|
54
|
+
it "returns specified lambda with single target argument" do
|
55
|
+
described_class._printable_notification_group_name = ->(target){ 'test_printable_name' }
|
56
|
+
expect(test_instance.printable_group_name).to eq('test_printable_name')
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -21,6 +21,7 @@ shared_examples_for :notifiable do
|
|
21
21
|
expect(described_class._notification_parameters).to eq({})
|
22
22
|
expect(described_class._notification_email_allowed).to eq({})
|
23
23
|
expect(described_class._notifiable_path).to eq({})
|
24
|
+
expect(described_class._printable_notifiable_name).to eq({})
|
24
25
|
end
|
25
26
|
end
|
26
27
|
end
|
@@ -403,6 +404,42 @@ shared_examples_for :notifiable do
|
|
403
404
|
end
|
404
405
|
end
|
405
406
|
|
407
|
+
describe "#printable_notifiable_name" do
|
408
|
+
context "without any configuration" do
|
409
|
+
it "returns ActivityNotification::Common.printable_name" do
|
410
|
+
expect(test_instance.printable_notifiable_name(test_target, 'dummy_key')).to eq(test_instance.printable_name)
|
411
|
+
end
|
412
|
+
end
|
413
|
+
|
414
|
+
context "configured with a field" do
|
415
|
+
it "returns specified value" do
|
416
|
+
described_class._printable_notifiable_name[:users] = 'test_printable_name'
|
417
|
+
expect(test_instance.printable_notifiable_name(test_target, 'dummy_key')).to eq('test_printable_name')
|
418
|
+
end
|
419
|
+
|
420
|
+
it "returns specified symbol of field" do
|
421
|
+
described_class._printable_notifiable_name[:users] = :title
|
422
|
+
expect(test_instance.printable_notifiable_name(test_target, 'dummy_key')).to eq(test_instance.title)
|
423
|
+
end
|
424
|
+
|
425
|
+
it "returns specified symbol of method" do
|
426
|
+
module AdditionalMethods
|
427
|
+
def custom_printable_name
|
428
|
+
'test_printable_name'
|
429
|
+
end
|
430
|
+
end
|
431
|
+
test_instance.extend(AdditionalMethods)
|
432
|
+
described_class._printable_notifiable_name[:users] = :custom_printable_name
|
433
|
+
expect(test_instance.printable_notifiable_name(test_target, 'dummy_key')).to eq('test_printable_name')
|
434
|
+
end
|
435
|
+
|
436
|
+
it "returns specified lambda with single target argument" do
|
437
|
+
described_class._printable_notifiable_name[:users] = ->(target){ 'test_printable_name' }
|
438
|
+
expect(test_instance.printable_notifiable_name(test_target, 'dummy_key')).to eq('test_printable_name')
|
439
|
+
end
|
440
|
+
end
|
441
|
+
end
|
442
|
+
|
406
443
|
describe "#notify" do
|
407
444
|
it "is an alias of ActivityNotification::Notification.notify" do
|
408
445
|
expect(ActivityNotification::Notification).to receive(:notify)
|
@@ -18,6 +18,54 @@ shared_examples_for :notifier do
|
|
18
18
|
expect(described_class.available_as_notifier?).to be_truthy
|
19
19
|
end
|
20
20
|
end
|
21
|
+
|
22
|
+
describe ".set_notifier_class_defaults" do
|
23
|
+
it "set parameter fields as default" do
|
24
|
+
described_class.set_notifier_class_defaults
|
25
|
+
expect(described_class._printable_notifier_name).to eq(:printable_name)
|
26
|
+
end
|
27
|
+
end
|
21
28
|
end
|
22
29
|
|
30
|
+
describe "as public instance methods" do
|
31
|
+
before do
|
32
|
+
described_class.set_notifier_class_defaults
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "#printable_notifier_name" do
|
36
|
+
context "without any configuration" do
|
37
|
+
it "returns ActivityNotification::Common.printable_name" do
|
38
|
+
expect(test_instance.printable_notifier_name).to eq(test_instance.printable_name)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context "configured with a field" do
|
43
|
+
it "returns specified value" do
|
44
|
+
described_class._printable_notifier_name = 'test_printable_name'
|
45
|
+
expect(test_instance.printable_notifier_name).to eq('test_printable_name')
|
46
|
+
end
|
47
|
+
|
48
|
+
it "returns specified symbol of field" do
|
49
|
+
described_class._printable_notifier_name = :name
|
50
|
+
expect(test_instance.printable_notifier_name).to eq(test_instance.name)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "returns specified symbol of method" do
|
54
|
+
module AdditionalMethods
|
55
|
+
def custom_printable_name
|
56
|
+
'test_printable_name'
|
57
|
+
end
|
58
|
+
end
|
59
|
+
test_instance.extend(AdditionalMethods)
|
60
|
+
described_class._printable_notifier_name = :custom_printable_name
|
61
|
+
expect(test_instance.printable_notifier_name).to eq('test_printable_name')
|
62
|
+
end
|
63
|
+
|
64
|
+
it "returns specified lambda with single target argument" do
|
65
|
+
described_class._printable_notifier_name = ->(target){ 'test_printable_name' }
|
66
|
+
expect(test_instance.printable_notifier_name).to eq('test_printable_name')
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
23
71
|
end
|
@@ -24,8 +24,10 @@ shared_examples_for :target do
|
|
24
24
|
describe ".set_target_class_defaults" do
|
25
25
|
it "set parameter fields as default" do
|
26
26
|
described_class.set_target_class_defaults
|
27
|
-
expect(described_class._notification_email).to
|
28
|
-
expect(described_class._notification_email_allowed).to
|
27
|
+
expect(described_class._notification_email).to eq(nil)
|
28
|
+
expect(described_class._notification_email_allowed).to eq(ActivityNotification.config.email_enabled)
|
29
|
+
expect(described_class._notification_devise_resource).to be_a_kind_of(Proc)
|
30
|
+
expect(described_class._printable_notification_target_name).to eq(:printable_name)
|
29
31
|
end
|
30
32
|
end
|
31
33
|
end
|
@@ -65,7 +67,7 @@ shared_examples_for :target do
|
|
65
67
|
expect(test_instance.mailer_to).to eq('test@example.com')
|
66
68
|
end
|
67
69
|
|
68
|
-
it "returns specified lambda with single
|
70
|
+
it "returns specified lambda with single target argument" do
|
69
71
|
described_class._notification_email = ->(target){ 'test@example.com' }
|
70
72
|
expect(test_instance.mailer_to).to eq('test@example.com')
|
71
73
|
end
|
@@ -171,6 +173,42 @@ shared_examples_for :target do
|
|
171
173
|
end
|
172
174
|
end
|
173
175
|
|
176
|
+
describe "#printable_target_name" do
|
177
|
+
context "without any configuration" do
|
178
|
+
it "returns ActivityNotification::Common.printable_name" do
|
179
|
+
expect(test_instance.printable_target_name).to eq(test_instance.printable_name)
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
context "configured with a field" do
|
184
|
+
it "returns specified value" do
|
185
|
+
described_class._printable_notification_target_name = 'test_printable_name'
|
186
|
+
expect(test_instance.printable_target_name).to eq('test_printable_name')
|
187
|
+
end
|
188
|
+
|
189
|
+
it "returns specified symbol of field" do
|
190
|
+
described_class._printable_notification_target_name = :name
|
191
|
+
expect(test_instance.printable_target_name).to eq(test_instance.name)
|
192
|
+
end
|
193
|
+
|
194
|
+
it "returns specified symbol of method" do
|
195
|
+
module AdditionalMethods
|
196
|
+
def custom_printable_name
|
197
|
+
'test_printable_name'
|
198
|
+
end
|
199
|
+
end
|
200
|
+
test_instance.extend(AdditionalMethods)
|
201
|
+
described_class._printable_notification_target_name = :custom_printable_name
|
202
|
+
expect(test_instance.printable_target_name).to eq('test_printable_name')
|
203
|
+
end
|
204
|
+
|
205
|
+
it "returns specified lambda with single target argument" do
|
206
|
+
described_class._printable_notification_target_name = ->(target){ 'test_printable_name' }
|
207
|
+
expect(test_instance.printable_target_name).to eq('test_printable_name')
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
174
212
|
describe "#unopened_notification_count" do
|
175
213
|
it "returns count of unopened notification index" do
|
176
214
|
create(:notification, target: test_instance)
|
@@ -212,24 +250,28 @@ shared_examples_for :target do
|
|
212
250
|
before do
|
213
251
|
create(:notification, target: test_instance)
|
214
252
|
create(:notification, target: test_instance)
|
253
|
+
create(:notification, target: test_instance).open!
|
215
254
|
end
|
216
255
|
|
217
256
|
it "calls unopened_notification_index" do
|
218
|
-
expect(test_instance).to receive(:unopened_notification_index)
|
257
|
+
expect(test_instance).to receive(:unopened_notification_index).at_least(:once)
|
219
258
|
test_instance.notification_index
|
220
259
|
end
|
221
260
|
|
222
261
|
context "without limit" do
|
223
|
-
it "returns the
|
224
|
-
expect(test_instance.notification_index).to eq(test_instance.unopened_notification_index)
|
225
|
-
expect(test_instance.notification_index
|
262
|
+
it "returns the combined array of unopened_notification_index and opened_notification_index" do
|
263
|
+
expect(test_instance.notification_index[0]).to eq(test_instance.unopened_notification_index[0])
|
264
|
+
expect(test_instance.notification_index[1]).to eq(test_instance.unopened_notification_index[1])
|
265
|
+
expect(test_instance.notification_index[2]).to eq(test_instance.opened_notification_index[0])
|
266
|
+
expect(test_instance.notification_index.size).to eq(3)
|
226
267
|
end
|
227
268
|
end
|
228
269
|
|
229
270
|
context "with limit" do
|
230
271
|
it "returns the same as unopened_notification_index with limit" do
|
231
|
-
|
232
|
-
expect(test_instance.notification_index(
|
272
|
+
options = { limit: 1 }
|
273
|
+
expect(test_instance.notification_index(options)).to eq(test_instance.unopened_notification_index(options))
|
274
|
+
expect(test_instance.notification_index(options).size).to eq(1)
|
233
275
|
end
|
234
276
|
end
|
235
277
|
end
|
@@ -241,7 +283,7 @@ shared_examples_for :target do
|
|
241
283
|
end
|
242
284
|
|
243
285
|
it "calls unopened_notification_index" do
|
244
|
-
expect(test_instance).to receive(:opened_notification_index)
|
286
|
+
expect(test_instance).to receive(:opened_notification_index).at_least(:once)
|
245
287
|
test_instance.notification_index
|
246
288
|
end
|
247
289
|
|
@@ -254,8 +296,9 @@ shared_examples_for :target do
|
|
254
296
|
|
255
297
|
context "with limit" do
|
256
298
|
it "returns the same as opened_notification_index with limit" do
|
257
|
-
|
258
|
-
expect(test_instance.notification_index(
|
299
|
+
options = { limit: 1 }
|
300
|
+
expect(test_instance.notification_index(options)).to eq(test_instance.opened_notification_index(options))
|
301
|
+
expect(test_instance.notification_index(options).size).to eq(1)
|
259
302
|
end
|
260
303
|
end
|
261
304
|
end
|
@@ -298,8 +341,9 @@ shared_examples_for :target do
|
|
298
341
|
|
299
342
|
context "with limit" do
|
300
343
|
it "returns unopened notification index with limit" do
|
301
|
-
|
302
|
-
expect(test_instance.unopened_notification_index(
|
344
|
+
options = { limit: 1 }
|
345
|
+
expect(test_instance.unopened_notification_index(options).size).to eq(1)
|
346
|
+
expect(test_instance.unopened_notification_index(options).first).to eq(@notification_2)
|
303
347
|
end
|
304
348
|
end
|
305
349
|
end
|
@@ -319,7 +363,7 @@ shared_examples_for :target do
|
|
319
363
|
describe "#opened_notification_index" do
|
320
364
|
context "when the target has no notifications" do
|
321
365
|
it "returns empty records" do
|
322
|
-
expect(test_instance.opened_notification_index
|
366
|
+
expect(test_instance.opened_notification_index).to be_empty
|
323
367
|
end
|
324
368
|
end
|
325
369
|
|
@@ -330,12 +374,12 @@ shared_examples_for :target do
|
|
330
374
|
end
|
331
375
|
|
332
376
|
context "without limit" do
|
333
|
-
it "uses ActivityNotification.config.
|
334
|
-
|
335
|
-
ActivityNotification.config.
|
336
|
-
expect(test_instance.opened_notification_index
|
337
|
-
expect(test_instance.opened_notification_index
|
338
|
-
ActivityNotification.config.
|
377
|
+
it "uses ActivityNotification.config.opened_index_limit as limit" do
|
378
|
+
configured_opened_index_limit = ActivityNotification.config.opened_index_limit
|
379
|
+
ActivityNotification.config.opened_index_limit = 1
|
380
|
+
expect(test_instance.opened_notification_index.size).to eq(1)
|
381
|
+
expect(test_instance.opened_notification_index.first).to eq(@notification_2)
|
382
|
+
ActivityNotification.config.opened_index_limit = configured_opened_index_limit
|
339
383
|
end
|
340
384
|
|
341
385
|
it "returns opened notification index" do
|
@@ -361,8 +405,9 @@ shared_examples_for :target do
|
|
361
405
|
|
362
406
|
context "with limit" do
|
363
407
|
it "returns opened notification index with limit" do
|
364
|
-
|
365
|
-
expect(test_instance.opened_notification_index(
|
408
|
+
options = { limit: 1 }
|
409
|
+
expect(test_instance.opened_notification_index(options).size).to eq(1)
|
410
|
+
expect(test_instance.opened_notification_index(options).first).to eq(@notification_2)
|
366
411
|
end
|
367
412
|
end
|
368
413
|
end
|
@@ -410,24 +455,28 @@ shared_examples_for :target do
|
|
410
455
|
before do
|
411
456
|
create(:notification, target: test_instance)
|
412
457
|
create(:notification, target: test_instance)
|
458
|
+
create(:notification, target: test_instance).open!
|
413
459
|
end
|
414
460
|
|
415
461
|
it "calls unopened_notification_index_with_attributes" do
|
416
|
-
expect(test_instance).to receive(:unopened_notification_index_with_attributes)
|
462
|
+
expect(test_instance).to receive(:unopened_notification_index_with_attributes).at_least(:once)
|
417
463
|
test_instance.notification_index_with_attributes
|
418
464
|
end
|
419
465
|
|
420
466
|
context "without limit" do
|
421
|
-
it "returns the
|
422
|
-
expect(test_instance.notification_index_with_attributes).to eq(test_instance.
|
423
|
-
expect(test_instance.notification_index_with_attributes
|
467
|
+
it "returns the combined array of unopened_notification_index and opened_notification_index" do
|
468
|
+
expect(test_instance.notification_index_with_attributes[0]).to eq(test_instance.unopened_notification_index[0])
|
469
|
+
expect(test_instance.notification_index_with_attributes[1]).to eq(test_instance.unopened_notification_index[1])
|
470
|
+
expect(test_instance.notification_index_with_attributes[2]).to eq(test_instance.opened_notification_index[0])
|
471
|
+
expect(test_instance.notification_index.size).to eq(3)
|
424
472
|
end
|
425
473
|
end
|
426
474
|
|
427
475
|
context "with limit" do
|
428
476
|
it "returns the same as unopened_notification_index_with_attributes with limit" do
|
429
|
-
|
430
|
-
expect(test_instance.notification_index_with_attributes(
|
477
|
+
options = { limit: 1 }
|
478
|
+
expect(test_instance.notification_index_with_attributes(options)).to eq(test_instance.unopened_notification_index_with_attributes(options))
|
479
|
+
expect(test_instance.notification_index_with_attributes(options).size).to eq(1)
|
431
480
|
end
|
432
481
|
end
|
433
482
|
end
|
@@ -452,8 +501,9 @@ shared_examples_for :target do
|
|
452
501
|
|
453
502
|
context "with limit" do
|
454
503
|
it "returns the same as opened_notification_index_with_attributes with limit" do
|
455
|
-
|
456
|
-
expect(test_instance.notification_index_with_attributes(
|
504
|
+
options = { limit: 1 }
|
505
|
+
expect(test_instance.notification_index_with_attributes(options)).to eq(test_instance.opened_notification_index_with_attributes(options))
|
506
|
+
expect(test_instance.notification_index_with_attributes(options).size).to eq(1)
|
457
507
|
end
|
458
508
|
end
|
459
509
|
end
|
@@ -198,6 +198,12 @@ describe ActivityNotification::ViewHelpers, type: :helper do
|
|
198
198
|
end
|
199
199
|
end
|
200
200
|
|
201
|
+
describe '#notifications_path_for' do
|
202
|
+
it "returns path for the notification target" do
|
203
|
+
expect(notifications_path_for(target_user))
|
204
|
+
.to eq(user_notifications_path(target_user))
|
205
|
+
end
|
206
|
+
end
|
201
207
|
|
202
208
|
describe '#notification_path_for' do
|
203
209
|
it "returns path for the notification target" do
|
@@ -227,6 +233,13 @@ describe ActivityNotification::ViewHelpers, type: :helper do
|
|
227
233
|
end
|
228
234
|
end
|
229
235
|
|
236
|
+
describe '#notifications_url_for' do
|
237
|
+
it "returns url for the notification target" do
|
238
|
+
expect(notifications_url_for(target_user))
|
239
|
+
.to eq(user_notifications_url(target_user))
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
230
243
|
describe '#notification_url_for' do
|
231
244
|
it "returns url for the notification target" do
|
232
245
|
expect(notification_url_for(notification))
|