activity_notification 0.0.9 → 0.0.10
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/.gitignore +2 -0
- data/.travis.yml +5 -0
- data/.yardopts +3 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +50 -44
- data/README.md +242 -81
- data/Rakefile +13 -13
- data/activity_notification.gemspec +6 -8
- data/app/controllers/activity_notification/notifications_controller.rb +89 -11
- data/app/controllers/activity_notification/notifications_with_devise_controller.rb +12 -3
- data/app/mailers/activity_notification/mailer.rb +3 -0
- data/gemfiles/Gemfile.rails-4.2 +13 -0
- data/gemfiles/Gemfile.rails-4.2.lock +190 -0
- data/gemfiles/Gemfile.rails-5.0 +14 -0
- data/gemfiles/Gemfile.rails-5.0.lock +201 -0
- data/lib/activity_notification.rb +10 -6
- data/lib/activity_notification/apis/notification_api.rb +137 -27
- data/lib/activity_notification/common.rb +48 -24
- data/lib/activity_notification/config.rb +68 -10
- data/lib/activity_notification/controllers/store_controller.rb +13 -5
- data/lib/activity_notification/helpers/polymorphic_helpers.rb +17 -3
- data/lib/activity_notification/helpers/view_helpers.rb +161 -45
- data/lib/activity_notification/mailers/helpers.rb +121 -83
- data/lib/activity_notification/models/concerns/notifiable.rb +162 -69
- data/lib/activity_notification/models/concerns/notifier.rb +2 -0
- data/lib/activity_notification/models/concerns/target.rb +124 -25
- data/lib/activity_notification/models/notification.rb +168 -4
- data/lib/activity_notification/rails/routes.rb +50 -48
- data/lib/activity_notification/renderable.rb +106 -26
- data/lib/activity_notification/roles/acts_as_notifiable.rb +99 -26
- data/lib/activity_notification/roles/acts_as_notifier.rb +3 -0
- data/lib/activity_notification/roles/acts_as_target.rb +70 -0
- data/lib/activity_notification/version.rb +1 -1
- data/lib/generators/activity_notification/active_record/migration_generator.rb +3 -1
- data/lib/generators/activity_notification/controllers_generator.rb +5 -0
- data/lib/generators/activity_notification/install_generator.rb +7 -3
- data/lib/generators/activity_notification/models/notification_generator.rb +4 -2
- data/lib/generators/activity_notification/views_generator.rb +20 -0
- data/spec/concerns/apis/notification_api_spec.rb +105 -36
- data/spec/concerns/common_spec.rb +1 -1
- data/spec/concerns/models/notifiable_spec.rb +2 -2
- data/spec/concerns/models/notifier_spec.rb +1 -1
- data/spec/concerns/models/target_spec.rb +9 -8
- data/spec/controllers/notifications_controller_shared_examples.rb +101 -28
- data/spec/controllers/notifications_with_devise_controller_spec.rb +14 -4
- data/spec/helpers/view_helpers_spec.rb +3 -3
- data/spec/mailers/mailer_spec.rb +1 -1
- data/spec/models/notification_spec.rb +57 -3
- data/spec/rails_app/app/models/article.rb +1 -2
- data/spec/rails_app/app/models/comment.rb +8 -6
- data/spec/rails_app/app/models/user.rb +1 -1
- data/spec/rails_app/app/views/layouts/_header.html.erb +2 -0
- data/spec/rails_app/config/application.rb +3 -1
- data/spec/rails_app/config/environment.rb +12 -2
- data/spec/rails_app/config/environments/test.rb +11 -2
- data/spec/roles/acts_as_notifiable_spec.rb +2 -2
- data/spec/roles/acts_as_notifier_spec.rb +1 -1
- data/spec/roles/acts_as_target_spec.rb +3 -3
- data/spec/spec_helper.rb +6 -0
- metadata +35 -40
- data/spec/rails_app/app/models/concerns/.keep +0 -0
@@ -3,7 +3,7 @@ shared_examples_for :common do
|
|
3
3
|
let(:test_instance) { create(test_class_name) }
|
4
4
|
|
5
5
|
describe "as public ActivityNotification methods with described class" do
|
6
|
-
describe "
|
6
|
+
describe ".resolve_value" do
|
7
7
|
before do
|
8
8
|
allow(ActivityNotification).to receive(:get_controller).and_return('StubController')
|
9
9
|
end
|
@@ -6,13 +6,13 @@ shared_examples_for :notifiable do
|
|
6
6
|
include Rails.application.routes.url_helpers
|
7
7
|
|
8
8
|
describe "as public class methods" do
|
9
|
-
describe "
|
9
|
+
describe ".available_as_notifiable?" do
|
10
10
|
it "returns true" do
|
11
11
|
expect(described_class.available_as_notifiable?).to be_truthy
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
describe "
|
15
|
+
describe ".set_notifiable_class_defaults" do
|
16
16
|
it "set parameter fields as default" do
|
17
17
|
described_class.set_notifiable_class_defaults
|
18
18
|
expect(described_class._notification_targets).to eq({})
|
@@ -10,17 +10,18 @@ shared_examples_for :target do
|
|
10
10
|
expect(test_instance.notifications.count).to eq(2)
|
11
11
|
expect(test_instance.notifications.earliest).to eq(notification_1)
|
12
12
|
expect(test_instance.notifications.latest).to eq(notification_2)
|
13
|
+
expect(test_instance.notifications).to eq (ActivityNotification::Notification.filtered_by_target(test_instance))
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
16
17
|
describe "as public class methods" do
|
17
|
-
describe "
|
18
|
+
describe ".available_as_target?" do
|
18
19
|
it "returns true" do
|
19
20
|
expect(described_class.available_as_target?).to be_truthy
|
20
21
|
end
|
21
22
|
end
|
22
23
|
|
23
|
-
describe "
|
24
|
+
describe ".set_target_class_defaults" do
|
24
25
|
it "set parameter fields as default" do
|
25
26
|
described_class.set_target_class_defaults
|
26
27
|
expect(described_class._notification_email).to eq(nil)
|
@@ -125,20 +126,20 @@ shared_examples_for :target do
|
|
125
126
|
|
126
127
|
describe "#authenticated_with_devise?" do
|
127
128
|
context "without any configuration" do
|
128
|
-
context "when the current
|
129
|
+
context "when the current devise resource and called target are defferent class instance" do
|
129
130
|
it "raises TypeError" do
|
130
131
|
expect { test_instance.authenticated_with_devise?(test_notifiable) }
|
131
132
|
.to raise_error(TypeError, /Defferent type of .+ has been passed to .+ You have to override .+ /)
|
132
133
|
end
|
133
134
|
end
|
134
135
|
|
135
|
-
context "when the current
|
136
|
+
context "when the current devise resource equals called target" do
|
136
137
|
it "returns true" do
|
137
138
|
expect(test_instance.authenticated_with_devise?(test_instance)).to be_truthy
|
138
139
|
end
|
139
140
|
end
|
140
141
|
|
141
|
-
context "when the current
|
142
|
+
context "when the current devise resource does not equal called target" do
|
142
143
|
it "returns false" do
|
143
144
|
expect(test_instance.authenticated_with_devise?(create(test_class_name))).to be_falsey
|
144
145
|
end
|
@@ -146,7 +147,7 @@ shared_examples_for :target do
|
|
146
147
|
end
|
147
148
|
|
148
149
|
context "configured with a field" do
|
149
|
-
context "when the current
|
150
|
+
context "when the current devise resource and called target are defferent class instance" do
|
150
151
|
it "raises TypeError" do
|
151
152
|
described_class._notification_devise_resource = test_notifiable
|
152
153
|
expect { test_instance.authenticated_with_devise?(test_instance) }
|
@@ -154,14 +155,14 @@ shared_examples_for :target do
|
|
154
155
|
end
|
155
156
|
end
|
156
157
|
|
157
|
-
context "when the current
|
158
|
+
context "when the current devise resource equals called target" do
|
158
159
|
it "returns true" do
|
159
160
|
described_class._notification_devise_resource = test_notifiable
|
160
161
|
expect(test_instance.authenticated_with_devise?(test_notifiable)).to be_truthy
|
161
162
|
end
|
162
163
|
end
|
163
164
|
|
164
|
-
context "when the current
|
165
|
+
context "when the current devise resource does not equal called target" do
|
165
166
|
it "returns false" do
|
166
167
|
described_class._notification_devise_resource = test_instance
|
167
168
|
expect(test_instance.authenticated_with_devise?(create(test_class_name))).to be_falsey
|
@@ -5,7 +5,7 @@ shared_examples_for :notification_controller do
|
|
5
5
|
context "with target_type and target_id parameters" do
|
6
6
|
before do
|
7
7
|
@notification = create(:notification, target: test_target)
|
8
|
-
|
8
|
+
get_with_compatibility :index, target_params.merge({ target_id: test_target, typed_target_param => 'dummy' }), valid_session
|
9
9
|
end
|
10
10
|
|
11
11
|
it "returns 200 as http status code" do
|
@@ -24,7 +24,7 @@ shared_examples_for :notification_controller do
|
|
24
24
|
context "with target_type and (typed_target)_id parameters" do
|
25
25
|
before do
|
26
26
|
@notification = create(:notification, target: test_target)
|
27
|
-
|
27
|
+
get_with_compatibility :index, target_params.merge({ typed_target_param => test_target }), valid_session
|
28
28
|
end
|
29
29
|
|
30
30
|
it "returns 200 as http status code" do
|
@@ -43,7 +43,7 @@ shared_examples_for :notification_controller do
|
|
43
43
|
context "without target_type parameters" do
|
44
44
|
before do
|
45
45
|
@notification = create(:notification, target: test_target)
|
46
|
-
|
46
|
+
get_with_compatibility :index, { typed_target_param => test_target }, valid_session
|
47
47
|
end
|
48
48
|
|
49
49
|
it "returns 400 as http status code" do
|
@@ -58,7 +58,7 @@ shared_examples_for :notification_controller do
|
|
58
58
|
|
59
59
|
it "raises ActiveRecord::RecordNotFound" do
|
60
60
|
expect {
|
61
|
-
|
61
|
+
get_with_compatibility :index, target_params.merge({ typed_target_param => 0 }), valid_session
|
62
62
|
}.to raise_error(ActiveRecord::RecordNotFound)
|
63
63
|
end
|
64
64
|
end
|
@@ -66,7 +66,7 @@ shared_examples_for :notification_controller do
|
|
66
66
|
context "with json as format parameter" do
|
67
67
|
before do
|
68
68
|
@notification = create(:notification, target: test_target)
|
69
|
-
|
69
|
+
get_with_compatibility :index, target_params.merge({ typed_target_param => test_target, format: :json }), valid_session
|
70
70
|
end
|
71
71
|
|
72
72
|
it "returns 200 as http status code" do
|
@@ -83,7 +83,7 @@ shared_examples_for :notification_controller do
|
|
83
83
|
context "with unopened as filter" do
|
84
84
|
before do
|
85
85
|
@notification = create(:notification, target: test_target)
|
86
|
-
|
86
|
+
get_with_compatibility :index, target_params.merge({ typed_target_param => test_target, filter: 'unopened' }), valid_session
|
87
87
|
end
|
88
88
|
|
89
89
|
it "assigns unopened notification index as @notifications" do
|
@@ -94,7 +94,7 @@ shared_examples_for :notification_controller do
|
|
94
94
|
context "with opened as filter" do
|
95
95
|
before do
|
96
96
|
@notification = create(:notification, target: test_target)
|
97
|
-
|
97
|
+
get_with_compatibility :index, target_params.merge({ typed_target_param => test_target, filter: 'opened' }), valid_session
|
98
98
|
end
|
99
99
|
|
100
100
|
it "assigns unopened notification index as @notifications" do
|
@@ -110,7 +110,7 @@ shared_examples_for :notification_controller do
|
|
110
110
|
end
|
111
111
|
context "with 2 as limit" do
|
112
112
|
before do
|
113
|
-
|
113
|
+
get_with_compatibility :index, target_params.merge({ typed_target_param => test_target, limit: 2 }), valid_session
|
114
114
|
end
|
115
115
|
|
116
116
|
it "assigns notification index of size 2 as @notifications" do
|
@@ -120,7 +120,7 @@ shared_examples_for :notification_controller do
|
|
120
120
|
|
121
121
|
context "with 1 as limit" do
|
122
122
|
before do
|
123
|
-
|
123
|
+
get_with_compatibility :index, target_params.merge({ typed_target_param => test_target, limit: 1 }), valid_session
|
124
124
|
end
|
125
125
|
|
126
126
|
it "assigns notification index of size 1 as @notifications" do
|
@@ -133,7 +133,7 @@ shared_examples_for :notification_controller do
|
|
133
133
|
context "with false as reload" do
|
134
134
|
before do
|
135
135
|
@notification = create(:notification, target: test_target)
|
136
|
-
|
136
|
+
get_with_compatibility :index, target_params.merge({ typed_target_param => test_target, reload: false }), valid_session
|
137
137
|
end
|
138
138
|
|
139
139
|
it "returns 200 as http status code" do
|
@@ -156,7 +156,7 @@ shared_examples_for :notification_controller do
|
|
156
156
|
before do
|
157
157
|
@notification = create(:notification, target: test_target)
|
158
158
|
expect(@notification.opened?).to be_falsey
|
159
|
-
|
159
|
+
post_with_compatibility :open_all, target_params.merge({ typed_target_param => test_target }), valid_session
|
160
160
|
end
|
161
161
|
|
162
162
|
it "returns 302 as http status code" do
|
@@ -181,7 +181,7 @@ shared_examples_for :notification_controller do
|
|
181
181
|
@notification = create(:notification, target: test_target)
|
182
182
|
expect(@notification.opened?).to be_falsey
|
183
183
|
request.env["HTTP_REFERER"] = root_path
|
184
|
-
|
184
|
+
post_with_compatibility :open_all, target_params.merge({ typed_target_param => test_target }), valid_session
|
185
185
|
end
|
186
186
|
|
187
187
|
it "returns 302 as http status code" do
|
@@ -201,7 +201,7 @@ shared_examples_for :notification_controller do
|
|
201
201
|
before do
|
202
202
|
@notification = create(:notification, target: test_target)
|
203
203
|
expect(@notification.opened?).to be_falsey
|
204
|
-
|
204
|
+
xhr_with_compatibility :post, :open_all, target_params.merge({ typed_target_param => test_target }), valid_session
|
205
205
|
end
|
206
206
|
|
207
207
|
it "returns 200 as http status code" do
|
@@ -220,13 +220,56 @@ shared_examples_for :notification_controller do
|
|
220
220
|
expect(response).to render_template :open_all, format: :js
|
221
221
|
end
|
222
222
|
end
|
223
|
+
|
224
|
+
context "with filter request parameters" do
|
225
|
+
before do
|
226
|
+
@target_1, @notifiable_1, @group_1, @key_1 = create(:confirmed_user), create(:article), nil, "key.1"
|
227
|
+
@target_2, @notifiable_2, @group_2, @key_2 = create(:confirmed_user), create(:comment), @notifiable_1, "key.2"
|
228
|
+
@notification_1 = create(:notification, target: test_target, notifiable: @notifiable_1, group: @group_1, key: @key_1)
|
229
|
+
@notification_2 = create(:notification, target: test_target, notifiable: @notifiable_2, group: @group_2, key: @key_2)
|
230
|
+
expect(@notification_1.opened?).to be_falsey
|
231
|
+
expect(@notification_2.opened?).to be_falsey
|
232
|
+
end
|
233
|
+
|
234
|
+
context "with filtered_by_type request parameters" do
|
235
|
+
it "opens filtered notifications only" do
|
236
|
+
post_with_compatibility :open_all, target_params.merge({ typed_target_param => test_target, 'filtered_by_type' => @notifiable_2.to_class_name }), valid_session
|
237
|
+
expect(@notification_1.reload.opened?).to be_falsey
|
238
|
+
expect(@notification_2.reload.opened?).to be_truthy
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
context 'with filtered_by_group_type and :filtered_by_group_id request parameters' do
|
243
|
+
it "opens filtered notifications only" do
|
244
|
+
post_with_compatibility :open_all, target_params.merge({ typed_target_param => test_target, 'filtered_by_group_type' => 'Article', 'filtered_by_group_id' => @group_2.id.to_s }), valid_session
|
245
|
+
expect(@notification_1.reload.opened?).to be_falsey
|
246
|
+
expect(@notification_2.reload.opened?).to be_truthy
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
context 'with filtered_by_key request parameters' do
|
251
|
+
it "opens filtered notifications only" do
|
252
|
+
post_with_compatibility :open_all, target_params.merge({ typed_target_param => test_target, 'filtered_by_key' => 'key.2' }), valid_session
|
253
|
+
expect(@notification_1.reload.opened?).to be_falsey
|
254
|
+
expect(@notification_2.reload.opened?).to be_truthy
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
context "with no filter request parameters" do
|
259
|
+
it "opens all notifications of the target" do
|
260
|
+
post_with_compatibility :open_all, target_params.merge({ typed_target_param => test_target}), valid_session
|
261
|
+
expect(@notification_1.reload.opened?).to be_truthy
|
262
|
+
expect(@notification_2.reload.opened?).to be_truthy
|
263
|
+
end
|
264
|
+
end
|
265
|
+
end
|
223
266
|
end
|
224
267
|
|
225
268
|
describe "GET #show" do
|
226
269
|
context "with id, target_type and (typed_target)_id parameters" do
|
227
270
|
before do
|
228
271
|
@notification = create(:notification, target: test_target)
|
229
|
-
|
272
|
+
get_with_compatibility :show, target_params.merge({ id: @notification, typed_target_param => test_target }), valid_session
|
230
273
|
end
|
231
274
|
|
232
275
|
it "returns 200 as http status code" do
|
@@ -245,7 +288,7 @@ shared_examples_for :notification_controller do
|
|
245
288
|
context "with wrong id and (typed_target)_id parameters" do
|
246
289
|
before do
|
247
290
|
@notification = create(:notification, target: create(:user))
|
248
|
-
|
291
|
+
get_with_compatibility :show, target_params.merge({ id: @notification, typed_target_param => test_target }), valid_session
|
249
292
|
end
|
250
293
|
|
251
294
|
it "returns 403 as http status code" do
|
@@ -258,7 +301,7 @@ shared_examples_for :notification_controller do
|
|
258
301
|
context "http direct DELETE request" do
|
259
302
|
before do
|
260
303
|
@notification = create(:notification, target: test_target)
|
261
|
-
|
304
|
+
delete_with_compatibility :destroy, target_params.merge({ id: @notification, typed_target_param => test_target }), valid_session
|
262
305
|
end
|
263
306
|
|
264
307
|
it "returns 302 as http status code" do
|
@@ -278,7 +321,7 @@ shared_examples_for :notification_controller do
|
|
278
321
|
before do
|
279
322
|
@notification = create(:notification, target: test_target)
|
280
323
|
request.env["HTTP_REFERER"] = root_path
|
281
|
-
|
324
|
+
delete_with_compatibility :destroy, target_params.merge({ id: @notification, typed_target_param => test_target }), valid_session
|
282
325
|
end
|
283
326
|
|
284
327
|
it "returns 302 as http status code" do
|
@@ -297,7 +340,7 @@ shared_examples_for :notification_controller do
|
|
297
340
|
context "Ajax DELETE request" do
|
298
341
|
before do
|
299
342
|
@notification = create(:notification, target: test_target)
|
300
|
-
|
343
|
+
xhr_with_compatibility :delete, :destroy, target_params.merge({ id: @notification, typed_target_param => test_target }), valid_session
|
301
344
|
end
|
302
345
|
|
303
346
|
it "returns 200 as http status code" do
|
@@ -324,7 +367,7 @@ shared_examples_for :notification_controller do
|
|
324
367
|
before do
|
325
368
|
@notification = create(:notification, target: test_target)
|
326
369
|
expect(@notification.opened?).to be_falsey
|
327
|
-
|
370
|
+
post_with_compatibility :open, target_params.merge({ id: @notification, typed_target_param => test_target }), valid_session
|
328
371
|
end
|
329
372
|
|
330
373
|
it "returns 302 as http status code" do
|
@@ -345,7 +388,7 @@ shared_examples_for :notification_controller do
|
|
345
388
|
@notification = create(:notification, target: test_target)
|
346
389
|
expect(@notification.opened?).to be_falsey
|
347
390
|
request.env["HTTP_REFERER"] = root_path
|
348
|
-
|
391
|
+
post_with_compatibility :open, target_params.merge({ id: @notification, typed_target_param => test_target }), valid_session
|
349
392
|
end
|
350
393
|
|
351
394
|
it "returns 302 as http status code" do
|
@@ -366,7 +409,7 @@ shared_examples_for :notification_controller do
|
|
366
409
|
@notification = create(:notification, target: test_target)
|
367
410
|
expect(@notification.opened?).to be_falsey
|
368
411
|
request.env["HTTP_REFERER"] = root_path
|
369
|
-
|
412
|
+
xhr_with_compatibility :post, :open, target_params.merge({ id: @notification, typed_target_param => test_target }), valid_session
|
370
413
|
end
|
371
414
|
|
372
415
|
it "returns 200 as http status code" do
|
@@ -392,17 +435,13 @@ shared_examples_for :notification_controller do
|
|
392
435
|
before do
|
393
436
|
@notification = create(:notification, target: test_target)
|
394
437
|
expect(@notification.opened?).to be_falsey
|
395
|
-
|
438
|
+
post_with_compatibility :open, target_params.merge({ id: @notification, typed_target_param => test_target, move: true }), valid_session
|
396
439
|
end
|
397
440
|
|
398
441
|
it "returns 302 as http status code" do
|
399
442
|
expect(response.status).to eq(302)
|
400
443
|
end
|
401
444
|
|
402
|
-
it "assigns notification index as @notifications" do
|
403
|
-
expect(assigns(:notifications)).to eq([@notification])
|
404
|
-
end
|
405
|
-
|
406
445
|
it "opens the notification" do
|
407
446
|
expect(@notification.reload.opened?).to be_truthy
|
408
447
|
end
|
@@ -419,7 +458,7 @@ shared_examples_for :notification_controller do
|
|
419
458
|
context "http direct GET request" do
|
420
459
|
before do
|
421
460
|
@notification = create(:notification, target: test_target)
|
422
|
-
|
461
|
+
get_with_compatibility :move, target_params.merge({ id: @notification, typed_target_param => test_target }), valid_session
|
423
462
|
end
|
424
463
|
|
425
464
|
it "returns 302 as http status code" do
|
@@ -437,7 +476,7 @@ shared_examples_for :notification_controller do
|
|
437
476
|
before do
|
438
477
|
@notification = create(:notification, target: test_target)
|
439
478
|
expect(@notification.opened?).to be_falsey
|
440
|
-
|
479
|
+
get_with_compatibility :move, target_params.merge({ id: @notification, typed_target_param => test_target, open: true }), valid_session
|
441
480
|
end
|
442
481
|
|
443
482
|
it "returns 302 as http status code" do
|
@@ -454,4 +493,38 @@ shared_examples_for :notification_controller do
|
|
454
493
|
end
|
455
494
|
end
|
456
495
|
end
|
496
|
+
|
497
|
+
private
|
498
|
+
|
499
|
+
def get_with_compatibility action, params, session
|
500
|
+
if Rails::VERSION::MAJOR <= 4
|
501
|
+
get action, params, session
|
502
|
+
else
|
503
|
+
get action, params: params, session: session
|
504
|
+
end
|
505
|
+
end
|
506
|
+
|
507
|
+
def post_with_compatibility action, params, session
|
508
|
+
if Rails::VERSION::MAJOR <= 4
|
509
|
+
post action, params, session
|
510
|
+
else
|
511
|
+
post action, params: params, session: session
|
512
|
+
end
|
513
|
+
end
|
514
|
+
|
515
|
+
def delete_with_compatibility action, params, session
|
516
|
+
if Rails::VERSION::MAJOR <= 4
|
517
|
+
delete action, params, session
|
518
|
+
else
|
519
|
+
delete action, params: params, session: session
|
520
|
+
end
|
521
|
+
end
|
522
|
+
|
523
|
+
def xhr_with_compatibility method, action, params, session
|
524
|
+
if Rails::VERSION::MAJOR <= 4
|
525
|
+
xhr method, action, params, session
|
526
|
+
else
|
527
|
+
send method.to_s, action, xhr: true, params: params, session: session
|
528
|
+
end
|
529
|
+
end
|
457
530
|
end
|
@@ -23,7 +23,7 @@ describe ActivityNotification::NotificationsWithDeviseController, type: :control
|
|
23
23
|
describe "GET #index" do
|
24
24
|
before do
|
25
25
|
sign_in unauthenticated_user
|
26
|
-
|
26
|
+
get_with_compatibility :index, target_params.merge({ typed_target_param => test_target }), valid_session
|
27
27
|
end
|
28
28
|
|
29
29
|
it "returns 403 as http status code" do
|
@@ -37,7 +37,7 @@ describe ActivityNotification::NotificationsWithDeviseController, type: :control
|
|
37
37
|
|
38
38
|
describe "GET #index" do
|
39
39
|
before do
|
40
|
-
|
40
|
+
get_with_compatibility :index, target_params.merge({ typed_target_param => test_target }), valid_session
|
41
41
|
end
|
42
42
|
|
43
43
|
it "returns 302 as http status code" do
|
@@ -55,7 +55,7 @@ describe ActivityNotification::NotificationsWithDeviseController, type: :control
|
|
55
55
|
|
56
56
|
describe "GET #index" do
|
57
57
|
before do
|
58
|
-
|
58
|
+
get_with_compatibility :index, target_params.merge({ typed_target_param => test_target }), valid_session
|
59
59
|
end
|
60
60
|
|
61
61
|
it "returns 400 as http status code" do
|
@@ -69,7 +69,7 @@ describe ActivityNotification::NotificationsWithDeviseController, type: :control
|
|
69
69
|
|
70
70
|
describe "GET #index" do
|
71
71
|
before do
|
72
|
-
|
72
|
+
get_with_compatibility :index, target_params.merge({ typed_target_param => test_target }), valid_session
|
73
73
|
end
|
74
74
|
|
75
75
|
it "returns 403 as http status code" do
|
@@ -78,4 +78,14 @@ describe ActivityNotification::NotificationsWithDeviseController, type: :control
|
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
+
private
|
82
|
+
|
83
|
+
def get_with_compatibility action, params, session
|
84
|
+
if Rails::VERSION::MAJOR <= 4
|
85
|
+
get action, params, session
|
86
|
+
else
|
87
|
+
get action, params: params, session: session
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
81
91
|
end
|