activity_notification 2.4.0 → 2.5.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.
Files changed (253) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +25 -29
  3. data/app/jobs/activity_notification/cascading_notification_job.rb +123 -0
  4. data/docs/Functions.md +202 -12
  5. data/docs/Setup.md +34 -2
  6. data/docs/Testing.md +12 -1
  7. data/lib/activity_notification/apis/cascading_notification_api.rb +208 -0
  8. data/lib/activity_notification/apis/notification_api.rb +3 -0
  9. data/lib/activity_notification/config.rb +10 -0
  10. data/lib/activity_notification/mailers/helpers.rb +27 -1
  11. data/lib/activity_notification/models/concerns/swagger/subscription_schema.rb +1 -1
  12. data/lib/activity_notification/version.rb +1 -1
  13. data/lib/generators/templates/activity_notification.rb +8 -0
  14. metadata +45 -481
  15. data/.codeclimate.yml +0 -33
  16. data/.coveralls.yml +0 -1
  17. data/.github/ISSUE_TEMPLATE/bug_report.md +0 -22
  18. data/.github/ISSUE_TEMPLATE/feature_request.md +0 -17
  19. data/.github/pull_request_template.md +0 -13
  20. data/.github/workflows/build.yml +0 -101
  21. data/.gitignore +0 -74
  22. data/.rspec +0 -3
  23. data/.rubocop.yml +0 -1157
  24. data/.yardopts +0 -6
  25. data/CHANGELOG.md +0 -439
  26. data/Gemfile +0 -31
  27. data/Procfile +0 -2
  28. data/Rakefile +0 -28
  29. data/activity_notification.gemspec +0 -44
  30. data/ai-curated-specs/issues/172/design.md +0 -220
  31. data/ai-curated-specs/issues/172/tasks.md +0 -326
  32. data/ai-curated-specs/issues/188/design.md +0 -227
  33. data/ai-curated-specs/issues/188/requirements.md +0 -78
  34. data/ai-curated-specs/issues/188/tasks.md +0 -203
  35. data/ai-curated-specs/issues/188/upstream-contributions.md +0 -592
  36. data/ai-curated-specs/issues/50/design.md +0 -235
  37. data/ai-curated-specs/issues/50/requirements.md +0 -49
  38. data/ai-curated-specs/issues/50/tasks.md +0 -232
  39. data/bin/_dynamodblocal +0 -4
  40. data/bin/bundle_update.sh +0 -7
  41. data/bin/deploy_on_heroku.sh +0 -16
  42. data/bin/install_dynamodblocal.sh +0 -5
  43. data/bin/start_dynamodblocal.sh +0 -47
  44. data/bin/stop_dynamodblocal.sh +0 -34
  45. data/gemfiles/Gemfile.rails-5.0 +0 -25
  46. data/gemfiles/Gemfile.rails-5.1 +0 -25
  47. data/gemfiles/Gemfile.rails-5.2 +0 -24
  48. data/gemfiles/Gemfile.rails-6.0 +0 -23
  49. data/gemfiles/Gemfile.rails-6.1 +0 -22
  50. data/gemfiles/Gemfile.rails-7.0 +0 -25
  51. data/gemfiles/Gemfile.rails-7.1 +0 -23
  52. data/gemfiles/Gemfile.rails-7.2 +0 -23
  53. data/gemfiles/Gemfile.rails-8.0 +0 -24
  54. data/package.json +0 -8
  55. data/spec/channels/notification_api_channel_shared_examples.rb +0 -59
  56. data/spec/channels/notification_api_channel_spec.rb +0 -49
  57. data/spec/channels/notification_api_with_devise_channel_spec.rb +0 -76
  58. data/spec/channels/notification_channel_shared_examples.rb +0 -59
  59. data/spec/channels/notification_channel_spec.rb +0 -48
  60. data/spec/channels/notification_with_devise_channel_spec.rb +0 -97
  61. data/spec/concerns/apis/notification_api_spec.rb +0 -1627
  62. data/spec/concerns/apis/subscription_api_spec.rb +0 -474
  63. data/spec/concerns/common_spec.rb +0 -213
  64. data/spec/concerns/models/group_spec.rb +0 -61
  65. data/spec/concerns/models/notifiable_spec.rb +0 -782
  66. data/spec/concerns/models/notifier_spec.rb +0 -71
  67. data/spec/concerns/models/subscriber_spec.rb +0 -800
  68. data/spec/concerns/models/target_spec.rb +0 -1285
  69. data/spec/concerns/renderable_spec.rb +0 -129
  70. data/spec/config_spec.rb +0 -85
  71. data/spec/controllers/common_controller_spec.rb +0 -25
  72. data/spec/controllers/controller_spec_utility.rb +0 -100
  73. data/spec/controllers/dummy_common_controller.rb +0 -5
  74. data/spec/controllers/notifications_api_controller_shared_examples.rb +0 -619
  75. data/spec/controllers/notifications_api_controller_spec.rb +0 -19
  76. data/spec/controllers/notifications_api_with_devise_controller_spec.rb +0 -60
  77. data/spec/controllers/notifications_controller_shared_examples.rb +0 -743
  78. data/spec/controllers/notifications_controller_spec.rb +0 -11
  79. data/spec/controllers/notifications_with_devise_controller_spec.rb +0 -97
  80. data/spec/controllers/subscriptions_api_controller_shared_examples.rb +0 -750
  81. data/spec/controllers/subscriptions_api_controller_spec.rb +0 -19
  82. data/spec/controllers/subscriptions_api_with_devise_controller_spec.rb +0 -60
  83. data/spec/controllers/subscriptions_controller_shared_examples.rb +0 -946
  84. data/spec/controllers/subscriptions_controller_spec.rb +0 -11
  85. data/spec/controllers/subscriptions_with_devise_controller_spec.rb +0 -97
  86. data/spec/factories/admins.rb +0 -5
  87. data/spec/factories/articles.rb +0 -5
  88. data/spec/factories/comments.rb +0 -6
  89. data/spec/factories/dummy/dummy_group.rb +0 -4
  90. data/spec/factories/dummy/dummy_notifiable.rb +0 -4
  91. data/spec/factories/dummy/dummy_notifier.rb +0 -4
  92. data/spec/factories/dummy/dummy_subscriber.rb +0 -4
  93. data/spec/factories/dummy/dummy_target.rb +0 -4
  94. data/spec/factories/notifications.rb +0 -7
  95. data/spec/factories/subscriptions.rb +0 -8
  96. data/spec/factories/users.rb +0 -11
  97. data/spec/generators/controllers_generator_spec.rb +0 -85
  98. data/spec/generators/install_generator_spec.rb +0 -43
  99. data/spec/generators/migration/migration_generator_spec.rb +0 -66
  100. data/spec/generators/models_generator_spec.rb +0 -96
  101. data/spec/generators/views_generator_spec.rb +0 -195
  102. data/spec/helpers/polymorphic_helpers_spec.rb +0 -89
  103. data/spec/helpers/view_helpers_spec.rb +0 -547
  104. data/spec/jobs/notification_resilience_job_spec.rb +0 -167
  105. data/spec/jobs/notify_all_job_spec.rb +0 -23
  106. data/spec/jobs/notify_job_spec.rb +0 -23
  107. data/spec/jobs/notify_to_job_spec.rb +0 -23
  108. data/spec/mailers/mailer_spec.rb +0 -214
  109. data/spec/mailers/notification_resilience_spec.rb +0 -263
  110. data/spec/models/dummy/dummy_group_spec.rb +0 -10
  111. data/spec/models/dummy/dummy_notifiable_spec.rb +0 -10
  112. data/spec/models/dummy/dummy_notifier_spec.rb +0 -10
  113. data/spec/models/dummy/dummy_subscriber_spec.rb +0 -8
  114. data/spec/models/dummy/dummy_target_spec.rb +0 -10
  115. data/spec/models/notification_spec.rb +0 -472
  116. data/spec/models/subscription_spec.rb +0 -215
  117. data/spec/optional_targets/action_cable_api_channel_spec.rb +0 -34
  118. data/spec/optional_targets/action_cable_channel_spec.rb +0 -41
  119. data/spec/optional_targets/amazon_sns_spec.rb +0 -47
  120. data/spec/optional_targets/base_spec.rb +0 -45
  121. data/spec/optional_targets/slack_spec.rb +0 -44
  122. data/spec/orm/dynamoid_spec.rb +0 -115
  123. data/spec/rails_app/Rakefile +0 -15
  124. data/spec/rails_app/app/assets/config/manifest.js +0 -3
  125. data/spec/rails_app/app/assets/images/.keep +0 -0
  126. data/spec/rails_app/app/assets/javascripts/application.js +0 -3
  127. data/spec/rails_app/app/assets/javascripts/cable.js +0 -12
  128. data/spec/rails_app/app/assets/stylesheets/application.css +0 -15
  129. data/spec/rails_app/app/assets/stylesheets/reset.css +0 -85
  130. data/spec/rails_app/app/assets/stylesheets/style.css +0 -244
  131. data/spec/rails_app/app/controllers/admins_controller.rb +0 -21
  132. data/spec/rails_app/app/controllers/application_controller.rb +0 -5
  133. data/spec/rails_app/app/controllers/articles_controller.rb +0 -67
  134. data/spec/rails_app/app/controllers/comments_controller.rb +0 -36
  135. data/spec/rails_app/app/controllers/concerns/.keep +0 -0
  136. data/spec/rails_app/app/controllers/spa_controller.rb +0 -7
  137. data/spec/rails_app/app/controllers/users/notifications_controller.rb +0 -2
  138. data/spec/rails_app/app/controllers/users/notifications_with_devise_controller.rb +0 -2
  139. data/spec/rails_app/app/controllers/users/subscriptions_controller.rb +0 -2
  140. data/spec/rails_app/app/controllers/users/subscriptions_with_devise_controller.rb +0 -2
  141. data/spec/rails_app/app/controllers/users_controller.rb +0 -26
  142. data/spec/rails_app/app/helpers/application_helper.rb +0 -2
  143. data/spec/rails_app/app/helpers/devise_helper.rb +0 -2
  144. data/spec/rails_app/app/javascript/App.vue +0 -40
  145. data/spec/rails_app/app/javascript/components/DeviseTokenAuth.vue +0 -82
  146. data/spec/rails_app/app/javascript/components/Top.vue +0 -98
  147. data/spec/rails_app/app/javascript/components/notifications/Index.vue +0 -200
  148. data/spec/rails_app/app/javascript/components/notifications/Notification.vue +0 -133
  149. data/spec/rails_app/app/javascript/components/notifications/NotificationContent.vue +0 -122
  150. data/spec/rails_app/app/javascript/components/subscriptions/Index.vue +0 -279
  151. data/spec/rails_app/app/javascript/components/subscriptions/NewSubscription.vue +0 -112
  152. data/spec/rails_app/app/javascript/components/subscriptions/NotificationKey.vue +0 -141
  153. data/spec/rails_app/app/javascript/components/subscriptions/Subscription.vue +0 -226
  154. data/spec/rails_app/app/javascript/config/development.js +0 -5
  155. data/spec/rails_app/app/javascript/config/environment.js +0 -7
  156. data/spec/rails_app/app/javascript/config/production.js +0 -5
  157. data/spec/rails_app/app/javascript/config/test.js +0 -5
  158. data/spec/rails_app/app/javascript/packs/application.js +0 -18
  159. data/spec/rails_app/app/javascript/packs/spa.js +0 -14
  160. data/spec/rails_app/app/javascript/router/index.js +0 -73
  161. data/spec/rails_app/app/javascript/store/index.js +0 -37
  162. data/spec/rails_app/app/mailers/.keep +0 -0
  163. data/spec/rails_app/app/mailers/custom_notification_mailer.rb +0 -5
  164. data/spec/rails_app/app/models/admin.rb +0 -35
  165. data/spec/rails_app/app/models/article.rb +0 -54
  166. data/spec/rails_app/app/models/comment.rb +0 -81
  167. data/spec/rails_app/app/models/dummy/dummy_base.rb +0 -11
  168. data/spec/rails_app/app/models/dummy/dummy_group.rb +0 -23
  169. data/spec/rails_app/app/models/dummy/dummy_notifiable.rb +0 -15
  170. data/spec/rails_app/app/models/dummy/dummy_notifiable_target.rb +0 -27
  171. data/spec/rails_app/app/models/dummy/dummy_notifier.rb +0 -15
  172. data/spec/rails_app/app/models/dummy/dummy_subscriber.rb +0 -14
  173. data/spec/rails_app/app/models/dummy/dummy_target.rb +0 -16
  174. data/spec/rails_app/app/models/user.rb +0 -73
  175. data/spec/rails_app/app/views/activity_notification/mailer/dummy_subscribers/test_key.text.erb +0 -1
  176. data/spec/rails_app/app/views/activity_notification/notifications/default/article/_update.html.erb +0 -146
  177. data/spec/rails_app/app/views/activity_notification/notifications/default/custom/_path_test.html.erb +0 -1
  178. data/spec/rails_app/app/views/activity_notification/notifications/default/custom/_test.html.erb +0 -1
  179. data/spec/rails_app/app/views/activity_notification/notifications/users/_custom_index.html.erb +0 -1
  180. data/spec/rails_app/app/views/activity_notification/notifications/users/custom/_test.html.erb +0 -1
  181. data/spec/rails_app/app/views/activity_notification/notifications/users/overridden/custom/_test.html.erb +0 -1
  182. data/spec/rails_app/app/views/activity_notification/optional_targets/admins/amazon_sns/comment/_default.text.erb +0 -10
  183. data/spec/rails_app/app/views/articles/_form.html.erb +0 -24
  184. data/spec/rails_app/app/views/articles/edit.html.erb +0 -8
  185. data/spec/rails_app/app/views/articles/index.html.erb +0 -113
  186. data/spec/rails_app/app/views/articles/new.html.erb +0 -7
  187. data/spec/rails_app/app/views/articles/show.html.erb +0 -49
  188. data/spec/rails_app/app/views/layouts/_header.html.erb +0 -46
  189. data/spec/rails_app/app/views/layouts/application.html.erb +0 -15
  190. data/spec/rails_app/app/views/spa/index.html.erb +0 -2
  191. data/spec/rails_app/babel.config.js +0 -72
  192. data/spec/rails_app/bin/bundle +0 -3
  193. data/spec/rails_app/bin/rails +0 -4
  194. data/spec/rails_app/bin/rake +0 -4
  195. data/spec/rails_app/bin/setup +0 -29
  196. data/spec/rails_app/bin/webpack +0 -18
  197. data/spec/rails_app/bin/webpack-dev-server +0 -18
  198. data/spec/rails_app/config/application.rb +0 -54
  199. data/spec/rails_app/config/boot.rb +0 -5
  200. data/spec/rails_app/config/cable.yml +0 -8
  201. data/spec/rails_app/config/database.yml +0 -36
  202. data/spec/rails_app/config/dynamoid.rb +0 -13
  203. data/spec/rails_app/config/environment.rb +0 -26
  204. data/spec/rails_app/config/environments/development.rb +0 -60
  205. data/spec/rails_app/config/environments/production.rb +0 -85
  206. data/spec/rails_app/config/environments/test.rb +0 -53
  207. data/spec/rails_app/config/initializers/activity_notification.rb +0 -104
  208. data/spec/rails_app/config/initializers/assets.rb +0 -11
  209. data/spec/rails_app/config/initializers/backtrace_silencers.rb +0 -7
  210. data/spec/rails_app/config/initializers/cookies_serializer.rb +0 -3
  211. data/spec/rails_app/config/initializers/copy_it.aws.rb.template +0 -6
  212. data/spec/rails_app/config/initializers/devise.rb +0 -278
  213. data/spec/rails_app/config/initializers/devise_token_auth.rb +0 -55
  214. data/spec/rails_app/config/initializers/filter_parameter_logging.rb +0 -4
  215. data/spec/rails_app/config/initializers/inflections.rb +0 -16
  216. data/spec/rails_app/config/initializers/mime_types.rb +0 -4
  217. data/spec/rails_app/config/initializers/mysql.rb +0 -9
  218. data/spec/rails_app/config/initializers/session_store.rb +0 -3
  219. data/spec/rails_app/config/initializers/wrap_parameters.rb +0 -14
  220. data/spec/rails_app/config/initializers/zeitwerk.rb +0 -10
  221. data/spec/rails_app/config/locales/activity_notification.en.yml +0 -26
  222. data/spec/rails_app/config/locales/devise.en.yml +0 -62
  223. data/spec/rails_app/config/mongoid.yml +0 -13
  224. data/spec/rails_app/config/routes.rb +0 -50
  225. data/spec/rails_app/config/secrets.yml +0 -22
  226. data/spec/rails_app/config/webpack/development.js +0 -5
  227. data/spec/rails_app/config/webpack/environment.js +0 -7
  228. data/spec/rails_app/config/webpack/loaders/vue.js +0 -6
  229. data/spec/rails_app/config/webpack/production.js +0 -5
  230. data/spec/rails_app/config/webpack/test.js +0 -5
  231. data/spec/rails_app/config/webpacker.yml +0 -97
  232. data/spec/rails_app/config.ru +0 -4
  233. data/spec/rails_app/db/migrate/20160716000000_create_test_tables.rb +0 -42
  234. data/spec/rails_app/db/migrate/20181209000000_create_activity_notification_tables.rb +0 -33
  235. data/spec/rails_app/db/migrate/20191201000000_add_tokens_to_users.rb +0 -10
  236. data/spec/rails_app/db/schema.rb +0 -98
  237. data/spec/rails_app/db/seeds.rb +0 -95
  238. data/spec/rails_app/lib/custom_optional_targets/console_output.rb +0 -16
  239. data/spec/rails_app/lib/custom_optional_targets/raise_error.rb +0 -14
  240. data/spec/rails_app/lib/custom_optional_targets/wrong_target.rb +0 -13
  241. data/spec/rails_app/lib/mailer_previews/mailer_preview.rb +0 -29
  242. data/spec/rails_app/package.json +0 -23
  243. data/spec/rails_app/postcss.config.js +0 -12
  244. data/spec/rails_app/public/404.html +0 -67
  245. data/spec/rails_app/public/422.html +0 -67
  246. data/spec/rails_app/public/500.html +0 -66
  247. data/spec/rails_app/public/favicon.ico +0 -0
  248. data/spec/roles/acts_as_group_spec.rb +0 -30
  249. data/spec/roles/acts_as_notifiable_spec.rb +0 -432
  250. data/spec/roles/acts_as_notifier_spec.rb +0 -30
  251. data/spec/roles/acts_as_target_spec.rb +0 -36
  252. data/spec/spec_helper.rb +0 -56
  253. data/spec/version_spec.rb +0 -31
@@ -1,129 +0,0 @@
1
- shared_examples_for :renderable do
2
- let(:test_class_name) { described_class.to_s.underscore.split('/').last.to_sym }
3
- let(:test_target) { create(:user) }
4
- let(:test_instance) { create(test_class_name, target: test_target) }
5
- let(:target_type_key) { 'user' }
6
-
7
- let(:notifier_name) { 'foo' }
8
- let(:article_title) { 'bar' }
9
- let(:group_notification_count) { 4 }
10
- let(:group_member_count) { 3 }
11
- let(:simple_text_key) { 'article.create' }
12
- let(:params_text_key) { 'article.update' }
13
- let(:group_text_key) { 'comment.reply' }
14
- let(:plural_text_key) { 'comment.post' }
15
- let(:simple_text_original) { 'Article has been created' }
16
- let(:params_text_original) { 'Article "%{article_title}" has been updated' }
17
- let(:plural_text_original_one) { "<p>%{notifier_name} posted a comment on your article %{article_title}</p>" }
18
- let(:plural_text_original_other) { "<p>%{notifier_name} posted %{count} comments on your article %{article_title}</p>" }
19
- let(:group_text_original) { "<p>%{notifier_name} and %{group_member_count} other people replied %{group_notification_count} times to your comment</p>" }
20
- let(:params_text_embedded) { 'Article "bar" has been updated' }
21
- let(:group_text_embedded) { "<p>foo and 3 other people replied 4 times to your comment</p>" }
22
- let(:plural_text_embedded_one) { "<p>foo posted a comment on your article bar</p>" }
23
- let(:plural_text_embedded_other) { "<p>foo posted 4 comments on your article bar</p>" }
24
-
25
- describe "i18n configuration" do
26
- it "has key configured for simple text" do
27
- expect(I18n.t("notification.#{target_type_key}.#{simple_text_key}.text"))
28
- .to eq(simple_text_original)
29
- end
30
-
31
- it "has key configured with embedded params" do
32
- expect(I18n.t("notification.#{target_type_key}.#{params_text_key}.text"))
33
- .to eq(params_text_original)
34
- expect(I18n.t("notification.#{target_type_key}.#{params_text_key}.text",
35
- article_title: article_title))
36
- .to eq(params_text_embedded)
37
- end
38
-
39
- it "has key configured with embedded params including group_member_count and group_notification_count" do
40
- expect(I18n.t("notification.#{target_type_key}.#{group_text_key}.text"))
41
- .to eq(group_text_original)
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 }))
44
- .to eq(group_text_embedded)
45
- end
46
-
47
- it "has key configured with plurals" do
48
- expect(I18n.t("notification.#{target_type_key}.#{plural_text_key}.text")[:one])
49
- .to eq(plural_text_original_one)
50
- expect(I18n.t("notification.#{target_type_key}.#{plural_text_key}.text")[:other])
51
- .to eq(plural_text_original_other)
52
- expect(I18n.t("notification.#{target_type_key}.#{plural_text_key}.text",
53
- **{ article_title: article_title, notifier_name: notifier_name, count: 1 }))
54
- .to eq(plural_text_embedded_one)
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 }))
57
- .to eq(plural_text_embedded_other)
58
- end
59
- end
60
-
61
- describe "as public instance methods" do
62
- describe "#text" do
63
- context "without params argument" do
64
- context "with target type of test instance" do
65
- it "uses text from key" do
66
- test_instance.key = simple_text_key
67
- expect(test_instance.text).to eq(simple_text_original)
68
- end
69
-
70
- it "uses text from key with notification namespace" do
71
- test_instance.key = "notification.#{simple_text_key}"
72
- expect(test_instance.text).to eq(simple_text_original)
73
- end
74
-
75
- context "when the text is missing for the target type" do
76
- it "returns translation missing text" do
77
- test_instance.target = create(:admin)
78
- test_instance.key = "notification.#{simple_text_key}"
79
- expect(test_instance.text)
80
- .to eq("Translation missing: en.notification.admin.#{simple_text_key}.text")
81
- end
82
- end
83
-
84
- context "when the text has embedded parameters" do
85
- it "raises MissingInterpolationArgument without embedded parameters" do
86
- test_instance.key = params_text_key
87
- expect { test_instance.text }
88
- .to raise_error(I18n::MissingInterpolationArgument)
89
- end
90
- end
91
- end
92
- end
93
-
94
- context "with params argument" do
95
- context "with target type of target parameter" do
96
- it "uses text from key" do
97
- test_instance.target = create(:admin)
98
- test_instance.key = simple_text_key
99
- expect(test_instance.text({target: :user})).to eq(simple_text_original)
100
- end
101
-
102
- context "when the text has embedded parameters" do
103
- it "uses text with embedded parameters" do
104
- test_instance.key = params_text_key
105
- expect(test_instance.text({article_title: article_title}))
106
- .to eq(params_text_embedded)
107
- end
108
-
109
- it "uses text with automatically embedded group_member_count" do
110
- # Create 3 group members
111
- create(test_class_name, target: test_instance.target, group_owner: test_instance)
112
- create(test_class_name, target: test_instance.target, group_owner: test_instance)
113
- create(test_class_name, target: test_instance.target, group_owner: test_instance)
114
- test_instance.key = group_text_key
115
- expect(test_instance.text({notifier_name: notifier_name}))
116
- .to eq(group_text_embedded)
117
- end
118
- end
119
- end
120
- end
121
- end
122
-
123
- # Test with view_helper for the following methods
124
- # #render
125
- # #partial_path
126
- # #layout_path
127
-
128
- end
129
- end
data/spec/config_spec.rb DELETED
@@ -1,85 +0,0 @@
1
- describe ActivityNotification::Config do
2
- describe "config.mailer" do
3
- let(:notification) { create(:notification) }
4
-
5
- context "as default" do
6
- it "is configured with ActivityNotification::Mailer" do
7
- expect(ActivityNotification::Mailer).to receive(:send_notification_email).and_call_original
8
- notification.send_notification_email send_later: false
9
- end
10
-
11
- it "is not configured with CustomNotificationMailer" do
12
- expect(CustomNotificationMailer).not_to receive(:send_notification_email).and_call_original
13
- notification.send_notification_email send_later: false
14
- end
15
- end
16
-
17
- context "when it is configured with CustomNotificationMailer" do
18
- before do
19
- ActivityNotification.config.mailer = 'CustomNotificationMailer'
20
- ActivityNotification::Notification.set_notification_mailer
21
- end
22
-
23
- after do
24
- ActivityNotification.config.mailer = 'ActivityNotification::Mailer'
25
- ActivityNotification::Notification.set_notification_mailer
26
- end
27
-
28
- it "is configured with CustomMailer" do
29
- expect(CustomNotificationMailer).to receive(:send_notification_email).and_call_original
30
- notification.send_notification_email send_later: false
31
- end
32
- end
33
- end
34
-
35
- describe "config.store_with_associated_records" do
36
- let(:target) { create(:confirmed_user) }
37
-
38
- context "when it is configured as true" do
39
- if ActivityNotification.config.orm == :active_record
40
- it "raises ActivityNotification::ConfigError when you use active_record ORM" do
41
- expect { ActivityNotification.config.store_with_associated_records = true }.to raise_error(ActivityNotification::ConfigError)
42
- end
43
- else
44
- before do
45
- @original = ActivityNotification.config.store_with_associated_records
46
- ActivityNotification.config.store_with_associated_records = true
47
- load Rails.root.join("../../lib/activity_notification/orm/#{ActivityNotification.config.orm}/notification.rb").to_s
48
- @notification = create(:notification, target: target)
49
- end
50
-
51
- after do
52
- ActivityNotification.config.store_with_associated_records = @original
53
- load Rails.root.join("../../lib/activity_notification/orm/#{ActivityNotification.config.orm}/notification.rb").to_s
54
- end
55
-
56
- it "stores notification with associated records" do
57
- expect(@notification.target).to eq(target)
58
- expect(@notification.stored_target["id"].to_s).to eq(target.id.to_s)
59
- end
60
- end
61
- end
62
-
63
- context "when it is configured as false" do
64
- before do
65
- @original = ActivityNotification.config.store_with_associated_records
66
- ActivityNotification.config.store_with_associated_records = false
67
- load Rails.root.join("../../lib/activity_notification/orm/#{ActivityNotification.config.orm}/notification.rb").to_s
68
- @notification = create(:notification, target: target)
69
- end
70
-
71
- after do
72
- ActivityNotification.config.store_with_associated_records = @original
73
- load Rails.root.join("../../lib/activity_notification/orm/#{ActivityNotification.config.orm}/notification.rb").to_s
74
- end
75
-
76
- it "does not store notification with associated records" do
77
- expect(@notification.target).to eq(target)
78
- begin
79
- expect(@notification.stored_target).to be_nil
80
- rescue NoMethodError
81
- end
82
- end
83
- end
84
- end
85
- end
@@ -1,25 +0,0 @@
1
- require 'controllers/dummy_common_controller'
2
-
3
- describe ActivityNotification::DummyCommonController, type: :controller do
4
-
5
- describe "#set_index_options" do
6
- it "raises NotImplementedError" do
7
- expect { controller.send(:set_index_options) }
8
- .to raise_error(NotImplementedError, /You have to implement .+#set_index_options/)
9
- end
10
- end
11
-
12
- describe "#load_index" do
13
- it "raises NotImplementedError" do
14
- expect { controller.send(:load_index) }
15
- .to raise_error(NotImplementedError, /You have to implement .+#load_index/)
16
- end
17
- end
18
-
19
- describe "#controller_path" do
20
- it "raises NotImplementedError" do
21
- expect { controller.send(:controller_path) }
22
- .to raise_error(NotImplementedError, /You have to implement .+#controller_path/)
23
- end
24
- end
25
- end
@@ -1,100 +0,0 @@
1
- module ActivityNotification
2
- module ControllerSpec
3
- module RequestUtility
4
- def get_with_compatibility action, params, session
5
- get action, params: params, session: session
6
- end
7
-
8
- def post_with_compatibility action, params, session
9
- post action, params: params, session: session
10
- end
11
-
12
- def put_with_compatibility action, params, session
13
- put action, params: params, session: session
14
- end
15
-
16
- def delete_with_compatibility action, params, session
17
- delete action, params: params, session: session
18
- end
19
-
20
- def xhr_with_compatibility method, action, params, session
21
- send method.to_s, action, xhr: true, params: params, session: session
22
- end
23
- end
24
-
25
- module ApiResponseUtility
26
- def response_json
27
- JSON.parse(response.body)
28
- end
29
-
30
- def assert_json_with_array_size(json_array, size)
31
- expect(json_array.size).to eq(size)
32
- end
33
-
34
- def assert_json_with_object(json_object, object)
35
- expect(json_object['id'].to_s).to eq(object.id.to_s)
36
- end
37
-
38
- def assert_json_with_object_array(json_array, expected_object_array)
39
- assert_json_with_array_size(json_array, expected_object_array.size)
40
- expected_object_array.each_with_index do |json_object, index|
41
- assert_json_with_object(json_object, expected_object_array[index])
42
- end
43
- end
44
-
45
- def assert_error_response(code)
46
- expect(response_json['gem']).to eq('activity_notification')
47
- expect(response_json['error']['code']).to eq(code)
48
- end
49
- end
50
-
51
- module CommitteeUtility
52
- extend ActiveSupport::Concern
53
- included do
54
- include Committee::Rails::Test::Methods
55
-
56
- def api_path
57
- "/#{root_path}/#{target_type}/#{test_target.id}"
58
- end
59
-
60
- def schema_path
61
- Rails.root.join('..', 'openapi.json')
62
- end
63
-
64
- def write_schema_file(schema_json)
65
- File.open(schema_path, "w") { |file| file.write(schema_json) }
66
- end
67
-
68
- def read_schema_file
69
- JSON.parse(File.read(schema_path))
70
- end
71
-
72
- def committee_options
73
- @committee_options ||= { schema: Committee::Drivers::load_from_file(schema_path), prefix: root_path, validate_success_only: true, parse_response_by_content_type: false }
74
- end
75
-
76
- def get_with_compatibility path, options = {}
77
- get path, **options
78
- end
79
-
80
- def post_with_compatibility path, options = {}
81
- post path, **options
82
- end
83
-
84
- def put_with_compatibility path, options = {}
85
- put path, **options
86
- end
87
-
88
- def delete_with_compatibility path, options = {}
89
- delete path, **options
90
- end
91
-
92
- def assert_all_schema_confirm(response, status)
93
- expect(response).to have_http_status(status)
94
- assert_request_schema_confirm
95
- assert_response_schema_confirm(status)
96
- end
97
- end
98
- end
99
- end
100
- end
@@ -1,5 +0,0 @@
1
- module ActivityNotification
2
- class DummyCommonController < ActivityNotification.config.parent_controller.constantize
3
- include CommonController
4
- end
5
- end