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