activity_notification 2.4.1 → 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.
- checksums.yaml +4 -4
- data/README.md +4 -2
- data/app/jobs/activity_notification/cascading_notification_job.rb +123 -0
- data/docs/Functions.md +197 -1
- data/lib/activity_notification/apis/cascading_notification_api.rb +208 -0
- data/lib/activity_notification/apis/notification_api.rb +3 -0
- data/lib/activity_notification/config.rb +10 -0
- data/lib/activity_notification/mailers/helpers.rb +27 -1
- data/lib/activity_notification/version.rb +1 -1
- data/lib/generators/templates/activity_notification.rb +8 -0
- metadata +5 -441
- data/.codeclimate.yml +0 -33
- data/.coveralls.yml +0 -1
- data/.github/ISSUE_TEMPLATE/bug_report.md +0 -22
- data/.github/ISSUE_TEMPLATE/feature_request.md +0 -17
- data/.github/pull_request_template.md +0 -13
- data/.github/workflows/build.yml +0 -100
- data/.gitignore +0 -74
- data/.rspec +0 -3
- data/.rubocop.yml +0 -1157
- data/.yardopts +0 -6
- data/CHANGELOG.md +0 -452
- data/Gemfile +0 -31
- data/Procfile +0 -2
- data/Rakefile +0 -28
- data/activity_notification.gemspec +0 -44
- data/ai-curated-specs/issues/172/design.md +0 -220
- data/ai-curated-specs/issues/172/tasks.md +0 -326
- data/ai-curated-specs/issues/188/design.md +0 -227
- data/ai-curated-specs/issues/188/requirements.md +0 -78
- data/ai-curated-specs/issues/188/tasks.md +0 -203
- data/ai-curated-specs/issues/188/upstream-contributions.md +0 -592
- data/ai-curated-specs/issues/50/design.md +0 -235
- data/ai-curated-specs/issues/50/requirements.md +0 -49
- data/ai-curated-specs/issues/50/tasks.md +0 -232
- data/bin/_dynamodblocal +0 -4
- data/bin/bundle_update.sh +0 -7
- data/bin/deploy_on_heroku.sh +0 -16
- data/bin/install_dynamodblocal.sh +0 -5
- data/bin/start_dynamodblocal.sh +0 -47
- data/bin/stop_dynamodblocal.sh +0 -34
- data/gemfiles/Gemfile.rails-5.0 +0 -25
- data/gemfiles/Gemfile.rails-5.1 +0 -25
- data/gemfiles/Gemfile.rails-5.2 +0 -24
- data/gemfiles/Gemfile.rails-6.0 +0 -23
- data/gemfiles/Gemfile.rails-6.1 +0 -22
- data/gemfiles/Gemfile.rails-7.0 +0 -25
- data/gemfiles/Gemfile.rails-7.1 +0 -23
- data/gemfiles/Gemfile.rails-7.2 +0 -23
- data/gemfiles/Gemfile.rails-8.0 +0 -24
- data/package.json +0 -8
- data/spec/channels/notification_api_channel_shared_examples.rb +0 -59
- data/spec/channels/notification_api_channel_spec.rb +0 -49
- data/spec/channels/notification_api_with_devise_channel_spec.rb +0 -76
- data/spec/channels/notification_channel_shared_examples.rb +0 -59
- data/spec/channels/notification_channel_spec.rb +0 -48
- data/spec/channels/notification_with_devise_channel_spec.rb +0 -97
- data/spec/concerns/apis/notification_api_spec.rb +0 -1627
- data/spec/concerns/apis/subscription_api_spec.rb +0 -474
- data/spec/concerns/common_spec.rb +0 -213
- data/spec/concerns/models/group_spec.rb +0 -61
- data/spec/concerns/models/notifiable_spec.rb +0 -782
- data/spec/concerns/models/notifier_spec.rb +0 -71
- data/spec/concerns/models/subscriber_spec.rb +0 -800
- data/spec/concerns/models/target_spec.rb +0 -1285
- data/spec/concerns/renderable_spec.rb +0 -129
- data/spec/config_spec.rb +0 -85
- data/spec/controllers/common_controller_spec.rb +0 -25
- data/spec/controllers/controller_spec_utility.rb +0 -100
- data/spec/controllers/dummy_common_controller.rb +0 -5
- data/spec/controllers/notifications_api_controller_shared_examples.rb +0 -619
- data/spec/controllers/notifications_api_controller_spec.rb +0 -19
- data/spec/controllers/notifications_api_with_devise_controller_spec.rb +0 -60
- data/spec/controllers/notifications_controller_shared_examples.rb +0 -743
- data/spec/controllers/notifications_controller_spec.rb +0 -11
- data/spec/controllers/notifications_with_devise_controller_spec.rb +0 -97
- data/spec/controllers/subscriptions_api_controller_shared_examples.rb +0 -750
- data/spec/controllers/subscriptions_api_controller_spec.rb +0 -19
- data/spec/controllers/subscriptions_api_with_devise_controller_spec.rb +0 -60
- data/spec/controllers/subscriptions_controller_shared_examples.rb +0 -946
- data/spec/controllers/subscriptions_controller_spec.rb +0 -11
- data/spec/controllers/subscriptions_with_devise_controller_spec.rb +0 -97
- data/spec/factories/admins.rb +0 -5
- data/spec/factories/articles.rb +0 -5
- data/spec/factories/comments.rb +0 -6
- data/spec/factories/dummy/dummy_group.rb +0 -4
- data/spec/factories/dummy/dummy_notifiable.rb +0 -4
- data/spec/factories/dummy/dummy_notifier.rb +0 -4
- data/spec/factories/dummy/dummy_subscriber.rb +0 -4
- data/spec/factories/dummy/dummy_target.rb +0 -4
- data/spec/factories/notifications.rb +0 -7
- data/spec/factories/subscriptions.rb +0 -8
- data/spec/factories/users.rb +0 -11
- data/spec/generators/controllers_generator_spec.rb +0 -85
- data/spec/generators/install_generator_spec.rb +0 -43
- data/spec/generators/migration/migration_generator_spec.rb +0 -80
- data/spec/generators/models_generator_spec.rb +0 -96
- data/spec/generators/views_generator_spec.rb +0 -195
- data/spec/helpers/polymorphic_helpers_spec.rb +0 -89
- data/spec/helpers/view_helpers_spec.rb +0 -547
- data/spec/jobs/notification_resilience_job_spec.rb +0 -167
- data/spec/jobs/notify_all_job_spec.rb +0 -23
- data/spec/jobs/notify_job_spec.rb +0 -23
- data/spec/jobs/notify_to_job_spec.rb +0 -23
- data/spec/mailers/mailer_spec.rb +0 -214
- data/spec/mailers/notification_resilience_spec.rb +0 -263
- data/spec/models/dummy/dummy_group_spec.rb +0 -10
- data/spec/models/dummy/dummy_notifiable_spec.rb +0 -10
- data/spec/models/dummy/dummy_notifier_spec.rb +0 -10
- data/spec/models/dummy/dummy_subscriber_spec.rb +0 -8
- data/spec/models/dummy/dummy_target_spec.rb +0 -10
- data/spec/models/notification_spec.rb +0 -472
- data/spec/models/subscription_spec.rb +0 -215
- data/spec/optional_targets/action_cable_api_channel_spec.rb +0 -34
- data/spec/optional_targets/action_cable_channel_spec.rb +0 -41
- data/spec/optional_targets/amazon_sns_spec.rb +0 -47
- data/spec/optional_targets/base_spec.rb +0 -45
- data/spec/optional_targets/slack_spec.rb +0 -44
- data/spec/orm/dynamoid_spec.rb +0 -115
- data/spec/rails_app/Rakefile +0 -15
- data/spec/rails_app/app/assets/config/manifest.js +0 -3
- data/spec/rails_app/app/assets/images/.keep +0 -0
- data/spec/rails_app/app/assets/javascripts/application.js +0 -3
- data/spec/rails_app/app/assets/javascripts/cable.js +0 -12
- data/spec/rails_app/app/assets/stylesheets/application.css +0 -15
- data/spec/rails_app/app/assets/stylesheets/reset.css +0 -85
- data/spec/rails_app/app/assets/stylesheets/style.css +0 -244
- data/spec/rails_app/app/controllers/admins_controller.rb +0 -21
- data/spec/rails_app/app/controllers/application_controller.rb +0 -5
- data/spec/rails_app/app/controllers/articles_controller.rb +0 -67
- data/spec/rails_app/app/controllers/comments_controller.rb +0 -36
- data/spec/rails_app/app/controllers/concerns/.keep +0 -0
- data/spec/rails_app/app/controllers/spa_controller.rb +0 -7
- data/spec/rails_app/app/controllers/users/notifications_controller.rb +0 -2
- data/spec/rails_app/app/controllers/users/notifications_with_devise_controller.rb +0 -2
- data/spec/rails_app/app/controllers/users/subscriptions_controller.rb +0 -2
- data/spec/rails_app/app/controllers/users/subscriptions_with_devise_controller.rb +0 -2
- data/spec/rails_app/app/controllers/users_controller.rb +0 -26
- data/spec/rails_app/app/helpers/application_helper.rb +0 -2
- data/spec/rails_app/app/helpers/devise_helper.rb +0 -2
- data/spec/rails_app/app/javascript/App.vue +0 -40
- data/spec/rails_app/app/javascript/components/DeviseTokenAuth.vue +0 -82
- data/spec/rails_app/app/javascript/components/Top.vue +0 -98
- data/spec/rails_app/app/javascript/components/notifications/Index.vue +0 -200
- data/spec/rails_app/app/javascript/components/notifications/Notification.vue +0 -133
- data/spec/rails_app/app/javascript/components/notifications/NotificationContent.vue +0 -122
- data/spec/rails_app/app/javascript/components/subscriptions/Index.vue +0 -279
- data/spec/rails_app/app/javascript/components/subscriptions/NewSubscription.vue +0 -112
- data/spec/rails_app/app/javascript/components/subscriptions/NotificationKey.vue +0 -141
- data/spec/rails_app/app/javascript/components/subscriptions/Subscription.vue +0 -226
- data/spec/rails_app/app/javascript/config/development.js +0 -5
- data/spec/rails_app/app/javascript/config/environment.js +0 -7
- data/spec/rails_app/app/javascript/config/production.js +0 -5
- data/spec/rails_app/app/javascript/config/test.js +0 -5
- data/spec/rails_app/app/javascript/packs/application.js +0 -18
- data/spec/rails_app/app/javascript/packs/spa.js +0 -14
- data/spec/rails_app/app/javascript/router/index.js +0 -73
- data/spec/rails_app/app/javascript/store/index.js +0 -37
- data/spec/rails_app/app/mailers/.keep +0 -0
- data/spec/rails_app/app/mailers/custom_notification_mailer.rb +0 -5
- data/spec/rails_app/app/models/admin.rb +0 -35
- data/spec/rails_app/app/models/article.rb +0 -54
- data/spec/rails_app/app/models/comment.rb +0 -81
- data/spec/rails_app/app/models/dummy/dummy_base.rb +0 -11
- data/spec/rails_app/app/models/dummy/dummy_group.rb +0 -23
- data/spec/rails_app/app/models/dummy/dummy_notifiable.rb +0 -15
- data/spec/rails_app/app/models/dummy/dummy_notifiable_target.rb +0 -27
- data/spec/rails_app/app/models/dummy/dummy_notifier.rb +0 -15
- data/spec/rails_app/app/models/dummy/dummy_subscriber.rb +0 -14
- data/spec/rails_app/app/models/dummy/dummy_target.rb +0 -16
- data/spec/rails_app/app/models/user.rb +0 -73
- data/spec/rails_app/app/views/activity_notification/mailer/dummy_subscribers/test_key.text.erb +0 -1
- data/spec/rails_app/app/views/activity_notification/notifications/default/article/_update.html.erb +0 -146
- data/spec/rails_app/app/views/activity_notification/notifications/default/custom/_path_test.html.erb +0 -1
- data/spec/rails_app/app/views/activity_notification/notifications/default/custom/_test.html.erb +0 -1
- data/spec/rails_app/app/views/activity_notification/notifications/users/_custom_index.html.erb +0 -1
- data/spec/rails_app/app/views/activity_notification/notifications/users/custom/_test.html.erb +0 -1
- data/spec/rails_app/app/views/activity_notification/notifications/users/overridden/custom/_test.html.erb +0 -1
- data/spec/rails_app/app/views/activity_notification/optional_targets/admins/amazon_sns/comment/_default.text.erb +0 -10
- data/spec/rails_app/app/views/articles/_form.html.erb +0 -24
- data/spec/rails_app/app/views/articles/edit.html.erb +0 -8
- data/spec/rails_app/app/views/articles/index.html.erb +0 -113
- data/spec/rails_app/app/views/articles/new.html.erb +0 -7
- data/spec/rails_app/app/views/articles/show.html.erb +0 -49
- data/spec/rails_app/app/views/layouts/_header.html.erb +0 -46
- data/spec/rails_app/app/views/layouts/application.html.erb +0 -15
- data/spec/rails_app/app/views/spa/index.html.erb +0 -2
- data/spec/rails_app/babel.config.js +0 -72
- data/spec/rails_app/bin/bundle +0 -3
- data/spec/rails_app/bin/rails +0 -4
- data/spec/rails_app/bin/rake +0 -4
- data/spec/rails_app/bin/setup +0 -29
- data/spec/rails_app/bin/webpack +0 -18
- data/spec/rails_app/bin/webpack-dev-server +0 -18
- data/spec/rails_app/config/application.rb +0 -54
- data/spec/rails_app/config/boot.rb +0 -5
- data/spec/rails_app/config/cable.yml +0 -8
- data/spec/rails_app/config/database.yml +0 -36
- data/spec/rails_app/config/dynamoid.rb +0 -13
- data/spec/rails_app/config/environment.rb +0 -26
- data/spec/rails_app/config/environments/development.rb +0 -60
- data/spec/rails_app/config/environments/production.rb +0 -85
- data/spec/rails_app/config/environments/test.rb +0 -53
- data/spec/rails_app/config/initializers/activity_notification.rb +0 -104
- data/spec/rails_app/config/initializers/assets.rb +0 -11
- data/spec/rails_app/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/rails_app/config/initializers/cookies_serializer.rb +0 -3
- data/spec/rails_app/config/initializers/copy_it.aws.rb.template +0 -6
- data/spec/rails_app/config/initializers/devise.rb +0 -278
- data/spec/rails_app/config/initializers/devise_token_auth.rb +0 -55
- data/spec/rails_app/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/rails_app/config/initializers/inflections.rb +0 -16
- data/spec/rails_app/config/initializers/mime_types.rb +0 -4
- data/spec/rails_app/config/initializers/mysql.rb +0 -9
- data/spec/rails_app/config/initializers/session_store.rb +0 -3
- data/spec/rails_app/config/initializers/wrap_parameters.rb +0 -14
- data/spec/rails_app/config/initializers/zeitwerk.rb +0 -10
- data/spec/rails_app/config/locales/activity_notification.en.yml +0 -26
- data/spec/rails_app/config/locales/devise.en.yml +0 -62
- data/spec/rails_app/config/mongoid.yml +0 -13
- data/spec/rails_app/config/routes.rb +0 -50
- data/spec/rails_app/config/secrets.yml +0 -22
- data/spec/rails_app/config/webpack/development.js +0 -5
- data/spec/rails_app/config/webpack/environment.js +0 -7
- data/spec/rails_app/config/webpack/loaders/vue.js +0 -6
- data/spec/rails_app/config/webpack/production.js +0 -5
- data/spec/rails_app/config/webpack/test.js +0 -5
- data/spec/rails_app/config/webpacker.yml +0 -97
- data/spec/rails_app/config.ru +0 -4
- data/spec/rails_app/db/migrate/20160716000000_create_test_tables.rb +0 -42
- data/spec/rails_app/db/migrate/20181209000000_create_activity_notification_tables.rb +0 -33
- data/spec/rails_app/db/migrate/20191201000000_add_tokens_to_users.rb +0 -10
- data/spec/rails_app/db/schema.rb +0 -98
- data/spec/rails_app/db/seeds.rb +0 -95
- data/spec/rails_app/lib/custom_optional_targets/console_output.rb +0 -16
- data/spec/rails_app/lib/custom_optional_targets/raise_error.rb +0 -14
- data/spec/rails_app/lib/custom_optional_targets/wrong_target.rb +0 -13
- data/spec/rails_app/lib/mailer_previews/mailer_preview.rb +0 -29
- data/spec/rails_app/package.json +0 -23
- data/spec/rails_app/postcss.config.js +0 -12
- data/spec/rails_app/public/404.html +0 -67
- data/spec/rails_app/public/422.html +0 -67
- data/spec/rails_app/public/500.html +0 -66
- data/spec/rails_app/public/favicon.ico +0 -0
- data/spec/roles/acts_as_group_spec.rb +0 -30
- data/spec/roles/acts_as_notifiable_spec.rb +0 -432
- data/spec/roles/acts_as_notifier_spec.rb +0 -30
- data/spec/roles/acts_as_target_spec.rb +0 -36
- data/spec/spec_helper.rb +0 -56
- data/spec/version_spec.rb +0 -31
|
@@ -1,547 +0,0 @@
|
|
|
1
|
-
describe ActivityNotification::ViewHelpers, type: :helper do
|
|
2
|
-
let(:view_context) { ActionView::Base.new(ActionView::LookupContext.new(ActionController::Base.view_paths), [], nil) }
|
|
3
|
-
let(:notification) {
|
|
4
|
-
create(:notification, target: create(:confirmed_user))
|
|
5
|
-
}
|
|
6
|
-
let(:target_user) { notification.target }
|
|
7
|
-
let(:subscription) {
|
|
8
|
-
create(:subscription, target: target_user, key: notification.key)
|
|
9
|
-
}
|
|
10
|
-
let(:notification_2) {
|
|
11
|
-
create(:notification, target: create(:confirmed_user))
|
|
12
|
-
}
|
|
13
|
-
let(:notifications) {
|
|
14
|
-
target = create(:confirmed_user)
|
|
15
|
-
create(:notification, target: target)
|
|
16
|
-
create(:notification, target: target)
|
|
17
|
-
target.notifications.group_owners_only
|
|
18
|
-
}
|
|
19
|
-
let(:simple_text_key) { 'article.create' }
|
|
20
|
-
let(:simple_text_original) { 'Article has been created' }
|
|
21
|
-
|
|
22
|
-
include ActivityNotification::ViewHelpers
|
|
23
|
-
|
|
24
|
-
describe 'ActionView::Base' do
|
|
25
|
-
it 'provides render_notification helper' do
|
|
26
|
-
expect(view_context.respond_to?(:render_notification)).to be_truthy
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
describe '.render_notification' do
|
|
31
|
-
context "without fallback" do
|
|
32
|
-
context "when the template is missing for the target type and key" do
|
|
33
|
-
it "raises ActionView::MissingTemplate" do
|
|
34
|
-
expect { render_notification notification }
|
|
35
|
-
.to raise_error(ActionView::MissingTemplate)
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
context "with default as fallback" do
|
|
41
|
-
it "renders default notification view" do
|
|
42
|
-
expect(render_notification notification, fallback: :default)
|
|
43
|
-
.to eq(
|
|
44
|
-
render partial: 'activity_notification/notifications/default/default',
|
|
45
|
-
locals: { notification: notification, parameters: {} }
|
|
46
|
-
)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
it 'handles multiple notifications of records' do
|
|
50
|
-
rendered_template = render_notification notifications, fallback: :default
|
|
51
|
-
expect(rendered_template).to start_with(
|
|
52
|
-
render partial: 'activity_notification/notifications/default/default',
|
|
53
|
-
locals: { notification: notifications.to_a.first, parameters: {} })
|
|
54
|
-
expect(rendered_template).to end_with(
|
|
55
|
-
render partial: 'activity_notification/notifications/default/default',
|
|
56
|
-
locals: { notification: notifications.to_a.last , parameters: {} })
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
it 'handles multiple notifications of array' do
|
|
60
|
-
expect(notification).to receive(:render).with(self, { fallback: :default })
|
|
61
|
-
expect(notification_2).to receive(:render).with(self, { fallback: :default })
|
|
62
|
-
render_notification [notification, notification_2], fallback: :default
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
context "with text as fallback" do
|
|
67
|
-
it "uses i18n text from key" do
|
|
68
|
-
notification.key = simple_text_key
|
|
69
|
-
expect(render_notification notification, fallback: :text)
|
|
70
|
-
.to eq(simple_text_original)
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
it "interpolates from parameters" do
|
|
74
|
-
notification.parameters = { "article_title" => "custom title" }
|
|
75
|
-
notification.key = 'article.destroy'
|
|
76
|
-
expect(render_notification notification, fallback: :text)
|
|
77
|
-
.to eq('The author removed an article "custom title"')
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
context "with i18n param set" do
|
|
82
|
-
it "uses i18n text from key" do
|
|
83
|
-
notification.key = simple_text_key
|
|
84
|
-
expect(render_notification notification, i18n: true)
|
|
85
|
-
.to eq(simple_text_original)
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
context "with custom view" do
|
|
90
|
-
it "renders custom notification view for default target" do
|
|
91
|
-
notification.key = 'custom.test'
|
|
92
|
-
# render activity_notification/notifications/default/custom/test
|
|
93
|
-
expect(render_notification notification)
|
|
94
|
-
.to eq("Custom template root for default target: #{notification.id}")
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
it "renders custom notification view for specified target" do
|
|
98
|
-
notification.key = 'custom.test'
|
|
99
|
-
# render activity_notification/notifications/users/custom/test
|
|
100
|
-
expect(render_notification notification, target: :users)
|
|
101
|
-
.to eq("Custom template root for user target: #{notification.id}")
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
it "renders custom notification view of partial parameter" do
|
|
105
|
-
notification.key = 'custom.test'
|
|
106
|
-
# render activity_notification/notifications/default/custom/path_test
|
|
107
|
-
expect(render_notification notification, partial: 'custom/path_test')
|
|
108
|
-
.to eq("Custom template root for path test: #{notification.id}")
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
it "uses layout of layout parameter" do
|
|
112
|
-
notification.key = 'custom.test'
|
|
113
|
-
expect(self).to receive(:render).with({
|
|
114
|
-
layout: 'layouts/test',
|
|
115
|
-
partial: 'activity_notification/notifications/default/custom/test',
|
|
116
|
-
assigns: {},
|
|
117
|
-
locals: notification.prepare_locals({ layout: 'test' })
|
|
118
|
-
})
|
|
119
|
-
render_notification notification, layout: 'test'
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
context "with defined overriding_notification_template_key in notifiable model" do
|
|
123
|
-
it "renders overridden custom notification view" do
|
|
124
|
-
notification.key = 'custom.test'
|
|
125
|
-
module AdditionalMethods
|
|
126
|
-
def overriding_notification_template_key(target, key)
|
|
127
|
-
'overridden.custom.test'
|
|
128
|
-
end
|
|
129
|
-
end
|
|
130
|
-
notification.notifiable.extend(AdditionalMethods)
|
|
131
|
-
# render activity_notification/notifications/users/overridden/custom/test
|
|
132
|
-
expect(render_notification notification, target: :users)
|
|
133
|
-
.to eq("Overridden custom template root for user target: #{notification.id}")
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
|
-
end
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
describe '.render_notifications' do
|
|
140
|
-
it "is an alias of render_notification" do
|
|
141
|
-
expect(notification).to receive(:render).with(self, { fallback: :default })
|
|
142
|
-
render_notifications notification, fallback: :default
|
|
143
|
-
end
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
describe '.render_notification_of' do
|
|
147
|
-
context "without fallback" do
|
|
148
|
-
context "when the template is missing for the target type and key" do
|
|
149
|
-
it "raises ActionView::MissingTemplate" do
|
|
150
|
-
expect { render_notification_of target_user }
|
|
151
|
-
.to raise_error(ActionView::MissingTemplate)
|
|
152
|
-
end
|
|
153
|
-
end
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
context "with default as fallback" do
|
|
157
|
-
it "renders default notification view" do
|
|
158
|
-
allow(self).to receive(:content_for).with(:notification_index).and_return('foo')
|
|
159
|
-
@target = target_user
|
|
160
|
-
expect(render_notification_of target_user, fallback: :default)
|
|
161
|
-
.to eq(
|
|
162
|
-
render partial: 'activity_notification/notifications/default/index',
|
|
163
|
-
locals: { target: target_user, parameters: { fallback: :default } }
|
|
164
|
-
)
|
|
165
|
-
end
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
context "with custom view" do
|
|
169
|
-
before do
|
|
170
|
-
allow(self).to receive(:content_for).with(:notification_index).and_return('foo')
|
|
171
|
-
@target = target_user
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
it "renders custom notification view for specified target" do
|
|
175
|
-
expect(render_notification_of target_user, partial: 'custom_index', fallback: :default).to eq("Custom index: ")
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
it "uses layout of layout parameter" do
|
|
179
|
-
expect(self).to receive(:render).with({
|
|
180
|
-
partial: 'activity_notification/notifications/users/index',
|
|
181
|
-
layout: 'layouts/test',
|
|
182
|
-
locals: { target: target_user, parameters: {} }
|
|
183
|
-
})
|
|
184
|
-
render_notification_of target_user, layout: 'test'
|
|
185
|
-
end
|
|
186
|
-
end
|
|
187
|
-
|
|
188
|
-
context "with index_content option" do
|
|
189
|
-
before do
|
|
190
|
-
@target = target_user
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
context "as default" do
|
|
194
|
-
it "uses target.notification_index_with_attributes" do
|
|
195
|
-
expect(target_user).to receive(:notification_index_with_attributes)
|
|
196
|
-
render_notification_of target_user
|
|
197
|
-
end
|
|
198
|
-
end
|
|
199
|
-
|
|
200
|
-
context "with :simple" do
|
|
201
|
-
it "uses target.notification_index" do
|
|
202
|
-
expect(target_user).to receive(:notification_index)
|
|
203
|
-
render_notification_of target_user, index_content: :simple
|
|
204
|
-
end
|
|
205
|
-
end
|
|
206
|
-
|
|
207
|
-
context "with :unopened_simple" do
|
|
208
|
-
it "uses target.unopened_notification_index" do
|
|
209
|
-
expect(target_user).to receive(:unopened_notification_index).at_least(:once)
|
|
210
|
-
render_notification_of target_user, index_content: :unopened_simple
|
|
211
|
-
end
|
|
212
|
-
end
|
|
213
|
-
|
|
214
|
-
context "with :opened_simple" do
|
|
215
|
-
it "uses target.opened_notification_index" do
|
|
216
|
-
expect(target_user).to receive(:opened_notification_index).at_least(:once)
|
|
217
|
-
render_notification_of target_user, index_content: :opened_simple
|
|
218
|
-
end
|
|
219
|
-
end
|
|
220
|
-
|
|
221
|
-
context "with :with_attributes" do
|
|
222
|
-
it "uses target.notification_index_with_attributes" do
|
|
223
|
-
expect(target_user).to receive(:notification_index_with_attributes)
|
|
224
|
-
render_notification_of target_user, index_content: :with_attributes
|
|
225
|
-
end
|
|
226
|
-
end
|
|
227
|
-
|
|
228
|
-
context "with :unopened_with_attributes" do
|
|
229
|
-
it "uses target.unopened_notification_index_with_attributes" do
|
|
230
|
-
expect(target_user).to receive(:unopened_notification_index_with_attributes).at_least(:once)
|
|
231
|
-
render_notification_of target_user, index_content: :unopened_with_attributes
|
|
232
|
-
end
|
|
233
|
-
end
|
|
234
|
-
|
|
235
|
-
context "with :opened_with_attributes" do
|
|
236
|
-
it "uses target.opened_notification_index_with_attributes" do
|
|
237
|
-
expect(target_user).to receive(:opened_notification_index_with_attributes).at_least(:once)
|
|
238
|
-
render_notification_of target_user, index_content: :opened_with_attributes
|
|
239
|
-
end
|
|
240
|
-
end
|
|
241
|
-
|
|
242
|
-
context "with :none" do
|
|
243
|
-
it "uses neither target.notification_index nor notification_index_with_attributes" do
|
|
244
|
-
expect(target_user).not_to receive(:notification_index)
|
|
245
|
-
expect(target_user).not_to receive(:notification_index_with_attributes)
|
|
246
|
-
render_notification_of target_user, index_content: :none
|
|
247
|
-
end
|
|
248
|
-
end
|
|
249
|
-
|
|
250
|
-
context "with any other key" do
|
|
251
|
-
it "uses target.notification_index_with_attributes" do
|
|
252
|
-
expect(target_user).to receive(:notification_index_with_attributes)
|
|
253
|
-
render_notification_of target_user, index_content: :hoge
|
|
254
|
-
end
|
|
255
|
-
end
|
|
256
|
-
|
|
257
|
-
end
|
|
258
|
-
end
|
|
259
|
-
|
|
260
|
-
describe '#render_notifications_of' do
|
|
261
|
-
it "is an alias of render_notification_of" do
|
|
262
|
-
expect(self).to receive(:render_notification)
|
|
263
|
-
render_notifications_of target_user, fallback: :default
|
|
264
|
-
end
|
|
265
|
-
end
|
|
266
|
-
|
|
267
|
-
describe '#notifications_path_for' do
|
|
268
|
-
it "returns path for the notification target" do
|
|
269
|
-
expect(notifications_path_for(target_user))
|
|
270
|
-
.to eq(user_notifications_path(target_user))
|
|
271
|
-
end
|
|
272
|
-
end
|
|
273
|
-
|
|
274
|
-
describe '#notification_path_for' do
|
|
275
|
-
it "returns path for the notification target" do
|
|
276
|
-
expect(notification_path_for(notification))
|
|
277
|
-
.to eq(user_notification_path(target_user, notification))
|
|
278
|
-
end
|
|
279
|
-
end
|
|
280
|
-
|
|
281
|
-
describe '#move_notification_path_for' do
|
|
282
|
-
it "returns path for the notification target" do
|
|
283
|
-
expect(move_notification_path_for(notification))
|
|
284
|
-
.to eq(move_user_notification_path(target_user, notification))
|
|
285
|
-
end
|
|
286
|
-
end
|
|
287
|
-
|
|
288
|
-
describe '#open_notification_path_for' do
|
|
289
|
-
it "returns path for the notification target" do
|
|
290
|
-
expect(open_notification_path_for(notification))
|
|
291
|
-
.to eq(open_user_notification_path(target_user, notification))
|
|
292
|
-
end
|
|
293
|
-
end
|
|
294
|
-
|
|
295
|
-
describe '#open_all_notifications_path_for' do
|
|
296
|
-
it "returns path for the notification target" do
|
|
297
|
-
expect(open_all_notifications_path_for(target_user))
|
|
298
|
-
.to eq(open_all_user_notifications_path(target_user))
|
|
299
|
-
end
|
|
300
|
-
end
|
|
301
|
-
|
|
302
|
-
describe '#destroy_all_notifications_path_for' do
|
|
303
|
-
it "returns path for the notification target" do
|
|
304
|
-
expect(destroy_all_notifications_path_for(target_user))
|
|
305
|
-
.to eq(destroy_all_user_notifications_path(target_user))
|
|
306
|
-
end
|
|
307
|
-
end
|
|
308
|
-
|
|
309
|
-
describe '#notifications_url_for' do
|
|
310
|
-
it "returns url for the notification target" do
|
|
311
|
-
expect(notifications_url_for(target_user))
|
|
312
|
-
.to eq(user_notifications_url(target_user))
|
|
313
|
-
end
|
|
314
|
-
end
|
|
315
|
-
|
|
316
|
-
describe '#notification_url_for' do
|
|
317
|
-
it "returns url for the notification target" do
|
|
318
|
-
expect(notification_url_for(notification))
|
|
319
|
-
.to eq(user_notification_url(target_user, notification))
|
|
320
|
-
end
|
|
321
|
-
end
|
|
322
|
-
|
|
323
|
-
describe '#move_notification_url_for' do
|
|
324
|
-
it "returns url for the notification target" do
|
|
325
|
-
expect(move_notification_url_for(notification))
|
|
326
|
-
.to eq(move_user_notification_url(target_user, notification))
|
|
327
|
-
end
|
|
328
|
-
end
|
|
329
|
-
|
|
330
|
-
describe '#open_notification_url_for' do
|
|
331
|
-
it "returns url for the notification target" do
|
|
332
|
-
expect(open_notification_url_for(notification))
|
|
333
|
-
.to eq(open_user_notification_url(target_user, notification))
|
|
334
|
-
end
|
|
335
|
-
end
|
|
336
|
-
|
|
337
|
-
describe '#open_all_notifications_url_for' do
|
|
338
|
-
it "returns url for the notification target" do
|
|
339
|
-
expect(open_all_notifications_url_for(target_user))
|
|
340
|
-
.to eq(open_all_user_notifications_url(target_user))
|
|
341
|
-
end
|
|
342
|
-
end
|
|
343
|
-
|
|
344
|
-
describe '#destroy_all_notifications_url_for' do
|
|
345
|
-
it "returns url for the notification target" do
|
|
346
|
-
expect(destroy_all_notifications_url_for(target_user))
|
|
347
|
-
.to eq(destroy_all_user_notifications_url(target_user))
|
|
348
|
-
end
|
|
349
|
-
end
|
|
350
|
-
|
|
351
|
-
describe '#subscriptions_path_for' do
|
|
352
|
-
it "returns path for the subscription target" do
|
|
353
|
-
expect(subscriptions_path_for(target_user))
|
|
354
|
-
.to eq(user_subscriptions_path(target_user))
|
|
355
|
-
end
|
|
356
|
-
end
|
|
357
|
-
|
|
358
|
-
describe '#subscription_path_for' do
|
|
359
|
-
it "returns path for the subscription target" do
|
|
360
|
-
expect(subscription_path_for(subscription))
|
|
361
|
-
.to eq(user_subscription_path(target_user, subscription))
|
|
362
|
-
end
|
|
363
|
-
end
|
|
364
|
-
|
|
365
|
-
describe '#subscribe_subscription_path_for' do
|
|
366
|
-
it "returns path for the subscription target" do
|
|
367
|
-
expect(subscribe_subscription_path_for(subscription))
|
|
368
|
-
.to eq(subscribe_user_subscription_path(target_user, subscription))
|
|
369
|
-
end
|
|
370
|
-
end
|
|
371
|
-
|
|
372
|
-
describe '#subscribe_path_for' do
|
|
373
|
-
it "returns path for the subscription target" do
|
|
374
|
-
expect(subscribe_path_for(subscription))
|
|
375
|
-
.to eq(subscribe_user_subscription_path(target_user, subscription))
|
|
376
|
-
end
|
|
377
|
-
end
|
|
378
|
-
|
|
379
|
-
describe '#unsubscribe_subscription_path_for' do
|
|
380
|
-
it "returns path for the subscription target" do
|
|
381
|
-
expect(unsubscribe_subscription_path_for(subscription))
|
|
382
|
-
.to eq(unsubscribe_user_subscription_path(target_user, subscription))
|
|
383
|
-
end
|
|
384
|
-
end
|
|
385
|
-
|
|
386
|
-
describe '#unsubscribe_path_for' do
|
|
387
|
-
it "returns path for the subscription target" do
|
|
388
|
-
expect(unsubscribe_path_for(subscription))
|
|
389
|
-
.to eq(unsubscribe_user_subscription_path(target_user, subscription))
|
|
390
|
-
end
|
|
391
|
-
end
|
|
392
|
-
|
|
393
|
-
describe '#subscribe_to_email_subscription_path_for' do
|
|
394
|
-
it "returns path for the subscription target" do
|
|
395
|
-
expect(subscribe_to_email_subscription_path_for(subscription))
|
|
396
|
-
.to eq(subscribe_to_email_user_subscription_path(target_user, subscription))
|
|
397
|
-
end
|
|
398
|
-
end
|
|
399
|
-
|
|
400
|
-
describe '#subscribe_to_email_path_for' do
|
|
401
|
-
it "returns path for the subscription target" do
|
|
402
|
-
expect(subscribe_to_email_path_for(subscription))
|
|
403
|
-
.to eq(subscribe_to_email_user_subscription_path(target_user, subscription))
|
|
404
|
-
end
|
|
405
|
-
end
|
|
406
|
-
|
|
407
|
-
describe '#unsubscribe_to_email_subscription_path_for' do
|
|
408
|
-
it "returns path for the subscription target" do
|
|
409
|
-
expect(unsubscribe_to_email_subscription_path_for(subscription))
|
|
410
|
-
.to eq(unsubscribe_to_email_user_subscription_path(target_user, subscription))
|
|
411
|
-
end
|
|
412
|
-
end
|
|
413
|
-
|
|
414
|
-
describe '#unsubscribe_to_email_path_for' do
|
|
415
|
-
it "returns path for the subscription target" do
|
|
416
|
-
expect(unsubscribe_to_email_path_for(subscription))
|
|
417
|
-
.to eq(unsubscribe_to_email_user_subscription_path(target_user, subscription))
|
|
418
|
-
end
|
|
419
|
-
end
|
|
420
|
-
|
|
421
|
-
describe '#subscribe_to_optional_target_subscription_path_for' do
|
|
422
|
-
it "returns path for the subscription target" do
|
|
423
|
-
expect(subscribe_to_optional_target_subscription_path_for(subscription))
|
|
424
|
-
.to eq(subscribe_to_optional_target_user_subscription_path(target_user, subscription))
|
|
425
|
-
end
|
|
426
|
-
end
|
|
427
|
-
|
|
428
|
-
describe '#subscribe_to_optional_target_path_for' do
|
|
429
|
-
it "returns path for the subscription target" do
|
|
430
|
-
expect(subscribe_to_optional_target_path_for(subscription))
|
|
431
|
-
.to eq(subscribe_to_optional_target_user_subscription_path(target_user, subscription))
|
|
432
|
-
end
|
|
433
|
-
end
|
|
434
|
-
|
|
435
|
-
describe '#unsubscribe_to_optional_target_subscription_path_for' do
|
|
436
|
-
it "returns path for the subscription target" do
|
|
437
|
-
expect(unsubscribe_to_optional_target_subscription_path_for(subscription))
|
|
438
|
-
.to eq(unsubscribe_to_optional_target_user_subscription_path(target_user, subscription))
|
|
439
|
-
end
|
|
440
|
-
end
|
|
441
|
-
|
|
442
|
-
describe '#unsubscribe_to_optional_target_path_for' do
|
|
443
|
-
it "returns path for the subscription target" do
|
|
444
|
-
expect(unsubscribe_to_optional_target_path_for(subscription))
|
|
445
|
-
.to eq(unsubscribe_to_optional_target_user_subscription_path(target_user, subscription))
|
|
446
|
-
end
|
|
447
|
-
end
|
|
448
|
-
|
|
449
|
-
describe '#subscriptions_url_for' do
|
|
450
|
-
it "returns url for the subscription target" do
|
|
451
|
-
expect(subscriptions_url_for(target_user))
|
|
452
|
-
.to eq(user_subscriptions_url(target_user))
|
|
453
|
-
end
|
|
454
|
-
end
|
|
455
|
-
|
|
456
|
-
describe '#subscription_url_for' do
|
|
457
|
-
it "returns url for the subscription target" do
|
|
458
|
-
expect(subscription_url_for(subscription))
|
|
459
|
-
.to eq(user_subscription_url(target_user, subscription))
|
|
460
|
-
end
|
|
461
|
-
end
|
|
462
|
-
|
|
463
|
-
describe '#subscribe_subscription_url_for' do
|
|
464
|
-
it "returns url for the subscription target" do
|
|
465
|
-
expect(subscribe_subscription_url_for(subscription))
|
|
466
|
-
.to eq(subscribe_user_subscription_url(target_user, subscription))
|
|
467
|
-
end
|
|
468
|
-
end
|
|
469
|
-
|
|
470
|
-
describe '#subscribe_url_for' do
|
|
471
|
-
it "returns url for the subscription target" do
|
|
472
|
-
expect(subscribe_url_for(subscription))
|
|
473
|
-
.to eq(subscribe_user_subscription_url(target_user, subscription))
|
|
474
|
-
end
|
|
475
|
-
end
|
|
476
|
-
|
|
477
|
-
describe '#unsubscribe_subscription_url_for' do
|
|
478
|
-
it "returns url for the subscription target" do
|
|
479
|
-
expect(unsubscribe_subscription_url_for(subscription))
|
|
480
|
-
.to eq(unsubscribe_user_subscription_url(target_user, subscription))
|
|
481
|
-
end
|
|
482
|
-
end
|
|
483
|
-
|
|
484
|
-
describe '#unsubscribe_url_for' do
|
|
485
|
-
it "returns url for the subscription target" do
|
|
486
|
-
expect(unsubscribe_url_for(subscription))
|
|
487
|
-
.to eq(unsubscribe_user_subscription_url(target_user, subscription))
|
|
488
|
-
end
|
|
489
|
-
end
|
|
490
|
-
|
|
491
|
-
describe '#subscribe_to_email_subscription_url_for' do
|
|
492
|
-
it "returns url for the subscription target" do
|
|
493
|
-
expect(subscribe_to_email_subscription_url_for(subscription))
|
|
494
|
-
.to eq(subscribe_to_email_user_subscription_url(target_user, subscription))
|
|
495
|
-
end
|
|
496
|
-
end
|
|
497
|
-
|
|
498
|
-
describe '#subscribe_to_email_url_for' do
|
|
499
|
-
it "returns url for the subscription target" do
|
|
500
|
-
expect(subscribe_to_email_url_for(subscription))
|
|
501
|
-
.to eq(subscribe_to_email_user_subscription_url(target_user, subscription))
|
|
502
|
-
end
|
|
503
|
-
end
|
|
504
|
-
|
|
505
|
-
describe '#unsubscribe_to_email_subscription_url_for' do
|
|
506
|
-
it "returns url for the subscription target" do
|
|
507
|
-
expect(unsubscribe_to_email_subscription_url_for(subscription))
|
|
508
|
-
.to eq(unsubscribe_to_email_user_subscription_url(target_user, subscription))
|
|
509
|
-
end
|
|
510
|
-
end
|
|
511
|
-
|
|
512
|
-
describe '#unsubscribe_to_email_url_for' do
|
|
513
|
-
it "returns url for the subscription target" do
|
|
514
|
-
expect(unsubscribe_to_email_url_for(subscription))
|
|
515
|
-
.to eq(unsubscribe_to_email_user_subscription_url(target_user, subscription))
|
|
516
|
-
end
|
|
517
|
-
end
|
|
518
|
-
|
|
519
|
-
describe '#subscribe_to_optional_target_subscription_url_for' do
|
|
520
|
-
it "returns url for the subscription target" do
|
|
521
|
-
expect(subscribe_to_optional_target_subscription_url_for(subscription))
|
|
522
|
-
.to eq(subscribe_to_optional_target_user_subscription_url(target_user, subscription))
|
|
523
|
-
end
|
|
524
|
-
end
|
|
525
|
-
|
|
526
|
-
describe '#subscribe_to_optional_target_url_for' do
|
|
527
|
-
it "returns url for the subscription target" do
|
|
528
|
-
expect(subscribe_to_optional_target_url_for(subscription))
|
|
529
|
-
.to eq(subscribe_to_optional_target_user_subscription_url(target_user, subscription))
|
|
530
|
-
end
|
|
531
|
-
end
|
|
532
|
-
|
|
533
|
-
describe '#unsubscribe_to_optional_target_subscription_url_for' do
|
|
534
|
-
it "returns url for the subscription target" do
|
|
535
|
-
expect(unsubscribe_to_optional_target_subscription_url_for(subscription))
|
|
536
|
-
.to eq(unsubscribe_to_optional_target_user_subscription_url(target_user, subscription))
|
|
537
|
-
end
|
|
538
|
-
end
|
|
539
|
-
|
|
540
|
-
describe '#unsubscribe_to_optional_target_url_for' do
|
|
541
|
-
it "returns url for the subscription target" do
|
|
542
|
-
expect(unsubscribe_to_optional_target_url_for(subscription))
|
|
543
|
-
.to eq(unsubscribe_to_optional_target_user_subscription_url(target_user, subscription))
|
|
544
|
-
end
|
|
545
|
-
end
|
|
546
|
-
|
|
547
|
-
end
|