activity_notification 2.1.4 → 2.2.3
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/.github/workflows/build.yml +120 -0
- data/CHANGELOG.md +38 -0
- data/README.md +2 -2
- data/activity_notification.gemspec +1 -1
- data/app/controllers/activity_notification/notifications_controller.rb +0 -20
- data/app/controllers/activity_notification/subscriptions_controller.rb +2 -2
- data/app/views/activity_notification/subscriptions/default/_form.html.erb +1 -1
- data/app/views/activity_notification/subscriptions/default/_notification_keys.html.erb +2 -2
- data/app/views/activity_notification/subscriptions/default/_subscription.html.erb +2 -2
- data/app/views/activity_notification/subscriptions/default/index.html.erb +2 -2
- data/app/views/activity_notification/subscriptions/default/show.html.erb +2 -2
- data/bin/bundle_update.sh +0 -1
- data/docs/Functions.md +17 -1
- data/gemfiles/{Gemfile.rails-4.2 → Gemfile.rails-6.1} +2 -4
- data/gemfiles/Gemfile.rails-7.0 +28 -0
- data/lib/activity_notification/apis/notification_api.rb +5 -1
- data/lib/activity_notification/apis/subscription_api.rb +5 -5
- data/lib/activity_notification/common.rb +11 -3
- data/lib/activity_notification/config.rb +63 -23
- data/lib/activity_notification/controllers/common_controller.rb +1 -17
- data/lib/activity_notification/models/concerns/notifiable.rb +1 -1
- data/lib/activity_notification/models/concerns/subscriber.rb +6 -4
- data/lib/activity_notification/models/concerns/swagger/notification_schema.rb +16 -16
- data/lib/activity_notification/models/concerns/target.rb +8 -12
- data/lib/activity_notification/orm/active_record/notification.rb +3 -3
- data/lib/activity_notification/orm/active_record.rb +1 -1
- data/lib/activity_notification/orm/dynamoid/notification.rb +1 -1
- data/lib/activity_notification/orm/dynamoid/subscription.rb +1 -1
- data/lib/activity_notification/orm/mongoid/notification.rb +1 -1
- data/lib/activity_notification/orm/mongoid/subscription.rb +1 -1
- data/lib/activity_notification/renderable.rb +2 -2
- data/lib/activity_notification/roles/acts_as_notifiable.rb +11 -15
- data/lib/activity_notification/version.rb +1 -1
- data/lib/generators/templates/activity_notification.rb +15 -1
- data/lib/generators/templates/migrations/migration.rb +1 -1
- data/spec/channels/notification_api_channel_spec.rb +42 -44
- data/spec/channels/notification_api_with_devise_channel_spec.rb +57 -59
- data/spec/channels/notification_channel_spec.rb +41 -43
- data/spec/channels/notification_with_devise_channel_spec.rb +75 -77
- data/spec/concerns/apis/notification_api_spec.rb +26 -3
- data/spec/concerns/apis/subscription_api_spec.rb +144 -2
- data/spec/concerns/common_spec.rb +25 -3
- data/spec/concerns/models/subscriber_spec.rb +179 -6
- data/spec/concerns/models/target_spec.rb +10 -12
- data/spec/concerns/renderable_spec.rb +5 -5
- data/spec/controllers/controller_spec_utility.rb +15 -51
- data/spec/generators/migration/migration_generator_spec.rb +2 -10
- data/spec/helpers/view_helpers_spec.rb +1 -1
- data/spec/optional_targets/action_cable_api_channel_spec.rb +21 -24
- data/spec/optional_targets/action_cable_channel_spec.rb +26 -29
- data/spec/rails_app/config/application.rb +2 -6
- data/spec/rails_app/config/database.yml +1 -1
- data/spec/rails_app/config/environments/test.rb +2 -11
- data/spec/rails_app/config/initializers/activity_notification.rb +14 -0
- data/spec/rails_app/package.json +14 -14
- data/spec/spec_helper.rb +1 -5
- metadata +13 -14
- data/.travis.yml +0 -76
- data/spec/support/patch_rails_42_action_controller_test_response.rb +0 -11
|
@@ -86,8 +86,65 @@ shared_examples_for :subscriber do
|
|
|
86
86
|
new_subscription = test_instance.create_subscription(params)
|
|
87
87
|
expect(new_subscription.subscribing?).to be_truthy
|
|
88
88
|
expect(new_subscription.subscribing_to_email?).to be_truthy
|
|
89
|
+
expect(new_subscription.subscribing_to_optional_target?(:console_output)).to be_truthy
|
|
89
90
|
expect(test_instance.subscriptions.reload.size).to eq(1)
|
|
90
91
|
end
|
|
92
|
+
|
|
93
|
+
context "with true as ActivityNotification.config.subscribe_to_email_as_default" do
|
|
94
|
+
it "creates a new subscription" do
|
|
95
|
+
ActivityNotification.config.subscribe_to_email_as_default = true
|
|
96
|
+
|
|
97
|
+
params = { key: 'key_1' }
|
|
98
|
+
new_subscription = test_instance.create_subscription(params)
|
|
99
|
+
expect(new_subscription.subscribing?).to be_truthy
|
|
100
|
+
expect(new_subscription.subscribing_to_email?).to be_truthy
|
|
101
|
+
expect(test_instance.subscriptions.reload.size).to eq(1)
|
|
102
|
+
|
|
103
|
+
ActivityNotification.config.subscribe_to_email_as_default = nil
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
context "with false as ActivityNotification.config.subscribe_to_email_as_default" do
|
|
108
|
+
it "creates a new subscription" do
|
|
109
|
+
ActivityNotification.config.subscribe_to_email_as_default = false
|
|
110
|
+
|
|
111
|
+
params = { key: 'key_1' }
|
|
112
|
+
new_subscription = test_instance.create_subscription(params)
|
|
113
|
+
expect(new_subscription.subscribing?).to be_truthy
|
|
114
|
+
expect(new_subscription.subscribing_to_email?).to be_falsey
|
|
115
|
+
expect(test_instance.subscriptions.reload.size).to eq(1)
|
|
116
|
+
|
|
117
|
+
ActivityNotification.config.subscribe_to_email_as_default = nil
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
context "with true as ActivityNotification.config.subscribe_to_optional_targets_as_default" do
|
|
122
|
+
it "creates a new subscription" do
|
|
123
|
+
ActivityNotification.config.subscribe_to_optional_targets_as_default = true
|
|
124
|
+
|
|
125
|
+
params = { key: 'key_1' }
|
|
126
|
+
new_subscription = test_instance.create_subscription(params)
|
|
127
|
+
expect(new_subscription.subscribing?).to be_truthy
|
|
128
|
+
expect(new_subscription.subscribing_to_optional_target?(:console_output)).to be_truthy
|
|
129
|
+
expect(test_instance.subscriptions.reload.size).to eq(1)
|
|
130
|
+
|
|
131
|
+
ActivityNotification.config.subscribe_to_optional_targets_as_default = nil
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
context "with false as ActivityNotification.config.subscribe_to_optional_targets_as_default" do
|
|
136
|
+
it "creates a new subscription" do
|
|
137
|
+
ActivityNotification.config.subscribe_to_optional_targets_as_default = false
|
|
138
|
+
|
|
139
|
+
params = { key: 'key_1' }
|
|
140
|
+
new_subscription = test_instance.create_subscription(params)
|
|
141
|
+
expect(new_subscription.subscribing?).to be_truthy
|
|
142
|
+
expect(new_subscription.subscribing_to_optional_target?(:console_output)).to be_falsey
|
|
143
|
+
expect(test_instance.subscriptions.reload.size).to eq(1)
|
|
144
|
+
|
|
145
|
+
ActivityNotification.config.subscribe_to_optional_targets_as_default = nil
|
|
146
|
+
end
|
|
147
|
+
end
|
|
91
148
|
end
|
|
92
149
|
|
|
93
150
|
context "with false as subscribing params" do
|
|
@@ -98,6 +155,34 @@ shared_examples_for :subscriber do
|
|
|
98
155
|
expect(new_subscription.subscribing_to_email?).to be_falsey
|
|
99
156
|
expect(test_instance.subscriptions.reload.size).to eq(1)
|
|
100
157
|
end
|
|
158
|
+
|
|
159
|
+
context "with true as ActivityNotification.config.subscribe_to_email_as_default" do
|
|
160
|
+
it "creates a new subscription" do
|
|
161
|
+
ActivityNotification.config.subscribe_to_email_as_default = true
|
|
162
|
+
|
|
163
|
+
params = { key: 'key_1', subscribing: false }
|
|
164
|
+
new_subscription = test_instance.create_subscription(params)
|
|
165
|
+
expect(new_subscription.subscribing?).to be_falsey
|
|
166
|
+
expect(new_subscription.subscribing_to_email?).to be_falsey
|
|
167
|
+
expect(test_instance.subscriptions.reload.size).to eq(1)
|
|
168
|
+
|
|
169
|
+
ActivityNotification.config.subscribe_to_email_as_default = nil
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
context "with false as ActivityNotification.config.subscribe_to_email_as_default" do
|
|
174
|
+
it "creates a new subscription" do
|
|
175
|
+
ActivityNotification.config.subscribe_to_email_as_default = false
|
|
176
|
+
|
|
177
|
+
params = { key: 'key_1', subscribing: false }
|
|
178
|
+
new_subscription = test_instance.create_subscription(params)
|
|
179
|
+
expect(new_subscription.subscribing?).to be_falsey
|
|
180
|
+
expect(new_subscription.subscribing_to_email?).to be_falsey
|
|
181
|
+
expect(test_instance.subscriptions.reload.size).to eq(1)
|
|
182
|
+
|
|
183
|
+
ActivityNotification.config.subscribe_to_email_as_default = nil
|
|
184
|
+
end
|
|
185
|
+
end
|
|
101
186
|
end
|
|
102
187
|
|
|
103
188
|
context "with false as subscribing_to_email params" do
|
|
@@ -462,7 +547,7 @@ shared_examples_for :subscriber do
|
|
|
462
547
|
described_class._notification_subscription_allowed = true
|
|
463
548
|
end
|
|
464
549
|
|
|
465
|
-
context "without configured
|
|
550
|
+
context "without configured subscription" do
|
|
466
551
|
context "without subscribe_as_default argument" do
|
|
467
552
|
context "with true as ActivityNotification.config.subscribe_as_default" do
|
|
468
553
|
it "returns true" do
|
|
@@ -484,7 +569,7 @@ shared_examples_for :subscriber do
|
|
|
484
569
|
end
|
|
485
570
|
end
|
|
486
571
|
|
|
487
|
-
context "with configured
|
|
572
|
+
context "with configured subscription" do
|
|
488
573
|
context "subscribing to notification" do
|
|
489
574
|
it "returns true" do
|
|
490
575
|
subscription = test_instance.create_subscription(key: @test_key)
|
|
@@ -521,7 +606,7 @@ shared_examples_for :subscriber do
|
|
|
521
606
|
described_class._notification_subscription_allowed = true
|
|
522
607
|
end
|
|
523
608
|
|
|
524
|
-
context "without configured
|
|
609
|
+
context "without configured subscription" do
|
|
525
610
|
context "without subscribe_as_default argument" do
|
|
526
611
|
context "with true as ActivityNotification.config.subscribe_as_default" do
|
|
527
612
|
it "returns true" do
|
|
@@ -530,6 +615,28 @@ shared_examples_for :subscriber do
|
|
|
530
615
|
expect(test_instance.subscribes_to_notification_email?(@test_key)).to be_truthy
|
|
531
616
|
ActivityNotification.config.subscribe_as_default = subscribe_as_default
|
|
532
617
|
end
|
|
618
|
+
|
|
619
|
+
context "with true as ActivityNotification.config.subscribe_to_email_as_default" do
|
|
620
|
+
it "returns true" do
|
|
621
|
+
subscribe_as_default = ActivityNotification.config.subscribe_as_default
|
|
622
|
+
ActivityNotification.config.subscribe_as_default = true
|
|
623
|
+
ActivityNotification.config.subscribe_to_email_as_default = true
|
|
624
|
+
expect(test_instance.subscribes_to_notification_email?(@test_key)).to be_truthy
|
|
625
|
+
ActivityNotification.config.subscribe_as_default = subscribe_as_default
|
|
626
|
+
ActivityNotification.config.subscribe_to_email_as_default = nil
|
|
627
|
+
end
|
|
628
|
+
end
|
|
629
|
+
|
|
630
|
+
context "with false as ActivityNotification.config.subscribe_to_email_as_default" do
|
|
631
|
+
it "returns false" do
|
|
632
|
+
subscribe_as_default = ActivityNotification.config.subscribe_as_default
|
|
633
|
+
ActivityNotification.config.subscribe_as_default = true
|
|
634
|
+
ActivityNotification.config.subscribe_to_email_as_default = false
|
|
635
|
+
expect(test_instance.subscribes_to_notification_email?(@test_key)).to be_falsey
|
|
636
|
+
ActivityNotification.config.subscribe_as_default = subscribe_as_default
|
|
637
|
+
ActivityNotification.config.subscribe_to_email_as_default = nil
|
|
638
|
+
end
|
|
639
|
+
end
|
|
533
640
|
end
|
|
534
641
|
|
|
535
642
|
context "with false as ActivityNotification.config.subscribe_as_default" do
|
|
@@ -539,11 +646,33 @@ shared_examples_for :subscriber do
|
|
|
539
646
|
expect(test_instance.subscribes_to_notification_email?(@test_key)).to be_falsey
|
|
540
647
|
ActivityNotification.config.subscribe_as_default = subscribe_as_default
|
|
541
648
|
end
|
|
649
|
+
|
|
650
|
+
context "with true as ActivityNotification.config.subscribe_to_email_as_default" do
|
|
651
|
+
it "returns false" do
|
|
652
|
+
subscribe_as_default = ActivityNotification.config.subscribe_as_default
|
|
653
|
+
ActivityNotification.config.subscribe_as_default = false
|
|
654
|
+
ActivityNotification.config.subscribe_to_email_as_default = true
|
|
655
|
+
expect(test_instance.subscribes_to_notification_email?(@test_key)).to be_falsey
|
|
656
|
+
ActivityNotification.config.subscribe_as_default = subscribe_as_default
|
|
657
|
+
ActivityNotification.config.subscribe_to_email_as_default = nil
|
|
658
|
+
end
|
|
659
|
+
end
|
|
660
|
+
|
|
661
|
+
context "with false as ActivityNotification.config.subscribe_to_email_as_default" do
|
|
662
|
+
it "returns false" do
|
|
663
|
+
subscribe_as_default = ActivityNotification.config.subscribe_as_default
|
|
664
|
+
ActivityNotification.config.subscribe_as_default = false
|
|
665
|
+
ActivityNotification.config.subscribe_to_email_as_default = false
|
|
666
|
+
expect(test_instance.subscribes_to_notification_email?(@test_key)).to be_falsey
|
|
667
|
+
ActivityNotification.config.subscribe_as_default = subscribe_as_default
|
|
668
|
+
ActivityNotification.config.subscribe_to_email_as_default = nil
|
|
669
|
+
end
|
|
670
|
+
end
|
|
542
671
|
end
|
|
543
672
|
end
|
|
544
673
|
end
|
|
545
674
|
|
|
546
|
-
context "with configured
|
|
675
|
+
context "with configured subscription" do
|
|
547
676
|
context "subscribing to notification email" do
|
|
548
677
|
it "returns true" do
|
|
549
678
|
subscription = test_instance.create_subscription(key: @test_key)
|
|
@@ -581,7 +710,7 @@ shared_examples_for :subscriber do
|
|
|
581
710
|
described_class._notification_subscription_allowed = true
|
|
582
711
|
end
|
|
583
712
|
|
|
584
|
-
context "without configured
|
|
713
|
+
context "without configured subscription" do
|
|
585
714
|
context "without subscribe_as_default argument" do
|
|
586
715
|
context "with true as ActivityNotification.config.subscribe_as_default" do
|
|
587
716
|
it "returns true" do
|
|
@@ -590,6 +719,28 @@ shared_examples_for :subscriber do
|
|
|
590
719
|
expect(test_instance.subscribes_to_optional_target?(@test_key, @optional_target_name)).to be_truthy
|
|
591
720
|
ActivityNotification.config.subscribe_as_default = subscribe_as_default
|
|
592
721
|
end
|
|
722
|
+
|
|
723
|
+
context "with true as ActivityNotification.config.subscribe_to_optional_targets_as_default" do
|
|
724
|
+
it "returns true" do
|
|
725
|
+
subscribe_as_default = ActivityNotification.config.subscribe_as_default
|
|
726
|
+
ActivityNotification.config.subscribe_as_default = true
|
|
727
|
+
ActivityNotification.config.subscribe_to_optional_targets_as_default = true
|
|
728
|
+
expect(test_instance.subscribes_to_optional_target?(@test_key, @optional_target_name)).to be_truthy
|
|
729
|
+
ActivityNotification.config.subscribe_as_default = subscribe_as_default
|
|
730
|
+
ActivityNotification.config.subscribe_to_optional_targets_as_default = nil
|
|
731
|
+
end
|
|
732
|
+
end
|
|
733
|
+
|
|
734
|
+
context "with false as ActivityNotification.config.subscribe_to_optional_targets_as_default" do
|
|
735
|
+
it "returns false" do
|
|
736
|
+
subscribe_as_default = ActivityNotification.config.subscribe_as_default
|
|
737
|
+
ActivityNotification.config.subscribe_as_default = true
|
|
738
|
+
ActivityNotification.config.subscribe_to_optional_targets_as_default = false
|
|
739
|
+
expect(test_instance.subscribes_to_optional_target?(@test_key, @optional_target_name)).to be_falsey
|
|
740
|
+
ActivityNotification.config.subscribe_as_default = subscribe_as_default
|
|
741
|
+
ActivityNotification.config.subscribe_to_optional_targets_as_default = nil
|
|
742
|
+
end
|
|
743
|
+
end
|
|
593
744
|
end
|
|
594
745
|
|
|
595
746
|
context "with false as ActivityNotification.config.subscribe_as_default" do
|
|
@@ -599,11 +750,33 @@ shared_examples_for :subscriber do
|
|
|
599
750
|
expect(test_instance.subscribes_to_optional_target?(@test_key, @optional_target_name)).to be_falsey
|
|
600
751
|
ActivityNotification.config.subscribe_as_default = subscribe_as_default
|
|
601
752
|
end
|
|
753
|
+
|
|
754
|
+
context "with true as ActivityNotification.config.subscribe_to_optional_targets_as_default" do
|
|
755
|
+
it "returns false" do
|
|
756
|
+
subscribe_as_default = ActivityNotification.config.subscribe_as_default
|
|
757
|
+
ActivityNotification.config.subscribe_as_default = false
|
|
758
|
+
ActivityNotification.config.subscribe_to_optional_targets_as_default = true
|
|
759
|
+
expect(test_instance.subscribes_to_optional_target?(@test_key, @optional_target_name)).to be_falsey
|
|
760
|
+
ActivityNotification.config.subscribe_as_default = subscribe_as_default
|
|
761
|
+
ActivityNotification.config.subscribe_to_optional_targets_as_default = nil
|
|
762
|
+
end
|
|
763
|
+
end
|
|
764
|
+
|
|
765
|
+
context "with false as ActivityNotification.config.subscribe_to_optional_targets_as_default" do
|
|
766
|
+
it "returns false" do
|
|
767
|
+
subscribe_as_default = ActivityNotification.config.subscribe_as_default
|
|
768
|
+
ActivityNotification.config.subscribe_as_default = false
|
|
769
|
+
ActivityNotification.config.subscribe_to_optional_targets_as_default = false
|
|
770
|
+
expect(test_instance.subscribes_to_optional_target?(@test_key, @optional_target_name)).to be_falsey
|
|
771
|
+
ActivityNotification.config.subscribe_as_default = subscribe_as_default
|
|
772
|
+
ActivityNotification.config.subscribe_to_optional_targets_as_default = nil
|
|
773
|
+
end
|
|
774
|
+
end
|
|
602
775
|
end
|
|
603
776
|
end
|
|
604
777
|
end
|
|
605
778
|
|
|
606
|
-
context "with configured
|
|
779
|
+
context "with configured subscription" do
|
|
607
780
|
context "subscribing to the specified optional target" do
|
|
608
781
|
it "returns true" do
|
|
609
782
|
subscription = test_instance.create_subscription(key: @test_key, optional_targets: { ActivityNotification::Subscription.to_optional_target_key(@optional_target_name) => true })
|
|
@@ -490,20 +490,18 @@ shared_examples_for :target do
|
|
|
490
490
|
end
|
|
491
491
|
end
|
|
492
492
|
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
expect(test_instance.notification_action_cable_channel_class_name).to eq(ActivityNotification::NotificationWithDeviseChannel.name)
|
|
499
|
-
end
|
|
493
|
+
describe "#notification_action_cable_channel_class_name" do
|
|
494
|
+
context "when custom_notification_action_cable_with_devise? returns true" do
|
|
495
|
+
it "returns ActivityNotification::NotificationWithDeviseChannel" do
|
|
496
|
+
described_class._notification_action_cable_with_devise = true
|
|
497
|
+
expect(test_instance.notification_action_cable_channel_class_name).to eq(ActivityNotification::NotificationWithDeviseChannel.name)
|
|
500
498
|
end
|
|
499
|
+
end
|
|
501
500
|
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
end
|
|
501
|
+
context "when custom_notification_action_cable_with_devise? returns false" do
|
|
502
|
+
it "returns ActivityNotification::NotificationChannel" do
|
|
503
|
+
described_class._notification_action_cable_with_devise = false
|
|
504
|
+
expect(test_instance.notification_action_cable_channel_class_name).to eq(ActivityNotification::NotificationChannel.name)
|
|
507
505
|
end
|
|
508
506
|
end
|
|
509
507
|
end
|
|
@@ -32,7 +32,7 @@ shared_examples_for :renderable do
|
|
|
32
32
|
expect(I18n.t("notification.#{target_type_key}.#{params_text_key}.text"))
|
|
33
33
|
.to eq(params_text_original)
|
|
34
34
|
expect(I18n.t("notification.#{target_type_key}.#{params_text_key}.text",
|
|
35
|
-
|
|
35
|
+
article_title: article_title))
|
|
36
36
|
.to eq(params_text_embedded)
|
|
37
37
|
end
|
|
38
38
|
|
|
@@ -40,7 +40,7 @@ shared_examples_for :renderable do
|
|
|
40
40
|
expect(I18n.t("notification.#{target_type_key}.#{group_text_key}.text"))
|
|
41
41
|
.to eq(group_text_original)
|
|
42
42
|
expect(I18n.t("notification.#{target_type_key}.#{group_text_key}.text",
|
|
43
|
-
{notifier_name: notifier_name, group_member_count: group_member_count, group_notification_count: group_notification_count}))
|
|
43
|
+
**{ notifier_name: notifier_name, group_member_count: group_member_count, group_notification_count: group_notification_count }))
|
|
44
44
|
.to eq(group_text_embedded)
|
|
45
45
|
end
|
|
46
46
|
|
|
@@ -50,10 +50,10 @@ shared_examples_for :renderable do
|
|
|
50
50
|
expect(I18n.t("notification.#{target_type_key}.#{plural_text_key}.text")[:other])
|
|
51
51
|
.to eq(plural_text_original_other)
|
|
52
52
|
expect(I18n.t("notification.#{target_type_key}.#{plural_text_key}.text",
|
|
53
|
-
{article_title: article_title, notifier_name: notifier_name, count: 1}))
|
|
53
|
+
**{ article_title: article_title, notifier_name: notifier_name, count: 1 }))
|
|
54
54
|
.to eq(plural_text_embedded_one)
|
|
55
55
|
expect(I18n.t("notification.#{target_type_key}.#{plural_text_key}.text",
|
|
56
|
-
{article_title: article_title, notifier_name: notifier_name, count: group_notification_count}))
|
|
56
|
+
**{ article_title: article_title, notifier_name: notifier_name, count: group_notification_count }))
|
|
57
57
|
.to eq(plural_text_embedded_other)
|
|
58
58
|
end
|
|
59
59
|
end
|
|
@@ -126,4 +126,4 @@ shared_examples_for :renderable do
|
|
|
126
126
|
# #layout_path
|
|
127
127
|
|
|
128
128
|
end
|
|
129
|
-
end
|
|
129
|
+
end
|
|
@@ -2,43 +2,23 @@ module ActivityNotification
|
|
|
2
2
|
module ControllerSpec
|
|
3
3
|
module RequestUtility
|
|
4
4
|
def get_with_compatibility action, params, session
|
|
5
|
-
|
|
6
|
-
get action, params, session
|
|
7
|
-
else
|
|
8
|
-
get action, params: params, session: session
|
|
9
|
-
end
|
|
5
|
+
get action, params: params, session: session
|
|
10
6
|
end
|
|
11
7
|
|
|
12
8
|
def post_with_compatibility action, params, session
|
|
13
|
-
|
|
14
|
-
post action, params, session
|
|
15
|
-
else
|
|
16
|
-
post action, params: params, session: session
|
|
17
|
-
end
|
|
9
|
+
post action, params: params, session: session
|
|
18
10
|
end
|
|
19
11
|
|
|
20
12
|
def put_with_compatibility action, params, session
|
|
21
|
-
|
|
22
|
-
put action, params, session
|
|
23
|
-
else
|
|
24
|
-
put action, params: params, session: session
|
|
25
|
-
end
|
|
13
|
+
put action, params: params, session: session
|
|
26
14
|
end
|
|
27
15
|
|
|
28
16
|
def delete_with_compatibility action, params, session
|
|
29
|
-
|
|
30
|
-
delete action, params, session
|
|
31
|
-
else
|
|
32
|
-
delete action, params: params, session: session
|
|
33
|
-
end
|
|
17
|
+
delete action, params: params, session: session
|
|
34
18
|
end
|
|
35
19
|
|
|
36
20
|
def xhr_with_compatibility method, action, params, session
|
|
37
|
-
|
|
38
|
-
xhr method, action, params, session
|
|
39
|
-
else
|
|
40
|
-
send method.to_s, action, xhr: true, params: params, session: session
|
|
41
|
-
end
|
|
21
|
+
send method.to_s, action, xhr: true, params: params, session: session
|
|
42
22
|
end
|
|
43
23
|
end
|
|
44
24
|
|
|
@@ -76,53 +56,37 @@ module ActivityNotification
|
|
|
76
56
|
def api_path
|
|
77
57
|
"/#{root_path}/#{target_type}/#{test_target.id}"
|
|
78
58
|
end
|
|
79
|
-
|
|
59
|
+
|
|
80
60
|
def schema_path
|
|
81
|
-
Rails.root.join('..', 'openapi.json')
|
|
61
|
+
Rails.root.join('..', 'openapi.json')
|
|
82
62
|
end
|
|
83
|
-
|
|
63
|
+
|
|
84
64
|
def write_schema_file(schema_json)
|
|
85
65
|
File.open(schema_path, "w") { |file| file.write(schema_json) }
|
|
86
66
|
end
|
|
87
|
-
|
|
67
|
+
|
|
88
68
|
def read_schema_file
|
|
89
69
|
JSON.parse(File.read(schema_path))
|
|
90
70
|
end
|
|
91
71
|
|
|
92
72
|
def committee_options
|
|
93
|
-
@committee_options ||= { schema: Committee::Drivers::load_from_file(schema_path), prefix: root_path, validate_success_only: true }
|
|
73
|
+
@committee_options ||= { schema: Committee::Drivers::load_from_file(schema_path), prefix: root_path, validate_success_only: true, parse_response_by_content_type: false }
|
|
94
74
|
end
|
|
95
75
|
|
|
96
76
|
def get_with_compatibility path, options = {}
|
|
97
|
-
|
|
98
|
-
get path, options[:params], options[:headers]
|
|
99
|
-
else
|
|
100
|
-
get path, options
|
|
101
|
-
end
|
|
77
|
+
get path, **options
|
|
102
78
|
end
|
|
103
79
|
|
|
104
80
|
def post_with_compatibility path, options = {}
|
|
105
|
-
|
|
106
|
-
post path, options[:params], options[:headers]
|
|
107
|
-
else
|
|
108
|
-
post path, options
|
|
109
|
-
end
|
|
81
|
+
post path, **options
|
|
110
82
|
end
|
|
111
83
|
|
|
112
84
|
def put_with_compatibility path, options = {}
|
|
113
|
-
|
|
114
|
-
put path, options[:params], options[:headers]
|
|
115
|
-
else
|
|
116
|
-
put path, options
|
|
117
|
-
end
|
|
85
|
+
put path, **options
|
|
118
86
|
end
|
|
119
87
|
|
|
120
88
|
def delete_with_compatibility path, options = {}
|
|
121
|
-
|
|
122
|
-
delete path, options[:params], options[:headers]
|
|
123
|
-
else
|
|
124
|
-
delete path, options
|
|
125
|
-
end
|
|
89
|
+
delete path, **options
|
|
126
90
|
end
|
|
127
91
|
|
|
128
92
|
def assert_all_schema_confirm(response, status)
|
|
@@ -133,4 +97,4 @@ module ActivityNotification
|
|
|
133
97
|
end
|
|
134
98
|
end
|
|
135
99
|
end
|
|
136
|
-
end
|
|
100
|
+
end
|
|
@@ -31,11 +31,7 @@ describe ActivityNotification::Generators::MigrationGenerator, type: :generator
|
|
|
31
31
|
describe 'CreateNotifications migration file' do
|
|
32
32
|
subject { file(Dir["tmp/db/migrate/*_create_activity_notification_tables.rb"].first.gsub!('tmp/', '')) }
|
|
33
33
|
it { is_expected.to exist }
|
|
34
|
-
|
|
35
|
-
it { is_expected.to contain(/class CreateActivityNotificationTables < ActiveRecord::Migration\[\d\.\d\]/) }
|
|
36
|
-
else
|
|
37
|
-
it { is_expected.to contain(/class CreateActivityNotificationTables < ActiveRecord::Migration/) }
|
|
38
|
-
end
|
|
34
|
+
it { is_expected.to contain(/class CreateActivityNotificationTables < ActiveRecord::Migration\[\d\.\d\]/) }
|
|
39
35
|
|
|
40
36
|
if ActivityNotification.config.orm == :active_record
|
|
41
37
|
it 'can be executed to migrate scheme' do
|
|
@@ -55,11 +51,7 @@ describe ActivityNotification::Generators::MigrationGenerator, type: :generator
|
|
|
55
51
|
describe 'CreateCustomNotifications migration file' do
|
|
56
52
|
subject { file(Dir["tmp/db/migrate/*_create_custom_notifications.rb"].first.gsub!('tmp/', '')) }
|
|
57
53
|
it { is_expected.to exist }
|
|
58
|
-
|
|
59
|
-
it { is_expected.to contain(/class CreateCustomNotifications < ActiveRecord::Migration\[\d\.\d\]/) }
|
|
60
|
-
else
|
|
61
|
-
it { is_expected.to contain(/class CreateCustomNotifications < ActiveRecord::Migration/) }
|
|
62
|
-
end
|
|
54
|
+
it { is_expected.to contain(/class CreateCustomNotifications < ActiveRecord::Migration\[\d\.\d\]/) }
|
|
63
55
|
|
|
64
56
|
if ActivityNotification.config.orm == :active_record
|
|
65
57
|
it 'can be executed to migrate scheme' do
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
describe ActivityNotification::ViewHelpers, type: :helper do
|
|
2
|
-
let(:view_context) { ActionView::Base.new }
|
|
2
|
+
let(:view_context) { ActionView::Base.new(ActionView::LookupContext.new(ActionController::Base.view_paths), [], nil) }
|
|
3
3
|
let(:notification) {
|
|
4
4
|
create(:notification, target: create(:confirmed_user))
|
|
5
5
|
}
|
|
@@ -1,37 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
let(:test_instance) { ActivityNotification::OptionalTarget::ActionCableApiChannel.new(skip_initializing_target: true) }
|
|
1
|
+
require 'activity_notification/optional_targets/action_cable_api_channel'
|
|
2
|
+
describe ActivityNotification::OptionalTarget::ActionCableApiChannel do
|
|
3
|
+
let(:test_instance) { ActivityNotification::OptionalTarget::ActionCableApiChannel.new(skip_initializing_target: true) }
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
end
|
|
5
|
+
describe "as public instance methods" do
|
|
6
|
+
describe "#to_optional_target_name" do
|
|
7
|
+
it "is return demodulized symbol class name" do
|
|
8
|
+
expect(test_instance.to_optional_target_name).to eq(:action_cable_api_channel)
|
|
11
9
|
end
|
|
10
|
+
end
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
end
|
|
12
|
+
describe "#initialize_target" do
|
|
13
|
+
it "does not raise NotImplementedError" do
|
|
14
|
+
test_instance.initialize_target
|
|
17
15
|
end
|
|
16
|
+
end
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
end
|
|
18
|
+
describe "#notify" do
|
|
19
|
+
it "does not raise NotImplementedError" do
|
|
20
|
+
test_instance.notify(create(:notification))
|
|
23
21
|
end
|
|
24
22
|
end
|
|
23
|
+
end
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
end
|
|
25
|
+
describe "as protected instance methods" do
|
|
26
|
+
describe "#render_notification_message" do
|
|
27
|
+
context "as default" do
|
|
28
|
+
it "renders notification message as formatted JSON" do
|
|
29
|
+
expect(test_instance.send(:render_notification_message, create(:notification)).with_indifferent_access[:notification].has_key?(:id)).to be_truthy
|
|
32
30
|
end
|
|
33
31
|
end
|
|
34
32
|
end
|
|
35
|
-
|
|
36
33
|
end
|
|
37
34
|
end
|
|
@@ -1,44 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
let(:test_instance) { ActivityNotification::OptionalTarget::ActionCableChannel.new(skip_initializing_target: true) }
|
|
1
|
+
require 'activity_notification/optional_targets/action_cable_channel'
|
|
2
|
+
describe ActivityNotification::OptionalTarget::ActionCableChannel do
|
|
3
|
+
let(:test_instance) { ActivityNotification::OptionalTarget::ActionCableChannel.new(skip_initializing_target: true) }
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
end
|
|
5
|
+
describe "as public instance methods" do
|
|
6
|
+
describe "#to_optional_target_name" do
|
|
7
|
+
it "is return demodulized symbol class name" do
|
|
8
|
+
expect(test_instance.to_optional_target_name).to eq(:action_cable_channel)
|
|
11
9
|
end
|
|
10
|
+
end
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
end
|
|
12
|
+
describe "#initialize_target" do
|
|
13
|
+
it "does not raise NotImplementedError" do
|
|
14
|
+
test_instance.initialize_target
|
|
17
15
|
end
|
|
16
|
+
end
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
end
|
|
18
|
+
describe "#notify" do
|
|
19
|
+
it "does not raise NotImplementedError" do
|
|
20
|
+
test_instance.notify(create(:notification))
|
|
23
21
|
end
|
|
24
22
|
end
|
|
23
|
+
end
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
end
|
|
25
|
+
describe "as protected instance methods" do
|
|
26
|
+
describe "#render_notification_message" do
|
|
27
|
+
context "as default" do
|
|
28
|
+
it "renders notification message with default template" do
|
|
29
|
+
expect(test_instance.send(:render_notification_message, create(:notification))).to be_include("<div class='notification_list")
|
|
32
30
|
end
|
|
31
|
+
end
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
end
|
|
33
|
+
context "with unexisting template as fallback option" do
|
|
34
|
+
it "raise ActionView::MissingTemplate" do
|
|
35
|
+
expect { expect(test_instance.send(:render_notification_message, create(:notification), fallback: :hoge)) }
|
|
36
|
+
.to raise_error(ActionView::MissingTemplate)
|
|
39
37
|
end
|
|
40
38
|
end
|
|
41
39
|
end
|
|
42
|
-
|
|
43
40
|
end
|
|
44
41
|
end
|
|
@@ -24,18 +24,14 @@ require "action_controller/railtie"
|
|
|
24
24
|
require "action_mailer/railtie"
|
|
25
25
|
require "action_view/railtie"
|
|
26
26
|
require "sprockets/railtie"
|
|
27
|
-
require 'action_cable/engine'
|
|
27
|
+
require 'action_cable/engine'
|
|
28
28
|
|
|
29
29
|
Bundler.require(*Rails.groups)
|
|
30
30
|
require "activity_notification"
|
|
31
31
|
|
|
32
32
|
module Dummy
|
|
33
33
|
class Application < Rails::Application
|
|
34
|
-
|
|
35
|
-
if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2 && ENV['AN_TEST_DB'] != 'mongodb'
|
|
36
|
-
config.active_record.raise_in_transactional_callbacks = true
|
|
37
|
-
end
|
|
38
|
-
if Rails::VERSION::MAJOR >= 5 && Rails::VERSION::MINOR >= 2 && ENV['AN_TEST_DB'] != 'mongodb'
|
|
34
|
+
if Gem::Version.new("5.2.0") <= Rails.gem_version && Rails.gem_version < Gem::Version.new("6.0.0") && ENV['AN_TEST_DB'] != 'mongodb'
|
|
39
35
|
config.active_record.sqlite3.represent_boolean_as_integer = true
|
|
40
36
|
end
|
|
41
37
|
|