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,750 +0,0 @@
|
|
|
1
|
-
require_relative 'controller_spec_utility'
|
|
2
|
-
|
|
3
|
-
shared_examples_for :subscriptions_api_controller do
|
|
4
|
-
include ActivityNotification::ControllerSpec::RequestUtility
|
|
5
|
-
include ActivityNotification::ControllerSpec::ApiResponseUtility
|
|
6
|
-
|
|
7
|
-
let(:target_params) { { target_type: target_type }.merge(extra_params || {}) }
|
|
8
|
-
|
|
9
|
-
describe "GET #index" do
|
|
10
|
-
context "with target_type and target_id parameters" do
|
|
11
|
-
before do
|
|
12
|
-
@subscription = create(:subscription, target: test_target, key: 'test_subscription_key')
|
|
13
|
-
@notification = create(:notification, target: test_target, key: 'test_notification_key')
|
|
14
|
-
get_with_compatibility :index, target_params.merge({ target_id: test_target, typed_target_param => 'dummy' }), valid_session
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it "returns 200 as http status code" do
|
|
18
|
-
expect(response.status).to eq(200)
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
it "returns configured subscription index as JSON" do
|
|
22
|
-
expect(response_json["configured_count"]).to eq(1)
|
|
23
|
-
assert_json_with_object_array(response_json["subscriptions"], [@subscription])
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
it "returns unconfigured notification keys as JSON" do
|
|
27
|
-
expect(response_json["unconfigured_count"]).to eq(1)
|
|
28
|
-
expect(response_json['unconfigured_notification_keys']).to eq([@notification.key])
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
context "with target_type and (typed_target)_id parameters" do
|
|
33
|
-
before do
|
|
34
|
-
@subscription = create(:subscription, target: test_target, key: 'test_subscription_key')
|
|
35
|
-
@notification = create(:notification, target: test_target, key: 'test_notification_key')
|
|
36
|
-
get_with_compatibility :index, target_params.merge({ typed_target_param => test_target }), valid_session
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
it "returns 200 as http status code" do
|
|
40
|
-
expect(response.status).to eq(200)
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
it "returns subscription index as JSON" do
|
|
44
|
-
expect(response_json["configured_count"]).to eq(1)
|
|
45
|
-
assert_json_with_object_array(response_json["subscriptions"], [@subscription])
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
it "returns unconfigured notification keys as JSON" do
|
|
49
|
-
expect(response_json["unconfigured_count"]).to eq(1)
|
|
50
|
-
expect(response_json['unconfigured_notification_keys']).to eq([@notification.key])
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
context "without target_type parameters" do
|
|
55
|
-
before do
|
|
56
|
-
@subscription = create(:subscription, target: test_target, key: 'test_subscription_key')
|
|
57
|
-
@notification = create(:notification, target: test_target, key: 'test_notification_key')
|
|
58
|
-
get_with_compatibility :index, { typed_target_param => test_target }, valid_session
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
it "returns 400 as http status code" do
|
|
62
|
-
expect(response.status).to eq(400)
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
it "returns error JSON response" do
|
|
66
|
-
assert_error_response(400)
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
context "with not found (typed_target)_id parameter" do
|
|
71
|
-
before do
|
|
72
|
-
@subscription = create(:subscription, target: test_target, key: 'test_subscription_key')
|
|
73
|
-
@notification = create(:notification, target: test_target, key: 'test_notification_key')
|
|
74
|
-
get_with_compatibility :index, target_params.merge({ typed_target_param => 0 }), valid_session
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
it "returns 404 as http status code" do
|
|
78
|
-
expect(response.status).to eq(404)
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
it "returns error JSON response" do
|
|
82
|
-
assert_error_response(404)
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
context "with filter parameter" do
|
|
87
|
-
context "with configured as filter" do
|
|
88
|
-
before do
|
|
89
|
-
@subscription = create(:subscription, target: test_target, key: 'test_subscription_key')
|
|
90
|
-
@notification = create(:notification, target: test_target, key: 'test_notification_key')
|
|
91
|
-
get_with_compatibility :index, target_params.merge({ typed_target_param => test_target, filter: 'configured' }), valid_session
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
it "returns configured subscription index as JSON" do
|
|
95
|
-
expect(response_json["configured_count"]).to eq(1)
|
|
96
|
-
assert_json_with_object_array(response_json["subscriptions"], [@subscription])
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
it "does not return unconfigured notification keys as JSON" do
|
|
100
|
-
expect(response_json['unconfigured_count']).to be_nil
|
|
101
|
-
expect(response_json['unconfigured_notification_keys']).to be_nil
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
context "with unconfigured as filter" do
|
|
106
|
-
before do
|
|
107
|
-
@subscription = create(:subscription, target: test_target, key: 'test_subscription_key')
|
|
108
|
-
@notification = create(:notification, target: test_target, key: 'test_notification_key')
|
|
109
|
-
get_with_compatibility :index, target_params.merge({ typed_target_param => test_target, filter: 'unconfigured' }), valid_session
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
it "does not return configured subscription index as JSON" do
|
|
113
|
-
expect(response_json['configured_count']).to be_nil
|
|
114
|
-
expect(response_json['subscriptions']).to be_nil
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
it "returns unconfigured notification keys as JSON" do
|
|
118
|
-
expect(response_json["unconfigured_count"]).to eq(1)
|
|
119
|
-
expect(response_json['unconfigured_notification_keys']).to eq([@notification.key])
|
|
120
|
-
end
|
|
121
|
-
end
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
context "with limit parameter" do
|
|
125
|
-
before do
|
|
126
|
-
create(:subscription, target: test_target, key: 'test_subscription_key_1')
|
|
127
|
-
create(:subscription, target: test_target, key: 'test_subscription_key_2')
|
|
128
|
-
create(:notification, target: test_target, key: 'test_notification_key_1')
|
|
129
|
-
create(:notification, target: test_target, key: 'test_notification_key_2')
|
|
130
|
-
end
|
|
131
|
-
context "with 2 as limit" do
|
|
132
|
-
before do
|
|
133
|
-
get_with_compatibility :index, target_params.merge({ typed_target_param => test_target, limit: 2 }), valid_session
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
it "returns subscription index of size 2 as JSON" do
|
|
137
|
-
assert_json_with_array_size(response_json["subscriptions"], 2)
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
it "returns notification key index of size 2 as JSON" do
|
|
141
|
-
assert_json_with_array_size(response_json["unconfigured_notification_keys"], 2)
|
|
142
|
-
end
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
context "with 1 as limit" do
|
|
146
|
-
before do
|
|
147
|
-
get_with_compatibility :index, target_params.merge({ typed_target_param => test_target, limit: 1 }), valid_session
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
it "returns subscription index of size 1 as JSON" do
|
|
151
|
-
assert_json_with_array_size(response_json["subscriptions"], 1)
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
it "returns notification key index of size 1 as JSON" do
|
|
155
|
-
assert_json_with_array_size(response_json["unconfigured_notification_keys"], 1)
|
|
156
|
-
end
|
|
157
|
-
end
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
context "with options filter parameters" do
|
|
161
|
-
before do
|
|
162
|
-
@subscription1 = create(:subscription, target: test_target, key: 'test_subscription_key_1')
|
|
163
|
-
@subscription2 = create(:subscription, target: test_target, key: 'test_subscription_key_2')
|
|
164
|
-
@notification1 = create(:notification, target: test_target, key: 'test_notification_key_1')
|
|
165
|
-
@notification2 = create(:notification, target: test_target, key: 'test_notification_key_2')
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
context 'with filtered_by_key parameter' do
|
|
169
|
-
it "returns filtered subscriptions only" do
|
|
170
|
-
get_with_compatibility :index, target_params.merge({ typed_target_param => test_target, filtered_by_key: 'test_subscription_key_2' }), valid_session
|
|
171
|
-
assert_json_with_object_array(response_json["subscriptions"], [@subscription2])
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
it "returns filtered notification keys only" do
|
|
175
|
-
get_with_compatibility :index, target_params.merge({ typed_target_param => test_target, filtered_by_key: 'test_notification_key_2' }), valid_session
|
|
176
|
-
expect(response_json['unconfigured_notification_keys']).to eq([@notification2.key])
|
|
177
|
-
end
|
|
178
|
-
end
|
|
179
|
-
end
|
|
180
|
-
end
|
|
181
|
-
|
|
182
|
-
describe "POST #create" do
|
|
183
|
-
before do
|
|
184
|
-
expect(test_target.subscriptions.size).to eq(0)
|
|
185
|
-
end
|
|
186
|
-
|
|
187
|
-
context "http POST request without optional targets" do
|
|
188
|
-
before do
|
|
189
|
-
post_with_compatibility :create, target_params.merge({
|
|
190
|
-
typed_target_param => test_target,
|
|
191
|
-
"subscription" => { "key" => "new_subscription_key",
|
|
192
|
-
"subscribing"=> "true",
|
|
193
|
-
"subscribing_to_email"=>"true"
|
|
194
|
-
}
|
|
195
|
-
}), valid_session
|
|
196
|
-
end
|
|
197
|
-
|
|
198
|
-
it "returns 201 as http status code" do
|
|
199
|
-
expect(response.status).to eq(201)
|
|
200
|
-
end
|
|
201
|
-
|
|
202
|
-
it "creates new subscription of the target" do
|
|
203
|
-
expect(test_target.subscriptions.reload.size).to eq(1)
|
|
204
|
-
expect(test_target.subscriptions.reload.first.key).to eq("new_subscription_key")
|
|
205
|
-
end
|
|
206
|
-
|
|
207
|
-
it "returns created subscription" do
|
|
208
|
-
created_subscription = test_target.subscriptions.reload.first
|
|
209
|
-
assert_json_with_object(response_json, created_subscription)
|
|
210
|
-
end
|
|
211
|
-
end
|
|
212
|
-
|
|
213
|
-
context "http POST request with optional targets" do
|
|
214
|
-
before do
|
|
215
|
-
post_with_compatibility :create, target_params.merge({
|
|
216
|
-
typed_target_param => test_target,
|
|
217
|
-
"subscription" => { "key" => "new_subscription_key",
|
|
218
|
-
"subscribing"=> "true",
|
|
219
|
-
"subscribing_to_email"=>"true",
|
|
220
|
-
"optional_targets" => { "subscribing_to_base1" => "true", "subscribing_to_base2" => "false" }
|
|
221
|
-
}
|
|
222
|
-
}), valid_session
|
|
223
|
-
end
|
|
224
|
-
|
|
225
|
-
it "returns 201 as http status code" do
|
|
226
|
-
expect(response.status).to eq(201)
|
|
227
|
-
end
|
|
228
|
-
|
|
229
|
-
it "creates new subscription of the target" do
|
|
230
|
-
expect(test_target.subscriptions.reload.size).to eq(1)
|
|
231
|
-
created_subscription = test_target.subscriptions.reload.first
|
|
232
|
-
expect(created_subscription.key).to eq("new_subscription_key")
|
|
233
|
-
expect(created_subscription.subscribing_to_optional_target?("base1")).to be_truthy
|
|
234
|
-
expect(created_subscription.subscribing_to_optional_target?("base2")).to be_falsey
|
|
235
|
-
end
|
|
236
|
-
|
|
237
|
-
it "returns created subscription" do
|
|
238
|
-
created_subscription = test_target.subscriptions.reload.first
|
|
239
|
-
assert_json_with_object(response_json, created_subscription)
|
|
240
|
-
end
|
|
241
|
-
end
|
|
242
|
-
|
|
243
|
-
context "without subscription parameter" do
|
|
244
|
-
before do
|
|
245
|
-
put_with_compatibility :create, target_params.merge({
|
|
246
|
-
typed_target_param => test_target
|
|
247
|
-
}), valid_session
|
|
248
|
-
end
|
|
249
|
-
|
|
250
|
-
it "returns 400 as http status code" do
|
|
251
|
-
expect(response.status).to eq(400)
|
|
252
|
-
end
|
|
253
|
-
|
|
254
|
-
it "returns error JSON response" do
|
|
255
|
-
assert_error_response(400)
|
|
256
|
-
end
|
|
257
|
-
end
|
|
258
|
-
|
|
259
|
-
context "unprocessable entity because of duplicate key" do
|
|
260
|
-
before do
|
|
261
|
-
@duplicate_subscription = create(:subscription, target: test_target, key: 'duplicate_subscription_key')
|
|
262
|
-
put_with_compatibility :create, target_params.merge({
|
|
263
|
-
typed_target_param => test_target,
|
|
264
|
-
"subscription" => { "key" => "duplicate_subscription_key",
|
|
265
|
-
"subscribing"=> "true",
|
|
266
|
-
"subscribing_to_email"=>"true"
|
|
267
|
-
}
|
|
268
|
-
}), valid_session
|
|
269
|
-
end
|
|
270
|
-
|
|
271
|
-
it "returns 422 as http status code" do
|
|
272
|
-
expect(response.status).to eq(422)
|
|
273
|
-
end
|
|
274
|
-
|
|
275
|
-
it "returns error JSON response" do
|
|
276
|
-
assert_error_response(422)
|
|
277
|
-
end
|
|
278
|
-
end
|
|
279
|
-
end
|
|
280
|
-
|
|
281
|
-
describe "GET #find" do
|
|
282
|
-
context "with key, target_type and (typed_target)_id parameters" do
|
|
283
|
-
before do
|
|
284
|
-
@subscription = create(:subscription, target: test_target, key: 'test_subscription_key')
|
|
285
|
-
get_with_compatibility :find, target_params.merge({ key: 'test_subscription_key', typed_target_param => test_target }), valid_session
|
|
286
|
-
end
|
|
287
|
-
|
|
288
|
-
it "returns 200 as http status code" do
|
|
289
|
-
expect(response.status).to eq(200)
|
|
290
|
-
end
|
|
291
|
-
|
|
292
|
-
it "returns the requested subscription as JSON" do
|
|
293
|
-
assert_json_with_object(response_json, @subscription)
|
|
294
|
-
end
|
|
295
|
-
end
|
|
296
|
-
|
|
297
|
-
context "with wrong id and (typed_target)_id parameters" do
|
|
298
|
-
before do
|
|
299
|
-
@subscription = create(:subscription, target: create(:user))
|
|
300
|
-
get_with_compatibility :find, target_params.merge({ key: 'test_subscription_key', typed_target_param => test_target }), valid_session
|
|
301
|
-
end
|
|
302
|
-
|
|
303
|
-
it "returns 404 as http status code" do
|
|
304
|
-
expect(response.status).to eq(404)
|
|
305
|
-
end
|
|
306
|
-
|
|
307
|
-
it "returns error JSON response" do
|
|
308
|
-
assert_error_response(404)
|
|
309
|
-
end
|
|
310
|
-
end
|
|
311
|
-
end
|
|
312
|
-
|
|
313
|
-
describe "GET #optional_target_names" do
|
|
314
|
-
context "with key, target_type and (typed_target)_id parameters" do
|
|
315
|
-
before do
|
|
316
|
-
@notification = create(:notification, target: test_target, key: 'test_subscription_key')
|
|
317
|
-
@subscription = create(:subscription, target: test_target, key: 'test_subscription_key')
|
|
318
|
-
get_with_compatibility :optional_target_names, target_params.merge({ key: 'test_subscription_key', typed_target_param => test_target }), valid_session
|
|
319
|
-
end
|
|
320
|
-
|
|
321
|
-
it "returns 200 as http status code" do
|
|
322
|
-
expect(response.status).to eq(200)
|
|
323
|
-
end
|
|
324
|
-
|
|
325
|
-
it "returns the blank array since configurured optional targets are not configured" do
|
|
326
|
-
expect(JSON.parse(response.body)["optional_target_names"].is_a?(Array)).to be_truthy
|
|
327
|
-
end
|
|
328
|
-
end
|
|
329
|
-
|
|
330
|
-
context "with wrong id and (typed_target)_id parameters" do
|
|
331
|
-
before do
|
|
332
|
-
@subscription = create(:subscription, target: create(:user))
|
|
333
|
-
get_with_compatibility :find, target_params.merge({ key: 'test_subscription_key', typed_target_param => test_target }), valid_session
|
|
334
|
-
end
|
|
335
|
-
|
|
336
|
-
it "returns 404 as http status code" do
|
|
337
|
-
expect(response.status).to eq(404)
|
|
338
|
-
end
|
|
339
|
-
|
|
340
|
-
it "returns error JSON response" do
|
|
341
|
-
assert_error_response(404)
|
|
342
|
-
end
|
|
343
|
-
end
|
|
344
|
-
end
|
|
345
|
-
|
|
346
|
-
describe "GET #show" do
|
|
347
|
-
context "with id, target_type and (typed_target)_id parameters" do
|
|
348
|
-
before do
|
|
349
|
-
@subscription = create(:subscription, target: test_target, key: 'test_subscription_key')
|
|
350
|
-
get_with_compatibility :show, target_params.merge({ id: @subscription, typed_target_param => test_target }), valid_session
|
|
351
|
-
end
|
|
352
|
-
|
|
353
|
-
it "returns 200 as http status code" do
|
|
354
|
-
expect(response.status).to eq(200)
|
|
355
|
-
end
|
|
356
|
-
|
|
357
|
-
it "returns the requested subscription as JSON" do
|
|
358
|
-
assert_json_with_object(response_json, @subscription)
|
|
359
|
-
end
|
|
360
|
-
end
|
|
361
|
-
|
|
362
|
-
context "with wrong id and (typed_target)_id parameters" do
|
|
363
|
-
before do
|
|
364
|
-
@subscription = create(:subscription, target: create(:user))
|
|
365
|
-
get_with_compatibility :show, target_params.merge({ id: @subscription, typed_target_param => test_target }), valid_session
|
|
366
|
-
end
|
|
367
|
-
|
|
368
|
-
it "returns 403 as http status code" do
|
|
369
|
-
expect(response.status).to eq(403)
|
|
370
|
-
end
|
|
371
|
-
|
|
372
|
-
it "returns error JSON response" do
|
|
373
|
-
assert_error_response(403)
|
|
374
|
-
end
|
|
375
|
-
end
|
|
376
|
-
end
|
|
377
|
-
|
|
378
|
-
describe "DELETE #destroy" do
|
|
379
|
-
context "http DELETE request" do
|
|
380
|
-
before do
|
|
381
|
-
@subscription = create(:subscription, target: test_target, key: 'test_subscription_key')
|
|
382
|
-
delete_with_compatibility :destroy, target_params.merge({ id: @subscription, typed_target_param => test_target }), valid_session
|
|
383
|
-
end
|
|
384
|
-
|
|
385
|
-
it "returns 204 as http status code" do
|
|
386
|
-
expect(response.status).to eq(204)
|
|
387
|
-
end
|
|
388
|
-
|
|
389
|
-
it "deletes the subscription" do
|
|
390
|
-
expect(test_target.subscriptions.where(id: @subscription.id).exists?).to be_falsey
|
|
391
|
-
end
|
|
392
|
-
end
|
|
393
|
-
end
|
|
394
|
-
|
|
395
|
-
describe "PUT #subscribe" do
|
|
396
|
-
context "http PUT request" do
|
|
397
|
-
before do
|
|
398
|
-
@subscription = create(:subscription, target: test_target, key: 'test_subscription_key')
|
|
399
|
-
@subscription.unsubscribe
|
|
400
|
-
expect(@subscription.subscribing?).to be_falsey
|
|
401
|
-
put_with_compatibility :subscribe, target_params.merge({ id: @subscription, typed_target_param => test_target }), valid_session
|
|
402
|
-
end
|
|
403
|
-
|
|
404
|
-
it "returns 200 as http status code" do
|
|
405
|
-
expect(response.status).to eq(200)
|
|
406
|
-
end
|
|
407
|
-
|
|
408
|
-
it "updates subscribing to true" do
|
|
409
|
-
expect(@subscription.reload.subscribing?).to be_truthy
|
|
410
|
-
end
|
|
411
|
-
|
|
412
|
-
it "returns JSON response" do
|
|
413
|
-
assert_json_with_object(response_json, @subscription)
|
|
414
|
-
end
|
|
415
|
-
end
|
|
416
|
-
end
|
|
417
|
-
|
|
418
|
-
describe "PUT #unsubscribe" do
|
|
419
|
-
context "http PUT request" do
|
|
420
|
-
before do
|
|
421
|
-
@subscription = create(:subscription, target: test_target, key: 'test_subscription_key')
|
|
422
|
-
expect(@subscription.subscribing?).to be_truthy
|
|
423
|
-
put_with_compatibility :unsubscribe, target_params.merge({ id: @subscription, typed_target_param => test_target }), valid_session
|
|
424
|
-
end
|
|
425
|
-
|
|
426
|
-
it "returns 200 as http status code" do
|
|
427
|
-
expect(response.status).to eq(200)
|
|
428
|
-
end
|
|
429
|
-
|
|
430
|
-
it "updates subscribing to false" do
|
|
431
|
-
expect(@subscription.reload.subscribing?).to be_falsey
|
|
432
|
-
end
|
|
433
|
-
|
|
434
|
-
it "returns JSON response" do
|
|
435
|
-
assert_json_with_object(response_json, @subscription)
|
|
436
|
-
end
|
|
437
|
-
end
|
|
438
|
-
end
|
|
439
|
-
|
|
440
|
-
describe "PUT #subscribe_to_email" do
|
|
441
|
-
context "http PUT request" do
|
|
442
|
-
before do
|
|
443
|
-
@subscription = create(:subscription, target: test_target, key: 'test_subscription_key')
|
|
444
|
-
@subscription.unsubscribe_to_email
|
|
445
|
-
expect(@subscription.subscribing_to_email?).to be_falsey
|
|
446
|
-
put_with_compatibility :subscribe_to_email, target_params.merge({ id: @subscription, typed_target_param => test_target }), valid_session
|
|
447
|
-
end
|
|
448
|
-
|
|
449
|
-
it "returns 200 as http status code" do
|
|
450
|
-
expect(response.status).to eq(200)
|
|
451
|
-
end
|
|
452
|
-
|
|
453
|
-
it "updates subscribing_to_email to true" do
|
|
454
|
-
expect(@subscription.reload.subscribing_to_email?).to be_truthy
|
|
455
|
-
end
|
|
456
|
-
|
|
457
|
-
it "returns JSON response" do
|
|
458
|
-
assert_json_with_object(response_json, @subscription)
|
|
459
|
-
end
|
|
460
|
-
end
|
|
461
|
-
|
|
462
|
-
context "with unsubscribed target" do
|
|
463
|
-
before do
|
|
464
|
-
@subscription = create(:subscription, target: test_target, key: 'test_subscription_key')
|
|
465
|
-
@subscription.unsubscribe
|
|
466
|
-
expect(@subscription.subscribing?).to be_falsey
|
|
467
|
-
expect(@subscription.subscribing_to_email?).to be_falsey
|
|
468
|
-
put_with_compatibility :subscribe_to_email, target_params.merge({ id: @subscription, typed_target_param => test_target }), valid_session
|
|
469
|
-
end
|
|
470
|
-
|
|
471
|
-
it "returns 422 as http status code" do
|
|
472
|
-
expect(response.status).to eq(422)
|
|
473
|
-
end
|
|
474
|
-
|
|
475
|
-
it "cannot update subscribing_to_email to true" do
|
|
476
|
-
expect(@subscription.reload.subscribing_to_email?).to be_falsey
|
|
477
|
-
end
|
|
478
|
-
|
|
479
|
-
it "returns error JSON response" do
|
|
480
|
-
assert_error_response(422)
|
|
481
|
-
end
|
|
482
|
-
end
|
|
483
|
-
end
|
|
484
|
-
|
|
485
|
-
describe "PUT #unsubscribe_to_email" do
|
|
486
|
-
context "http PUT request" do
|
|
487
|
-
before do
|
|
488
|
-
@subscription = create(:subscription, target: test_target, key: 'test_subscription_key')
|
|
489
|
-
expect(@subscription.subscribing_to_email?).to be_truthy
|
|
490
|
-
put_with_compatibility :unsubscribe_to_email, target_params.merge({ id: @subscription, typed_target_param => test_target }), valid_session
|
|
491
|
-
end
|
|
492
|
-
|
|
493
|
-
it "returns 200 as http status code" do
|
|
494
|
-
expect(response.status).to eq(200)
|
|
495
|
-
end
|
|
496
|
-
|
|
497
|
-
it "updates subscribing_to_email to false" do
|
|
498
|
-
expect(@subscription.reload.subscribing_to_email?).to be_falsey
|
|
499
|
-
end
|
|
500
|
-
|
|
501
|
-
it "returns JSON response" do
|
|
502
|
-
assert_json_with_object(response_json, @subscription)
|
|
503
|
-
end
|
|
504
|
-
end
|
|
505
|
-
end
|
|
506
|
-
|
|
507
|
-
describe "PUT #subscribe_to_optional_target" do
|
|
508
|
-
context "without optional_target_name param" do
|
|
509
|
-
before do
|
|
510
|
-
@subscription = create(:subscription, target: test_target, key: 'test_subscription_key')
|
|
511
|
-
@subscription.unsubscribe_to_optional_target(:base)
|
|
512
|
-
expect(@subscription.subscribing_to_optional_target?(:base)).to be_falsey
|
|
513
|
-
put_with_compatibility :subscribe_to_optional_target, target_params.merge({ id: @subscription, typed_target_param => test_target }), valid_session
|
|
514
|
-
end
|
|
515
|
-
|
|
516
|
-
it "returns 400 as http status code" do
|
|
517
|
-
expect(response.status).to eq(400)
|
|
518
|
-
end
|
|
519
|
-
|
|
520
|
-
it "does not update subscribing_to_optional_target?" do
|
|
521
|
-
expect(@subscription.subscribing_to_optional_target?(:base)).to be_falsey
|
|
522
|
-
end
|
|
523
|
-
|
|
524
|
-
it "returns error JSON response" do
|
|
525
|
-
assert_error_response(400)
|
|
526
|
-
end
|
|
527
|
-
end
|
|
528
|
-
|
|
529
|
-
context "http PUT request" do
|
|
530
|
-
before do
|
|
531
|
-
@subscription = create(:subscription, target: test_target, key: 'test_subscription_key')
|
|
532
|
-
@subscription.unsubscribe_to_optional_target(:base)
|
|
533
|
-
expect(@subscription.subscribing_to_optional_target?(:base)).to be_falsey
|
|
534
|
-
put_with_compatibility :subscribe_to_optional_target, target_params.merge({ id: @subscription, optional_target_name: 'base', typed_target_param => test_target }), valid_session
|
|
535
|
-
end
|
|
536
|
-
|
|
537
|
-
it "returns 200 as http status code" do
|
|
538
|
-
expect(response.status).to eq(200)
|
|
539
|
-
end
|
|
540
|
-
|
|
541
|
-
it "updates subscribing_to_optional_target to true" do
|
|
542
|
-
expect(@subscription.reload.subscribing_to_optional_target?(:base)).to be_truthy
|
|
543
|
-
end
|
|
544
|
-
|
|
545
|
-
it "returns JSON response" do
|
|
546
|
-
assert_json_with_object(response_json, @subscription)
|
|
547
|
-
end
|
|
548
|
-
end
|
|
549
|
-
|
|
550
|
-
context "with unsubscribed target" do
|
|
551
|
-
before do
|
|
552
|
-
@subscription = create(:subscription, target: test_target, key: 'test_subscription_key')
|
|
553
|
-
@subscription.unsubscribe_to_optional_target(:base)
|
|
554
|
-
@subscription.unsubscribe
|
|
555
|
-
expect(@subscription.subscribing?).to be_falsey
|
|
556
|
-
expect(@subscription.subscribing_to_optional_target?(:base)).to be_falsey
|
|
557
|
-
put_with_compatibility :subscribe_to_optional_target, target_params.merge({ id: @subscription, optional_target_name: 'base', typed_target_param => test_target }), valid_session
|
|
558
|
-
end
|
|
559
|
-
|
|
560
|
-
it "returns 422 as http status code" do
|
|
561
|
-
expect(response.status).to eq(422)
|
|
562
|
-
end
|
|
563
|
-
|
|
564
|
-
it "cannot update subscribing_to_optional_target to true" do
|
|
565
|
-
expect(@subscription.reload.subscribing_to_optional_target?(:base)).to be_falsey
|
|
566
|
-
end
|
|
567
|
-
|
|
568
|
-
it "returns error JSON response" do
|
|
569
|
-
assert_error_response(422)
|
|
570
|
-
end
|
|
571
|
-
end
|
|
572
|
-
end
|
|
573
|
-
|
|
574
|
-
describe "PUT #unsubscribe_to_optional_target" do
|
|
575
|
-
context "without optional_target_name param" do
|
|
576
|
-
before do
|
|
577
|
-
@subscription = create(:subscription, target: test_target, key: 'test_subscription_key')
|
|
578
|
-
expect(@subscription.subscribing_to_optional_target?(:base)).to be_truthy
|
|
579
|
-
put_with_compatibility :unsubscribe_to_optional_target, target_params.merge({ id: @subscription, typed_target_param => test_target }), valid_session
|
|
580
|
-
end
|
|
581
|
-
|
|
582
|
-
it "returns 400 as http status code" do
|
|
583
|
-
expect(response.status).to eq(400)
|
|
584
|
-
end
|
|
585
|
-
|
|
586
|
-
it "does not update subscribing_to_optional_target?" do
|
|
587
|
-
expect(@subscription.subscribing_to_optional_target?(:base)).to be_truthy
|
|
588
|
-
end
|
|
589
|
-
|
|
590
|
-
it "returns error JSON response" do
|
|
591
|
-
assert_error_response(400)
|
|
592
|
-
end
|
|
593
|
-
end
|
|
594
|
-
|
|
595
|
-
context "http PUT request" do
|
|
596
|
-
before do
|
|
597
|
-
@subscription = create(:subscription, target: test_target, key: 'test_subscription_key')
|
|
598
|
-
expect(@subscription.subscribing_to_optional_target?(:base)).to be_truthy
|
|
599
|
-
put_with_compatibility :unsubscribe_to_optional_target, target_params.merge({ id: @subscription, optional_target_name: 'base', typed_target_param => test_target }), valid_session
|
|
600
|
-
end
|
|
601
|
-
|
|
602
|
-
it "returns 200 as http status code" do
|
|
603
|
-
expect(response.status).to eq(200)
|
|
604
|
-
end
|
|
605
|
-
|
|
606
|
-
it "updates subscribing_to_optional_target to false" do
|
|
607
|
-
expect(@subscription.reload.subscribing_to_optional_target?(:base)).to be_falsey
|
|
608
|
-
end
|
|
609
|
-
|
|
610
|
-
it "returns JSON response" do
|
|
611
|
-
assert_json_with_object(response_json, @subscription)
|
|
612
|
-
end
|
|
613
|
-
end
|
|
614
|
-
end
|
|
615
|
-
end
|
|
616
|
-
|
|
617
|
-
shared_examples_for :subscriptions_api_request do
|
|
618
|
-
include ActivityNotification::ControllerSpec::CommitteeUtility
|
|
619
|
-
|
|
620
|
-
before do
|
|
621
|
-
@notification = create(:notification, target: test_target, key: "unconfigured_key")
|
|
622
|
-
@subscription = create(:subscription, target: test_target, key: "configured_key")
|
|
623
|
-
end
|
|
624
|
-
|
|
625
|
-
describe "GET /apidocs to test" do
|
|
626
|
-
it "returns API references as OpenAPI Specification JSON schema" do
|
|
627
|
-
get "#{root_path}/apidocs"
|
|
628
|
-
write_schema_file(response.body)
|
|
629
|
-
expect(read_schema_file["openapi"]).to eq("3.0.0")
|
|
630
|
-
end
|
|
631
|
-
end
|
|
632
|
-
|
|
633
|
-
describe "GET /{target_type}/{target_id}/subscriptions", type: :request do
|
|
634
|
-
it "returns response as API references" do
|
|
635
|
-
get_with_compatibility "#{api_path}/subscriptions", headers: @headers
|
|
636
|
-
assert_all_schema_confirm(response, 200)
|
|
637
|
-
end
|
|
638
|
-
end
|
|
639
|
-
|
|
640
|
-
describe "POST /{target_type}/{target_id}/subscriptions", type: :request do
|
|
641
|
-
it "returns response as API references" do
|
|
642
|
-
post_with_compatibility "#{api_path}/subscriptions", params: {
|
|
643
|
-
"subscription" => { "key" => "new_subscription_key",
|
|
644
|
-
"subscribing"=> "true",
|
|
645
|
-
"subscribing_to_email"=>"true",
|
|
646
|
-
"optional_targets"=>{
|
|
647
|
-
"action_cable_channel"=>{
|
|
648
|
-
"subscribing"=>"true",
|
|
649
|
-
},
|
|
650
|
-
"slack"=>{
|
|
651
|
-
"subscribing"=>"false"
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
}, headers: @headers
|
|
656
|
-
assert_all_schema_confirm(response, 201)
|
|
657
|
-
end
|
|
658
|
-
|
|
659
|
-
it "returns response as API references when the key is duplicate" do
|
|
660
|
-
post_with_compatibility "#{api_path}/subscriptions", params: {
|
|
661
|
-
"subscription" => { "key" => "configured_key",
|
|
662
|
-
"subscribing"=> "true",
|
|
663
|
-
"subscribing_to_email"=>"true"
|
|
664
|
-
}
|
|
665
|
-
}, headers: @headers
|
|
666
|
-
assert_all_schema_confirm(response, 422)
|
|
667
|
-
end
|
|
668
|
-
end
|
|
669
|
-
|
|
670
|
-
describe "GET /{target_type}/{target_id}/subscriptions/find", type: :request do
|
|
671
|
-
it "returns response as API references" do
|
|
672
|
-
get_with_compatibility "#{api_path}/subscriptions/find?key=#{@subscription.key}", headers: @headers
|
|
673
|
-
assert_all_schema_confirm(response, 200)
|
|
674
|
-
end
|
|
675
|
-
end
|
|
676
|
-
|
|
677
|
-
describe "GET /{target_type}/{target_id}/subscriptions/optional_target_names", type: :request do
|
|
678
|
-
it "returns response as API references" do
|
|
679
|
-
create(:notification, target: test_target, key: @subscription.key)
|
|
680
|
-
get_with_compatibility "#{api_path}/subscriptions/optional_target_names?key=#{@subscription.key}", headers: @headers
|
|
681
|
-
assert_all_schema_confirm(response, 200)
|
|
682
|
-
end
|
|
683
|
-
|
|
684
|
-
it "returns response as API references when any notification with the key is not found" do
|
|
685
|
-
get_with_compatibility "#{api_path}/subscriptions/optional_target_names?key=#{@subscription.key}", headers: @headers
|
|
686
|
-
assert_all_schema_confirm(response, 404)
|
|
687
|
-
end
|
|
688
|
-
end
|
|
689
|
-
|
|
690
|
-
describe "GET /{target_type}/{target_id}/subscriptions/{id}", type: :request do
|
|
691
|
-
it "returns response as API references" do
|
|
692
|
-
get_with_compatibility "#{api_path}/subscriptions/#{@subscription.id}", headers: @headers
|
|
693
|
-
assert_all_schema_confirm(response, 200)
|
|
694
|
-
end
|
|
695
|
-
|
|
696
|
-
it "returns error response as API references" do
|
|
697
|
-
get_with_compatibility "#{api_path}/subscriptions/0", headers: @headers
|
|
698
|
-
assert_all_schema_confirm(response, 404)
|
|
699
|
-
end
|
|
700
|
-
end
|
|
701
|
-
|
|
702
|
-
describe "DELETE /{target_type}/{target_id}/subscriptions/{id}", type: :request do
|
|
703
|
-
it "returns response as API references" do
|
|
704
|
-
delete_with_compatibility "#{api_path}/subscriptions/#{@subscription.id}", headers: @headers
|
|
705
|
-
assert_all_schema_confirm(response, 204)
|
|
706
|
-
end
|
|
707
|
-
end
|
|
708
|
-
|
|
709
|
-
describe "PUT /{target_type}/{target_id}/subscriptions/{id}/subscribe", type: :request do
|
|
710
|
-
it "returns response as API references" do
|
|
711
|
-
put_with_compatibility "#{api_path}/subscriptions/#{@subscription.id}/subscribe", headers: @headers
|
|
712
|
-
assert_all_schema_confirm(response, 200)
|
|
713
|
-
end
|
|
714
|
-
end
|
|
715
|
-
|
|
716
|
-
describe "PUT /{target_type}/{target_id}/subscriptions/{id}/unsubscribe", type: :request do
|
|
717
|
-
it "returns response as API references" do
|
|
718
|
-
put_with_compatibility "#{api_path}/subscriptions/#{@subscription.id}/unsubscribe", headers: @headers
|
|
719
|
-
assert_all_schema_confirm(response, 200)
|
|
720
|
-
end
|
|
721
|
-
end
|
|
722
|
-
|
|
723
|
-
describe "PUT /{target_type}/{target_id}/subscriptions/{id}/subscribe_to_email", type: :request do
|
|
724
|
-
it "returns response as API references" do
|
|
725
|
-
put_with_compatibility "#{api_path}/subscriptions/#{@subscription.id}/subscribe_to_email", headers: @headers
|
|
726
|
-
assert_all_schema_confirm(response, 200)
|
|
727
|
-
end
|
|
728
|
-
end
|
|
729
|
-
|
|
730
|
-
describe "PUT /{target_type}/{target_id}/subscriptions/{id}/unsubscribe_to_email", type: :request do
|
|
731
|
-
it "returns response as API references" do
|
|
732
|
-
put_with_compatibility "#{api_path}/subscriptions/#{@subscription.id}/unsubscribe_to_email", headers: @headers
|
|
733
|
-
assert_all_schema_confirm(response, 200)
|
|
734
|
-
end
|
|
735
|
-
end
|
|
736
|
-
|
|
737
|
-
describe "PUT /{target_type}/{target_id}/subscriptions/{id}/subscribe_to_optional_target", type: :request do
|
|
738
|
-
it "returns response as API references" do
|
|
739
|
-
put_with_compatibility "#{api_path}/subscriptions/#{@subscription.id}/subscribe_to_optional_target?optional_target_name=slack", headers: @headers
|
|
740
|
-
assert_all_schema_confirm(response, 200)
|
|
741
|
-
end
|
|
742
|
-
end
|
|
743
|
-
|
|
744
|
-
describe "PUT /{target_type}/{target_id}/subscriptions/{id}/unsubscribe_to_optional_target", type: :request do
|
|
745
|
-
it "returns response as API references" do
|
|
746
|
-
put_with_compatibility "#{api_path}/subscriptions/#{@subscription.id}/unsubscribe_to_optional_target?optional_target_name=slack", headers: @headers
|
|
747
|
-
assert_all_schema_confirm(response, 200)
|
|
748
|
-
end
|
|
749
|
-
end
|
|
750
|
-
end
|