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,782 +0,0 @@
|
|
|
1
|
-
shared_examples_for :notifiable do
|
|
2
|
-
let(:test_class_name) { described_class.to_s.underscore.split('/').last.to_sym }
|
|
3
|
-
let(:test_instance) { create(test_class_name) }
|
|
4
|
-
let(:test_target) { create(:user) }
|
|
5
|
-
|
|
6
|
-
include Rails.application.routes.url_helpers
|
|
7
|
-
|
|
8
|
-
describe "as public class methods" do
|
|
9
|
-
describe ".available_as_notifiable?" do
|
|
10
|
-
it "returns true" do
|
|
11
|
-
expect(described_class.available_as_notifiable?).to be_truthy
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
describe ".set_notifiable_class_defaults" do
|
|
16
|
-
it "set parameter fields as default" do
|
|
17
|
-
described_class.set_notifiable_class_defaults
|
|
18
|
-
expect(described_class._notification_targets).to eq({})
|
|
19
|
-
expect(described_class._notification_group).to eq({})
|
|
20
|
-
expect(described_class._notification_group_expiry_delay).to eq({})
|
|
21
|
-
expect(described_class._notifier).to eq({})
|
|
22
|
-
expect(described_class._notification_parameters).to eq({})
|
|
23
|
-
expect(described_class._notification_email_allowed).to eq({})
|
|
24
|
-
expect(described_class._notifiable_action_cable_allowed).to eq({})
|
|
25
|
-
expect(described_class._notifiable_path).to eq({})
|
|
26
|
-
expect(described_class._printable_notifiable_name).to eq({})
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
describe "as public instance methods" do
|
|
32
|
-
before do
|
|
33
|
-
User.delete_all
|
|
34
|
-
described_class.set_notifiable_class_defaults
|
|
35
|
-
create(:user)
|
|
36
|
-
create(:user)
|
|
37
|
-
expect(User.all.count).to eq(2)
|
|
38
|
-
expect(User.all.first).to be_an_instance_of(User)
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
describe "#notification_targets" do
|
|
42
|
-
context "without any configuration" do
|
|
43
|
-
it "raises NotImplementedError" do
|
|
44
|
-
expect { test_instance.notification_targets(User, 'dummy_key') }
|
|
45
|
-
.to raise_error(NotImplementedError, /You have to implement .+ or set :targets in acts_as_notifiable/)
|
|
46
|
-
expect { test_instance.notification_targets(User, { key: 'dummy_key' }) }
|
|
47
|
-
.to raise_error(NotImplementedError, /You have to implement .+ or set :targets in acts_as_notifiable/)
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
context "configured with overridden method" do
|
|
52
|
-
it "returns specified value" do
|
|
53
|
-
module AdditionalMethods
|
|
54
|
-
def notification_users(key)
|
|
55
|
-
User.all
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
test_instance.extend(AdditionalMethods)
|
|
59
|
-
expect(test_instance.notification_targets(User, 'dummy_key')).to eq(User.all)
|
|
60
|
-
expect(test_instance.notification_targets(User, { key: 'dummy_key' })).to eq(User.all)
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
context "configured with a field" do
|
|
65
|
-
it "returns specified value" do
|
|
66
|
-
described_class._notification_targets[:users] = User.all
|
|
67
|
-
expect(test_instance.notification_targets(User, 'dummy_key')).to eq(User.all)
|
|
68
|
-
expect(test_instance.notification_targets(User, { key: 'dummy_key' })).to eq(User.all)
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
it "returns specified symbol without argumentss" do
|
|
72
|
-
module AdditionalMethods
|
|
73
|
-
def custom_notification_users
|
|
74
|
-
User.all
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
test_instance.extend(AdditionalMethods)
|
|
78
|
-
described_class._notification_targets[:users] = :custom_notification_users
|
|
79
|
-
expect(test_instance.notification_targets(User, 'dummy_key')).to eq(User.all)
|
|
80
|
-
expect(test_instance.notification_targets(User, { key: 'dummy_key' })).to eq(User.all)
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
it "returns specified symbol with key argument" do
|
|
84
|
-
module AdditionalMethods
|
|
85
|
-
def custom_notification_users(key)
|
|
86
|
-
User.all
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
test_instance.extend(AdditionalMethods)
|
|
90
|
-
described_class._notification_targets[:users] = :custom_notification_users
|
|
91
|
-
expect(test_instance.notification_targets(User, 'dummy_key')).to eq(User.all)
|
|
92
|
-
expect(test_instance.notification_targets(User, { key: 'dummy_key' })).to eq(User.all)
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
it "returns specified lambda with single notifiable argument" do
|
|
96
|
-
described_class._notification_targets[:users] = ->(notifiable){ User.all }
|
|
97
|
-
expect(test_instance.notification_targets(User, 'dummy_key')).to eq(User.all)
|
|
98
|
-
expect(test_instance.notification_targets(User, { key: 'dummy_key' })).to eq(User.all)
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
it "returns specified lambda with notifiable and key arguments" do
|
|
102
|
-
described_class._notification_targets[:users] = ->(notifiable, key){ User.all if key == 'dummy_key' }
|
|
103
|
-
expect(test_instance.notification_targets(User, 'dummy_key')).to eq(User.all)
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
it "returns specified lambda with notifiable and options arguments" do
|
|
107
|
-
described_class._notification_targets[:users] = ->(notifiable, options){ User.all if options[:key] == 'dummy_key' }
|
|
108
|
-
expect(test_instance.notification_targets(User, { key: 'dummy_key' })).to eq(User.all)
|
|
109
|
-
end
|
|
110
|
-
end
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
describe "#notification_group" do
|
|
114
|
-
context "without any configuration" do
|
|
115
|
-
it "returns nil" do
|
|
116
|
-
expect(test_instance.notification_group(User, 'dummy_key')).to be_nil
|
|
117
|
-
end
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
context "configured with overridden method" do
|
|
121
|
-
it "returns specified value" do
|
|
122
|
-
module AdditionalMethods
|
|
123
|
-
def notification_group_for_users(key)
|
|
124
|
-
User.all.first
|
|
125
|
-
end
|
|
126
|
-
end
|
|
127
|
-
test_instance.extend(AdditionalMethods)
|
|
128
|
-
expect(test_instance.notification_group(User, 'dummy_key')).to eq(User.all.first)
|
|
129
|
-
end
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
context "configured with a field" do
|
|
133
|
-
it "returns specified value" do
|
|
134
|
-
described_class._notification_group[:users] = User.all.first
|
|
135
|
-
expect(test_instance.notification_group(User, 'dummy_key')).to eq(User.all.first)
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
it "returns specified symbol without argumentss" do
|
|
139
|
-
module AdditionalMethods
|
|
140
|
-
def custom_notification_group
|
|
141
|
-
User.all.first
|
|
142
|
-
end
|
|
143
|
-
end
|
|
144
|
-
test_instance.extend(AdditionalMethods)
|
|
145
|
-
described_class._notification_group[:users] = :custom_notification_group
|
|
146
|
-
expect(test_instance.notification_group(User, 'dummy_key')).to eq(User.all.first)
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
it "returns specified symbol with key argument" do
|
|
150
|
-
module AdditionalMethods
|
|
151
|
-
def custom_notification_group(key)
|
|
152
|
-
User.all.first
|
|
153
|
-
end
|
|
154
|
-
end
|
|
155
|
-
test_instance.extend(AdditionalMethods)
|
|
156
|
-
described_class._notification_group[:users] = :custom_notification_group
|
|
157
|
-
expect(test_instance.notification_group(User, 'dummy_key')).to eq(User.all.first)
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
it "returns specified lambda with single notifiable argument" do
|
|
161
|
-
described_class._notification_group[:users] = ->(notifiable){ User.all.first }
|
|
162
|
-
expect(test_instance.notification_group(User, 'dummy_key')).to eq(User.all.first)
|
|
163
|
-
end
|
|
164
|
-
|
|
165
|
-
it "returns specified lambda with notifiable and key arguments" do
|
|
166
|
-
described_class._notification_group[:users] = ->(notifiable, key){ User.all.first }
|
|
167
|
-
expect(test_instance.notification_group(User, 'dummy_key')).to eq(User.all.first)
|
|
168
|
-
end
|
|
169
|
-
end
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
describe "#notification_group_expiry_delay" do
|
|
173
|
-
context "without any configuration" do
|
|
174
|
-
it "returns nil" do
|
|
175
|
-
expect(test_instance.notification_group_expiry_delay(User, 'dummy_key')).to be_nil
|
|
176
|
-
end
|
|
177
|
-
end
|
|
178
|
-
|
|
179
|
-
context "configured with overridden method" do
|
|
180
|
-
it "returns specified value" do
|
|
181
|
-
module AdditionalMethods
|
|
182
|
-
def notification_group_expiry_delay_for_users(key)
|
|
183
|
-
User.all.first
|
|
184
|
-
end
|
|
185
|
-
end
|
|
186
|
-
test_instance.extend(AdditionalMethods)
|
|
187
|
-
expect(test_instance.notification_group_expiry_delay(User, 'dummy_key')).to eq(User.all.first)
|
|
188
|
-
end
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
context "configured with a field" do
|
|
192
|
-
it "returns specified value" do
|
|
193
|
-
described_class._notification_group_expiry_delay[:users] = User.all.first
|
|
194
|
-
expect(test_instance.notification_group_expiry_delay(User, 'dummy_key')).to eq(User.all.first)
|
|
195
|
-
end
|
|
196
|
-
|
|
197
|
-
it "returns specified symbol without argumentss" do
|
|
198
|
-
module AdditionalMethods
|
|
199
|
-
def custom_notification_group_expiry_delay
|
|
200
|
-
User.all.first
|
|
201
|
-
end
|
|
202
|
-
end
|
|
203
|
-
test_instance.extend(AdditionalMethods)
|
|
204
|
-
described_class._notification_group_expiry_delay[:users] = :custom_notification_group_expiry_delay
|
|
205
|
-
expect(test_instance.notification_group_expiry_delay(User, 'dummy_key')).to eq(User.all.first)
|
|
206
|
-
end
|
|
207
|
-
|
|
208
|
-
it "returns specified symbol with key argument" do
|
|
209
|
-
module AdditionalMethods
|
|
210
|
-
def custom_notification_group_expiry_delay(key)
|
|
211
|
-
User.all.first
|
|
212
|
-
end
|
|
213
|
-
end
|
|
214
|
-
test_instance.extend(AdditionalMethods)
|
|
215
|
-
described_class._notification_group_expiry_delay[:users] = :custom_notification_group_expiry_delay
|
|
216
|
-
expect(test_instance.notification_group_expiry_delay(User, 'dummy_key')).to eq(User.all.first)
|
|
217
|
-
end
|
|
218
|
-
|
|
219
|
-
it "returns specified lambda with single notifiable argument" do
|
|
220
|
-
described_class._notification_group_expiry_delay[:users] = ->(notifiable){ User.all.first }
|
|
221
|
-
expect(test_instance.notification_group_expiry_delay(User, 'dummy_key')).to eq(User.all.first)
|
|
222
|
-
end
|
|
223
|
-
|
|
224
|
-
it "returns specified lambda with notifiable and key arguments" do
|
|
225
|
-
described_class._notification_group_expiry_delay[:users] = ->(notifiable, key){ User.all.first }
|
|
226
|
-
expect(test_instance.notification_group_expiry_delay(User, 'dummy_key')).to eq(User.all.first)
|
|
227
|
-
end
|
|
228
|
-
end
|
|
229
|
-
end
|
|
230
|
-
|
|
231
|
-
describe "#notification_parameters" do
|
|
232
|
-
context "without any configuration" do
|
|
233
|
-
it "returns blank hash" do
|
|
234
|
-
expect(test_instance.notification_parameters(User, 'dummy_key')).to eq({})
|
|
235
|
-
end
|
|
236
|
-
end
|
|
237
|
-
|
|
238
|
-
context "configured with overridden method" do
|
|
239
|
-
it "returns specified value" do
|
|
240
|
-
module AdditionalMethods
|
|
241
|
-
def notification_parameters_for_users(key)
|
|
242
|
-
{ hoge: 'fuga', foo: 'bar' }
|
|
243
|
-
end
|
|
244
|
-
end
|
|
245
|
-
test_instance.extend(AdditionalMethods)
|
|
246
|
-
expect(test_instance.notification_parameters(User, 'dummy_key')).to eq({ hoge: 'fuga', foo: 'bar' })
|
|
247
|
-
end
|
|
248
|
-
end
|
|
249
|
-
|
|
250
|
-
context "configured with a field" do
|
|
251
|
-
it "returns specified value" do
|
|
252
|
-
described_class._notification_parameters[:users] = { hoge: 'fuga', foo: 'bar' }
|
|
253
|
-
expect(test_instance.notification_parameters(User, 'dummy_key')).to eq({ hoge: 'fuga', foo: 'bar' })
|
|
254
|
-
end
|
|
255
|
-
|
|
256
|
-
it "returns specified symbol without arguments" do
|
|
257
|
-
module AdditionalMethods
|
|
258
|
-
def custom_notification_parameters
|
|
259
|
-
{ hoge: 'fuga', foo: 'bar' }
|
|
260
|
-
end
|
|
261
|
-
end
|
|
262
|
-
test_instance.extend(AdditionalMethods)
|
|
263
|
-
described_class._notification_parameters[:users] = :custom_notification_parameters
|
|
264
|
-
expect(test_instance.notification_parameters(User, 'dummy_key')).to eq({ hoge: 'fuga', foo: 'bar' })
|
|
265
|
-
end
|
|
266
|
-
|
|
267
|
-
it "returns specified symbol with key argument" do
|
|
268
|
-
module AdditionalMethods
|
|
269
|
-
def custom_notification_parameters(key)
|
|
270
|
-
{ hoge: 'fuga', foo: 'bar' }
|
|
271
|
-
end
|
|
272
|
-
end
|
|
273
|
-
test_instance.extend(AdditionalMethods)
|
|
274
|
-
described_class._notification_parameters[:users] = :custom_notification_parameters
|
|
275
|
-
expect(test_instance.notification_parameters(User, 'dummy_key')).to eq({ hoge: 'fuga', foo: 'bar' })
|
|
276
|
-
end
|
|
277
|
-
|
|
278
|
-
it "returns specified lambda with single notifiable argument" do
|
|
279
|
-
described_class._notification_parameters[:users] = ->(notifiable){ { hoge: 'fuga', foo: 'bar' } }
|
|
280
|
-
expect(test_instance.notification_parameters(User, 'dummy_key')).to eq({ hoge: 'fuga', foo: 'bar' })
|
|
281
|
-
end
|
|
282
|
-
|
|
283
|
-
it "returns specified lambda with notifiable and key arguments" do
|
|
284
|
-
described_class._notification_parameters[:users] = ->(notifiable, key){ { hoge: 'fuga', foo: 'bar' } }
|
|
285
|
-
expect(test_instance.notification_parameters(User, 'dummy_key')).to eq({ hoge: 'fuga', foo: 'bar' })
|
|
286
|
-
end
|
|
287
|
-
end
|
|
288
|
-
end
|
|
289
|
-
|
|
290
|
-
describe "#notifier" do
|
|
291
|
-
context "without any configuration" do
|
|
292
|
-
it "returns nil" do
|
|
293
|
-
expect(test_instance.notifier(User, 'dummy_key')).to be_nil
|
|
294
|
-
end
|
|
295
|
-
end
|
|
296
|
-
|
|
297
|
-
context "configured with overridden method" do
|
|
298
|
-
it "returns specified value" do
|
|
299
|
-
module AdditionalMethods
|
|
300
|
-
def notifier_for_users(key)
|
|
301
|
-
User.all.first
|
|
302
|
-
end
|
|
303
|
-
end
|
|
304
|
-
test_instance.extend(AdditionalMethods)
|
|
305
|
-
expect(test_instance.notifier(User, 'dummy_key')).to eq(User.all.first)
|
|
306
|
-
end
|
|
307
|
-
end
|
|
308
|
-
|
|
309
|
-
context "configured with a field" do
|
|
310
|
-
it "returns specified value" do
|
|
311
|
-
described_class._notifier[:users] = User.all.first
|
|
312
|
-
expect(test_instance.notifier(User, 'dummy_key')).to eq(User.all.first)
|
|
313
|
-
end
|
|
314
|
-
|
|
315
|
-
it "returns specified symbol without arguments" do
|
|
316
|
-
module AdditionalMethods
|
|
317
|
-
def custom_notifier
|
|
318
|
-
User.all.first
|
|
319
|
-
end
|
|
320
|
-
end
|
|
321
|
-
test_instance.extend(AdditionalMethods)
|
|
322
|
-
described_class._notifier[:users] = :custom_notifier
|
|
323
|
-
expect(test_instance.notifier(User, 'dummy_key')).to eq(User.all.first)
|
|
324
|
-
end
|
|
325
|
-
|
|
326
|
-
it "returns specified symbol with key argument" do
|
|
327
|
-
module AdditionalMethods
|
|
328
|
-
def custom_notifier(key)
|
|
329
|
-
User.all.first
|
|
330
|
-
end
|
|
331
|
-
end
|
|
332
|
-
test_instance.extend(AdditionalMethods)
|
|
333
|
-
described_class._notifier[:users] = :custom_notifier
|
|
334
|
-
expect(test_instance.notifier(User, 'dummy_key')).to eq(User.all.first)
|
|
335
|
-
end
|
|
336
|
-
|
|
337
|
-
it "returns specified lambda with single notifiable argument" do
|
|
338
|
-
described_class._notifier[:users] = ->(notifiable){ User.all.first }
|
|
339
|
-
expect(test_instance.notifier(User, 'dummy_key')).to eq(User.all.first)
|
|
340
|
-
end
|
|
341
|
-
|
|
342
|
-
it "returns specified lambda with notifiable and key arguments" do
|
|
343
|
-
described_class._notifier[:users] = ->(notifiable, key){ User.all.first }
|
|
344
|
-
expect(test_instance.notifier(User, 'dummy_key')).to eq(User.all.first)
|
|
345
|
-
end
|
|
346
|
-
end
|
|
347
|
-
end
|
|
348
|
-
|
|
349
|
-
describe "#notification_email_allowed?" do
|
|
350
|
-
context "without any configuration" do
|
|
351
|
-
it "returns ActivityNotification.config.email_enabled" do
|
|
352
|
-
expect(test_instance.notification_email_allowed?(test_target, 'dummy_key'))
|
|
353
|
-
.to eq(ActivityNotification.config.email_enabled)
|
|
354
|
-
end
|
|
355
|
-
|
|
356
|
-
it "returns false as default" do
|
|
357
|
-
expect(test_instance.notification_email_allowed?(test_target, 'dummy_key')).to be_falsey
|
|
358
|
-
end
|
|
359
|
-
end
|
|
360
|
-
|
|
361
|
-
context "configured with overridden method" do
|
|
362
|
-
it "returns specified value" do
|
|
363
|
-
module AdditionalMethods
|
|
364
|
-
def notification_email_allowed_for_users?(target, key)
|
|
365
|
-
true
|
|
366
|
-
end
|
|
367
|
-
end
|
|
368
|
-
test_instance.extend(AdditionalMethods)
|
|
369
|
-
expect(test_instance.notification_email_allowed?(test_target, 'dummy_key')).to eq(true)
|
|
370
|
-
end
|
|
371
|
-
end
|
|
372
|
-
|
|
373
|
-
context "configured with a field" do
|
|
374
|
-
it "returns specified value" do
|
|
375
|
-
described_class._notification_email_allowed[:users] = true
|
|
376
|
-
expect(test_instance.notification_email_allowed?(test_target, 'dummy_key')).to eq(true)
|
|
377
|
-
end
|
|
378
|
-
|
|
379
|
-
it "returns specified symbol without arguments" do
|
|
380
|
-
module AdditionalMethods
|
|
381
|
-
def custom_notification_email_allowed?
|
|
382
|
-
true
|
|
383
|
-
end
|
|
384
|
-
end
|
|
385
|
-
test_instance.extend(AdditionalMethods)
|
|
386
|
-
described_class._notification_email_allowed[:users] = :custom_notification_email_allowed?
|
|
387
|
-
expect(test_instance.notification_email_allowed?(test_target, 'dummy_key')).to eq(true)
|
|
388
|
-
end
|
|
389
|
-
|
|
390
|
-
it "returns specified symbol with target and key arguments" do
|
|
391
|
-
module AdditionalMethods
|
|
392
|
-
def custom_notification_email_allowed?(target, key)
|
|
393
|
-
true
|
|
394
|
-
end
|
|
395
|
-
end
|
|
396
|
-
test_instance.extend(AdditionalMethods)
|
|
397
|
-
described_class._notification_email_allowed[:users] = :custom_notification_email_allowed?
|
|
398
|
-
expect(test_instance.notification_email_allowed?(test_target, 'dummy_key')).to eq(true)
|
|
399
|
-
end
|
|
400
|
-
|
|
401
|
-
it "returns specified lambda with single notifiable argument" do
|
|
402
|
-
described_class._notification_email_allowed[:users] = ->(notifiable){ true }
|
|
403
|
-
expect(test_instance.notification_email_allowed?(test_target, 'dummy_key')).to eq(true)
|
|
404
|
-
end
|
|
405
|
-
|
|
406
|
-
it "returns specified lambda with notifiable, target and key arguments" do
|
|
407
|
-
described_class._notification_email_allowed[:users] = ->(notifiable, target, key){ true }
|
|
408
|
-
expect(test_instance.notification_email_allowed?(test_target, 'dummy_key')).to eq(true)
|
|
409
|
-
end
|
|
410
|
-
end
|
|
411
|
-
end
|
|
412
|
-
|
|
413
|
-
describe "#notifiable_action_cable_allowed?" do
|
|
414
|
-
context "without any configuration" do
|
|
415
|
-
it "returns ActivityNotification.config.action_cable_enabled" do
|
|
416
|
-
expect(test_instance.notifiable_action_cable_allowed?(test_target, 'dummy_key'))
|
|
417
|
-
.to eq(ActivityNotification.config.action_cable_enabled)
|
|
418
|
-
end
|
|
419
|
-
|
|
420
|
-
it "returns false as default" do
|
|
421
|
-
expect(test_instance.notifiable_action_cable_allowed?(test_target, 'dummy_key')).to be_falsey
|
|
422
|
-
end
|
|
423
|
-
end
|
|
424
|
-
|
|
425
|
-
context "configured with overridden method" do
|
|
426
|
-
it "returns specified value" do
|
|
427
|
-
module AdditionalMethods
|
|
428
|
-
def notifiable_action_cable_allowed_for_users?(target, key)
|
|
429
|
-
true
|
|
430
|
-
end
|
|
431
|
-
end
|
|
432
|
-
test_instance.extend(AdditionalMethods)
|
|
433
|
-
expect(test_instance.notifiable_action_cable_allowed?(test_target, 'dummy_key')).to eq(true)
|
|
434
|
-
end
|
|
435
|
-
end
|
|
436
|
-
|
|
437
|
-
context "configured with a field" do
|
|
438
|
-
it "returns specified value" do
|
|
439
|
-
described_class._notifiable_action_cable_allowed[:users] = true
|
|
440
|
-
expect(test_instance.notifiable_action_cable_allowed?(test_target, 'dummy_key')).to eq(true)
|
|
441
|
-
end
|
|
442
|
-
|
|
443
|
-
it "returns specified symbol without arguments" do
|
|
444
|
-
module AdditionalMethods
|
|
445
|
-
def custom_notifiable_action_cable_allowed?
|
|
446
|
-
true
|
|
447
|
-
end
|
|
448
|
-
end
|
|
449
|
-
test_instance.extend(AdditionalMethods)
|
|
450
|
-
described_class._notifiable_action_cable_allowed[:users] = :custom_notifiable_action_cable_allowed?
|
|
451
|
-
expect(test_instance.notifiable_action_cable_allowed?(test_target, 'dummy_key')).to eq(true)
|
|
452
|
-
end
|
|
453
|
-
|
|
454
|
-
it "returns specified symbol with target and key arguments" do
|
|
455
|
-
module AdditionalMethods
|
|
456
|
-
def custom_notifiable_action_cable_allowed?(target, key)
|
|
457
|
-
true
|
|
458
|
-
end
|
|
459
|
-
end
|
|
460
|
-
test_instance.extend(AdditionalMethods)
|
|
461
|
-
described_class._notifiable_action_cable_allowed[:users] = :custom_notifiable_action_cable_allowed?
|
|
462
|
-
expect(test_instance.notifiable_action_cable_allowed?(test_target, 'dummy_key')).to eq(true)
|
|
463
|
-
end
|
|
464
|
-
|
|
465
|
-
it "returns specified lambda with single notifiable argument" do
|
|
466
|
-
described_class._notifiable_action_cable_allowed[:users] = ->(notifiable){ true }
|
|
467
|
-
expect(test_instance.notifiable_action_cable_allowed?(test_target, 'dummy_key')).to eq(true)
|
|
468
|
-
end
|
|
469
|
-
|
|
470
|
-
it "returns specified lambda with notifiable, target and key arguments" do
|
|
471
|
-
described_class._notifiable_action_cable_allowed[:users] = ->(notifiable, target, key){ true }
|
|
472
|
-
expect(test_instance.notifiable_action_cable_allowed?(test_target, 'dummy_key')).to eq(true)
|
|
473
|
-
end
|
|
474
|
-
end
|
|
475
|
-
end
|
|
476
|
-
|
|
477
|
-
describe "#notifiable_action_cable_api_allowed?" do
|
|
478
|
-
context "without any configuration" do
|
|
479
|
-
it "returns ActivityNotification.config.action_cable_api_enabled" do
|
|
480
|
-
expect(test_instance.notifiable_action_cable_api_allowed?(test_target, 'dummy_key'))
|
|
481
|
-
.to eq(ActivityNotification.config.action_cable_api_enabled)
|
|
482
|
-
end
|
|
483
|
-
|
|
484
|
-
it "returns false as default" do
|
|
485
|
-
expect(test_instance.notifiable_action_cable_api_allowed?(test_target, 'dummy_key')).to be_falsey
|
|
486
|
-
end
|
|
487
|
-
end
|
|
488
|
-
|
|
489
|
-
context "configured with overridden method" do
|
|
490
|
-
it "returns specified value" do
|
|
491
|
-
module AdditionalMethods
|
|
492
|
-
def notifiable_action_cable_api_allowed_for_users?(target, key)
|
|
493
|
-
true
|
|
494
|
-
end
|
|
495
|
-
end
|
|
496
|
-
test_instance.extend(AdditionalMethods)
|
|
497
|
-
expect(test_instance.notifiable_action_cable_api_allowed?(test_target, 'dummy_key')).to eq(true)
|
|
498
|
-
end
|
|
499
|
-
end
|
|
500
|
-
|
|
501
|
-
context "configured with a field" do
|
|
502
|
-
it "returns specified value" do
|
|
503
|
-
described_class._notifiable_action_cable_api_allowed[:users] = true
|
|
504
|
-
expect(test_instance.notifiable_action_cable_api_allowed?(test_target, 'dummy_key')).to eq(true)
|
|
505
|
-
end
|
|
506
|
-
|
|
507
|
-
it "returns specified symbol without arguments" do
|
|
508
|
-
module AdditionalMethods
|
|
509
|
-
def custom_notifiable_action_cable_api_allowed?
|
|
510
|
-
true
|
|
511
|
-
end
|
|
512
|
-
end
|
|
513
|
-
test_instance.extend(AdditionalMethods)
|
|
514
|
-
described_class._notifiable_action_cable_api_allowed[:users] = :custom_notifiable_action_cable_api_allowed?
|
|
515
|
-
expect(test_instance.notifiable_action_cable_api_allowed?(test_target, 'dummy_key')).to eq(true)
|
|
516
|
-
end
|
|
517
|
-
|
|
518
|
-
it "returns specified symbol with target and key arguments" do
|
|
519
|
-
module AdditionalMethods
|
|
520
|
-
def custom_notifiable_action_cable_api_allowed?(target, key)
|
|
521
|
-
true
|
|
522
|
-
end
|
|
523
|
-
end
|
|
524
|
-
test_instance.extend(AdditionalMethods)
|
|
525
|
-
described_class._notifiable_action_cable_api_allowed[:users] = :custom_notifiable_action_cable_api_allowed?
|
|
526
|
-
expect(test_instance.notifiable_action_cable_api_allowed?(test_target, 'dummy_key')).to eq(true)
|
|
527
|
-
end
|
|
528
|
-
|
|
529
|
-
it "returns specified lambda with single notifiable argument" do
|
|
530
|
-
described_class._notifiable_action_cable_api_allowed[:users] = ->(notifiable){ true }
|
|
531
|
-
expect(test_instance.notifiable_action_cable_api_allowed?(test_target, 'dummy_key')).to eq(true)
|
|
532
|
-
end
|
|
533
|
-
|
|
534
|
-
it "returns specified lambda with notifiable, target and key arguments" do
|
|
535
|
-
described_class._notifiable_action_cable_api_allowed[:users] = ->(notifiable, target, key){ true }
|
|
536
|
-
expect(test_instance.notifiable_action_cable_api_allowed?(test_target, 'dummy_key')).to eq(true)
|
|
537
|
-
end
|
|
538
|
-
end
|
|
539
|
-
end
|
|
540
|
-
|
|
541
|
-
describe "#notifiable_path" do
|
|
542
|
-
context "without any configuration" do
|
|
543
|
-
it "raises NotImplementedError" do
|
|
544
|
-
expect { test_instance.notifiable_path(User, 'dummy_key') }
|
|
545
|
-
.to raise_error(NotImplementedError, /You have to implement .+, set :notifiable_path in acts_as_notifiable or set polymorphic_path routing for/)
|
|
546
|
-
end
|
|
547
|
-
end
|
|
548
|
-
|
|
549
|
-
context "configured with polymorphic_path" do
|
|
550
|
-
it "returns polymorphic_path" do
|
|
551
|
-
article = create(:article)
|
|
552
|
-
expect(article.notifiable_path(User, 'dummy_key')).to eq(article_path(article))
|
|
553
|
-
end
|
|
554
|
-
end
|
|
555
|
-
|
|
556
|
-
context "configured with overridden method" do
|
|
557
|
-
it "returns specified value" do
|
|
558
|
-
module AdditionalMethods
|
|
559
|
-
def notifiable_path_for_users(key)
|
|
560
|
-
article_path(1)
|
|
561
|
-
end
|
|
562
|
-
end
|
|
563
|
-
test_instance.extend(AdditionalMethods)
|
|
564
|
-
expect(test_instance.notifiable_path(User, 'dummy_key')).to eq(article_path(1))
|
|
565
|
-
end
|
|
566
|
-
end
|
|
567
|
-
|
|
568
|
-
context "configured with a field" do
|
|
569
|
-
it "returns specified value" do
|
|
570
|
-
described_class._notifiable_path[:users] = article_path(1)
|
|
571
|
-
expect(test_instance.notifiable_path(User, 'dummy_key')).to eq(article_path(1))
|
|
572
|
-
end
|
|
573
|
-
|
|
574
|
-
it "returns specified symbol without arguments" do
|
|
575
|
-
module AdditionalMethods
|
|
576
|
-
def custom_notifiable_path
|
|
577
|
-
article_path(1)
|
|
578
|
-
end
|
|
579
|
-
end
|
|
580
|
-
test_instance.extend(AdditionalMethods)
|
|
581
|
-
described_class._notifiable_path[:users] = :custom_notifiable_path
|
|
582
|
-
expect(test_instance.notifiable_path(User, 'dummy_key')).to eq(article_path(1))
|
|
583
|
-
end
|
|
584
|
-
|
|
585
|
-
it "returns specified symbol with key argument" do
|
|
586
|
-
module AdditionalMethods
|
|
587
|
-
def custom_notifiable_path(key)
|
|
588
|
-
article_path(1)
|
|
589
|
-
end
|
|
590
|
-
end
|
|
591
|
-
test_instance.extend(AdditionalMethods)
|
|
592
|
-
described_class._notifiable_path[:users] = :custom_notifiable_path
|
|
593
|
-
expect(test_instance.notifiable_path(User, 'dummy_key')).to eq(article_path(1))
|
|
594
|
-
end
|
|
595
|
-
|
|
596
|
-
it "returns specified lambda with single notifiable argument" do
|
|
597
|
-
described_class._notifiable_path[:users] = ->(notifiable){ article_path(1) }
|
|
598
|
-
expect(test_instance.notifiable_path(User, 'dummy_key')).to eq(article_path(1))
|
|
599
|
-
end
|
|
600
|
-
|
|
601
|
-
it "returns specified lambda with notifiable and key arguments" do
|
|
602
|
-
described_class._notifiable_path[:users] = ->(notifiable, key){ article_path(1) }
|
|
603
|
-
expect(test_instance.notifiable_path(User, 'dummy_key')).to eq(article_path(1))
|
|
604
|
-
end
|
|
605
|
-
end
|
|
606
|
-
end
|
|
607
|
-
|
|
608
|
-
describe "#printable_notifiable_name" do
|
|
609
|
-
context "without any configuration" do
|
|
610
|
-
it "returns ActivityNotification::Common.printable_name" do
|
|
611
|
-
expect(test_instance.printable_notifiable_name(test_target, 'dummy_key')).to eq(test_instance.printable_name)
|
|
612
|
-
end
|
|
613
|
-
end
|
|
614
|
-
|
|
615
|
-
context "configured with a field" do
|
|
616
|
-
it "returns specified value" do
|
|
617
|
-
described_class._printable_notifiable_name[:users] = 'test_printable_name'
|
|
618
|
-
expect(test_instance.printable_notifiable_name(test_target, 'dummy_key')).to eq('test_printable_name')
|
|
619
|
-
end
|
|
620
|
-
|
|
621
|
-
it "returns specified symbol of field" do
|
|
622
|
-
described_class._printable_notifiable_name[:users] = :title
|
|
623
|
-
expect(test_instance.printable_notifiable_name(test_target, 'dummy_key')).to eq(test_instance.title)
|
|
624
|
-
end
|
|
625
|
-
|
|
626
|
-
it "returns specified symbol of method" do
|
|
627
|
-
module AdditionalMethods
|
|
628
|
-
def custom_printable_name
|
|
629
|
-
'test_printable_name'
|
|
630
|
-
end
|
|
631
|
-
end
|
|
632
|
-
test_instance.extend(AdditionalMethods)
|
|
633
|
-
described_class._printable_notifiable_name[:users] = :custom_printable_name
|
|
634
|
-
expect(test_instance.printable_notifiable_name(test_target, 'dummy_key')).to eq('test_printable_name')
|
|
635
|
-
end
|
|
636
|
-
|
|
637
|
-
it "returns specified lambda with notifiable, target and key argument" do
|
|
638
|
-
described_class._printable_notifiable_name[:users] = ->(notifiable, target, key){ 'test_printable_name' }
|
|
639
|
-
expect(test_instance.printable_notifiable_name(test_target, 'dummy_key')).to eq('test_printable_name')
|
|
640
|
-
end
|
|
641
|
-
end
|
|
642
|
-
end
|
|
643
|
-
|
|
644
|
-
describe "#optional_targets" do
|
|
645
|
-
require 'custom_optional_targets/console_output'
|
|
646
|
-
|
|
647
|
-
context "without any configuration" do
|
|
648
|
-
it "returns blank array" do
|
|
649
|
-
expect(test_instance.optional_targets(test_target, 'dummy_key')).to eq([])
|
|
650
|
-
end
|
|
651
|
-
end
|
|
652
|
-
|
|
653
|
-
context "configured with a field" do
|
|
654
|
-
before do
|
|
655
|
-
@optional_target_instance = CustomOptionalTarget::ConsoleOutput.new
|
|
656
|
-
end
|
|
657
|
-
|
|
658
|
-
it "returns specified value" do
|
|
659
|
-
described_class._optional_targets[:users] = [@optional_target_instance]
|
|
660
|
-
expect(test_instance.optional_targets(User, 'dummy_key')).to eq([@optional_target_instance])
|
|
661
|
-
end
|
|
662
|
-
|
|
663
|
-
it "returns specified symbol of method" do
|
|
664
|
-
module AdditionalMethods
|
|
665
|
-
require 'custom_optional_targets/console_output'
|
|
666
|
-
def custom_optional_targets
|
|
667
|
-
[CustomOptionalTarget::ConsoleOutput.new]
|
|
668
|
-
end
|
|
669
|
-
end
|
|
670
|
-
test_instance.extend(AdditionalMethods)
|
|
671
|
-
described_class._optional_targets[:users] = :custom_optional_targets
|
|
672
|
-
expect(test_instance.optional_targets(User, 'dummy_key').size).to eq(1)
|
|
673
|
-
expect(test_instance.optional_targets(User, 'dummy_key').first).to be_a(CustomOptionalTarget::ConsoleOutput)
|
|
674
|
-
end
|
|
675
|
-
|
|
676
|
-
it "returns specified lambda with no arguments" do
|
|
677
|
-
described_class._optional_targets[:users] = ->{ [CustomOptionalTarget::ConsoleOutput.new] }
|
|
678
|
-
expect(test_instance.optional_targets(User, 'dummy_key').first).to be_a(CustomOptionalTarget::ConsoleOutput)
|
|
679
|
-
end
|
|
680
|
-
|
|
681
|
-
it "returns specified lambda with notifiable and key argument" do
|
|
682
|
-
described_class._optional_targets[:users] = ->(notifiable, key){ key == 'dummy_key' ? [CustomOptionalTarget::ConsoleOutput.new] : [] }
|
|
683
|
-
expect(test_instance.optional_targets(User)).to eq([])
|
|
684
|
-
expect(test_instance.optional_targets(User, 'dummy_key').first).to be_a(CustomOptionalTarget::ConsoleOutput)
|
|
685
|
-
end
|
|
686
|
-
end
|
|
687
|
-
end
|
|
688
|
-
|
|
689
|
-
describe "#optional_target_names" do
|
|
690
|
-
require 'custom_optional_targets/console_output'
|
|
691
|
-
|
|
692
|
-
context "without any configuration" do
|
|
693
|
-
it "returns blank array" do
|
|
694
|
-
expect(test_instance.optional_target_names(test_target, 'dummy_key')).to eq([])
|
|
695
|
-
end
|
|
696
|
-
end
|
|
697
|
-
|
|
698
|
-
context "configured with a field" do
|
|
699
|
-
before do
|
|
700
|
-
@optional_target_instance = CustomOptionalTarget::ConsoleOutput.new
|
|
701
|
-
end
|
|
702
|
-
|
|
703
|
-
it "returns specified value" do
|
|
704
|
-
described_class._optional_targets[:users] = [@optional_target_instance]
|
|
705
|
-
expect(test_instance.optional_target_names(User, 'dummy_key')).to eq([:console_output])
|
|
706
|
-
end
|
|
707
|
-
|
|
708
|
-
it "returns specified symbol of method" do
|
|
709
|
-
module AdditionalMethods
|
|
710
|
-
require 'custom_optional_targets/console_output'
|
|
711
|
-
def custom_optional_targets
|
|
712
|
-
[CustomOptionalTarget::ConsoleOutput.new]
|
|
713
|
-
end
|
|
714
|
-
end
|
|
715
|
-
test_instance.extend(AdditionalMethods)
|
|
716
|
-
described_class._optional_targets[:users] = :custom_optional_targets
|
|
717
|
-
expect(test_instance.optional_target_names(User, 'dummy_key')).to eq([:console_output])
|
|
718
|
-
end
|
|
719
|
-
|
|
720
|
-
it "returns specified lambda with no arguments" do
|
|
721
|
-
described_class._optional_targets[:users] = ->{ [@optional_target_instance] }
|
|
722
|
-
expect(test_instance.optional_target_names(User, 'dummy_key')).to eq([:console_output])
|
|
723
|
-
end
|
|
724
|
-
|
|
725
|
-
it "returns specified lambda with notifiable and key argument" do
|
|
726
|
-
described_class._optional_targets[:users] = ->(notifiable, key){ key == 'dummy_key' ? [@optional_target_instance] : [] }
|
|
727
|
-
expect(test_instance.optional_target_names(User, 'dummy_key')).to eq([:console_output])
|
|
728
|
-
end
|
|
729
|
-
end
|
|
730
|
-
end
|
|
731
|
-
|
|
732
|
-
describe "#notify" do
|
|
733
|
-
it "is an alias of ActivityNotification::Notification.notify" do
|
|
734
|
-
expect(ActivityNotification::Notification).to receive(:notify)
|
|
735
|
-
test_instance.notify :users
|
|
736
|
-
end
|
|
737
|
-
end
|
|
738
|
-
|
|
739
|
-
describe "#notify_later" do
|
|
740
|
-
it "is an alias of ActivityNotification::Notification.notify_later" do
|
|
741
|
-
expect(ActivityNotification::Notification).to receive(:notify_later)
|
|
742
|
-
test_instance.notify_later :users
|
|
743
|
-
end
|
|
744
|
-
end
|
|
745
|
-
|
|
746
|
-
describe "#notify_all" do
|
|
747
|
-
it "is an alias of ActivityNotification::Notification.notify_all" do
|
|
748
|
-
expect(ActivityNotification::Notification).to receive(:notify_all)
|
|
749
|
-
test_instance.notify_all [create(:user)]
|
|
750
|
-
end
|
|
751
|
-
end
|
|
752
|
-
|
|
753
|
-
describe "#notify_all_later" do
|
|
754
|
-
it "is an alias of ActivityNotification::Notification.notify_all_later" do
|
|
755
|
-
expect(ActivityNotification::Notification).to receive(:notify_all_later)
|
|
756
|
-
test_instance.notify_all_later [create(:user)]
|
|
757
|
-
end
|
|
758
|
-
end
|
|
759
|
-
|
|
760
|
-
describe "#notify_to" do
|
|
761
|
-
it "is an alias of ActivityNotification::Notification.notify_to" do
|
|
762
|
-
expect(ActivityNotification::Notification).to receive(:notify_to)
|
|
763
|
-
test_instance.notify_to create(:user)
|
|
764
|
-
end
|
|
765
|
-
end
|
|
766
|
-
|
|
767
|
-
describe "#notify_later_to" do
|
|
768
|
-
it "is an alias of ActivityNotification::Notification.notify_later_to" do
|
|
769
|
-
expect(ActivityNotification::Notification).to receive(:notify_later_to)
|
|
770
|
-
test_instance.notify_later_to create(:user)
|
|
771
|
-
end
|
|
772
|
-
end
|
|
773
|
-
|
|
774
|
-
describe "#default_notification_key" do
|
|
775
|
-
it "returns '#to_resource_name.default'" do
|
|
776
|
-
expect(test_instance.default_notification_key).to eq("#{test_instance.to_resource_name}.default")
|
|
777
|
-
end
|
|
778
|
-
end
|
|
779
|
-
|
|
780
|
-
end
|
|
781
|
-
|
|
782
|
-
end
|