activity_notification 2.0.0 → 2.1.4
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/.github/ISSUE_TEMPLATE/bug_report.md +22 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +17 -0
- data/.github/pull_request_template.md +13 -0
- data/.gitignore +10 -3
- data/.travis.yml +6 -5
- data/CHANGELOG.md +60 -0
- data/Gemfile +8 -3
- data/Procfile +1 -1
- data/README.md +153 -1510
- data/activity_notification.gemspec +4 -1
- data/app/channels/activity_notification/notification_api_channel.rb +12 -0
- data/app/channels/activity_notification/notification_api_with_devise_channel.rb +46 -0
- data/app/channels/activity_notification/notification_channel.rb +2 -2
- data/app/channels/activity_notification/notification_with_devise_channel.rb +2 -2
- data/app/controllers/activity_notification/apidocs_controller.rb +75 -0
- data/app/controllers/activity_notification/notifications_api_controller.rb +143 -0
- data/app/controllers/activity_notification/notifications_api_with_devise_controller.rb +7 -0
- data/app/controllers/activity_notification/notifications_controller.rb +79 -53
- data/app/controllers/activity_notification/subscriptions_api_controller.rb +197 -0
- data/app/controllers/activity_notification/subscriptions_api_with_devise_controller.rb +7 -0
- data/app/controllers/activity_notification/subscriptions_controller.rb +78 -69
- data/app/views/activity_notification/notifications/default/_default.html.erb +18 -18
- data/app/views/activity_notification/notifications/default/_default_without_grouping.html.erb +14 -14
- data/app/views/activity_notification/notifications/default/index.html.erb +6 -6
- data/app/views/activity_notification/optional_targets/default/action_cable_channel/_default.html.erb +176 -0
- data/app/views/activity_notification/subscriptions/default/_form.html.erb +1 -1
- data/app/views/activity_notification/subscriptions/default/_notification_keys.html.erb +3 -31
- data/app/views/activity_notification/subscriptions/default/_subscription.html.erb +7 -7
- data/app/views/activity_notification/subscriptions/default/index.html.erb +11 -7
- data/bin/deploy_on_heroku.sh +3 -1
- data/docs/CODE_OF_CONDUCT.md +76 -0
- data/docs/CONTRIBUTING.md +36 -0
- data/docs/Functions.md +1130 -0
- data/docs/Setup.md +801 -0
- data/docs/Testing.md +148 -0
- data/gemfiles/Gemfile.rails-4.2 +5 -1
- data/gemfiles/Gemfile.rails-5.0 +6 -1
- data/gemfiles/Gemfile.rails-5.1 +6 -1
- data/gemfiles/Gemfile.rails-5.2 +6 -1
- data/gemfiles/{Gemfile.rails-6.0.rc → Gemfile.rails-6.0} +6 -5
- data/lib/activity_notification.rb +13 -0
- data/lib/activity_notification/apis/notification_api.rb +37 -93
- data/lib/activity_notification/apis/subscription_api.rb +20 -8
- data/lib/activity_notification/apis/swagger.rb +6 -0
- data/lib/activity_notification/common.rb +4 -1
- data/lib/activity_notification/config.rb +41 -21
- data/lib/activity_notification/controllers/common_api_controller.rb +30 -0
- data/lib/activity_notification/controllers/common_controller.rb +45 -21
- data/lib/activity_notification/controllers/concerns/swagger/error_responses.rb +55 -0
- data/lib/activity_notification/controllers/concerns/swagger/notifications_api.rb +273 -0
- data/lib/activity_notification/controllers/concerns/swagger/notifications_parameters.rb +92 -0
- data/lib/activity_notification/controllers/concerns/swagger/subscriptions_api.rb +405 -0
- data/lib/activity_notification/controllers/concerns/swagger/subscriptions_parameters.rb +50 -0
- data/lib/activity_notification/controllers/devise_authentication_controller.rb +7 -6
- data/lib/activity_notification/gem_version.rb +14 -0
- data/lib/activity_notification/helpers/errors.rb +2 -0
- data/lib/activity_notification/helpers/view_helpers.rb +4 -0
- data/lib/activity_notification/mailers/helpers.rb +17 -10
- data/lib/activity_notification/models/concerns/notifiable.rb +31 -15
- data/lib/activity_notification/models/concerns/subscriber.rb +12 -1
- data/lib/activity_notification/models/concerns/swagger/error_schema.rb +36 -0
- data/lib/activity_notification/models/concerns/swagger/notification_schema.rb +209 -0
- data/lib/activity_notification/models/concerns/swagger/subscription_schema.rb +162 -0
- data/lib/activity_notification/models/concerns/target.rb +36 -10
- data/lib/activity_notification/models/notification.rb +1 -0
- data/lib/activity_notification/models/subscription.rb +1 -0
- data/lib/activity_notification/optional_targets/action_cable_api_channel.rb +69 -0
- data/lib/activity_notification/optional_targets/action_cable_channel.rb +68 -0
- data/lib/activity_notification/optional_targets/base.rb +7 -13
- data/lib/activity_notification/orm/active_record/notification.rb +17 -1
- data/lib/activity_notification/orm/active_record/subscription.rb +1 -1
- data/lib/activity_notification/orm/dynamoid.rb +38 -3
- data/lib/activity_notification/orm/dynamoid/extension.rb +79 -1
- data/lib/activity_notification/orm/dynamoid/notification.rb +49 -14
- data/lib/activity_notification/orm/dynamoid/subscription.rb +2 -2
- data/lib/activity_notification/orm/mongoid.rb +32 -3
- data/lib/activity_notification/orm/mongoid/notification.rb +24 -6
- data/lib/activity_notification/orm/mongoid/subscription.rb +1 -1
- data/lib/activity_notification/rails/routes.rb +132 -48
- data/lib/activity_notification/renderable.rb +13 -2
- data/lib/activity_notification/roles/acts_as_notifiable.rb +39 -20
- data/lib/activity_notification/version.rb +1 -1
- data/lib/generators/activity_notification/controllers_generator.rb +2 -1
- data/lib/generators/templates/activity_notification.rb +8 -0
- data/lib/generators/templates/controllers/notifications_api_controller.rb +31 -0
- data/lib/generators/templates/controllers/notifications_api_with_devise_controller.rb +31 -0
- data/lib/generators/templates/controllers/notifications_controller.rb +1 -37
- data/lib/generators/templates/controllers/notifications_with_devise_controller.rb +1 -45
- data/lib/generators/templates/controllers/subscriptions_api_controller.rb +61 -0
- data/lib/generators/templates/controllers/subscriptions_api_with_devise_controller.rb +61 -0
- data/lib/generators/templates/controllers/subscriptions_controller.rb +14 -37
- data/lib/generators/templates/controllers/subscriptions_with_devise_controller.rb +14 -45
- data/lib/generators/templates/models/README +8 -4
- data/lib/generators/templates/models/notification.rb +1 -1
- data/lib/generators/templates/models/subscription.rb +1 -1
- data/package.json +8 -0
- data/spec/channels/notification_api_channel_shared_examples.rb +59 -0
- data/spec/channels/notification_api_channel_spec.rb +51 -0
- data/spec/channels/notification_api_with_devise_channel_spec.rb +78 -0
- data/spec/concerns/apis/notification_api_spec.rb +38 -3
- data/spec/concerns/models/notifiable_spec.rb +82 -18
- data/spec/concerns/models/subscriber_spec.rb +13 -16
- data/spec/concerns/models/target_spec.rb +32 -0
- data/spec/concerns/renderable_spec.rb +2 -2
- data/spec/config_spec.rb +26 -15
- data/spec/controllers/controller_spec_utility.rb +136 -0
- data/spec/controllers/notifications_api_controller_shared_examples.rb +506 -0
- data/spec/controllers/notifications_api_controller_spec.rb +19 -0
- data/spec/controllers/notifications_api_with_devise_controller_spec.rb +60 -0
- data/spec/controllers/notifications_controller_shared_examples.rb +54 -79
- data/spec/controllers/notifications_controller_spec.rb +1 -2
- data/spec/controllers/notifications_with_devise_controller_spec.rb +3 -12
- data/spec/controllers/subscriptions_api_controller_shared_examples.rb +750 -0
- data/spec/controllers/subscriptions_api_controller_spec.rb +19 -0
- data/spec/controllers/subscriptions_api_with_devise_controller_spec.rb +60 -0
- data/spec/controllers/subscriptions_controller_shared_examples.rb +94 -121
- data/spec/controllers/subscriptions_controller_spec.rb +1 -2
- data/spec/controllers/subscriptions_with_devise_controller_spec.rb +3 -12
- data/spec/helpers/view_helpers_spec.rb +4 -11
- data/spec/mailers/mailer_spec.rb +41 -0
- data/spec/models/notification_spec.rb +17 -0
- data/spec/models/subscription_spec.rb +8 -13
- data/spec/optional_targets/action_cable_api_channel_spec.rb +37 -0
- data/spec/optional_targets/action_cable_channel_spec.rb +44 -0
- data/spec/optional_targets/amazon_sns_spec.rb +0 -2
- data/spec/optional_targets/slack_spec.rb +0 -2
- data/spec/rails_app/Rakefile +9 -0
- data/spec/rails_app/app/assets/config/manifest.js +3 -0
- data/spec/rails_app/app/assets/images/.keep +0 -0
- data/spec/rails_app/app/controllers/admins_controller.rb +21 -0
- data/spec/rails_app/app/controllers/application_controller.rb +1 -1
- data/spec/rails_app/app/controllers/articles_controller.rb +6 -3
- data/spec/rails_app/app/controllers/spa_controller.rb +7 -0
- data/spec/rails_app/app/controllers/users/notifications_controller.rb +0 -65
- data/spec/rails_app/app/controllers/users/notifications_with_devise_controller.rb +0 -73
- data/spec/rails_app/app/controllers/users/subscriptions_controller.rb +0 -77
- data/spec/rails_app/app/controllers/users/subscriptions_with_devise_controller.rb +0 -85
- data/spec/rails_app/app/controllers/users_controller.rb +26 -0
- data/spec/rails_app/app/javascript/App.vue +40 -0
- data/spec/rails_app/app/javascript/components/DeviseTokenAuth.vue +82 -0
- data/spec/rails_app/app/javascript/components/Top.vue +98 -0
- data/spec/rails_app/app/javascript/components/notifications/Index.vue +200 -0
- data/spec/rails_app/app/javascript/components/notifications/Notification.vue +133 -0
- data/spec/rails_app/app/javascript/components/notifications/NotificationContent.vue +122 -0
- data/spec/rails_app/app/javascript/components/subscriptions/Index.vue +279 -0
- data/spec/rails_app/app/javascript/components/subscriptions/NewSubscription.vue +112 -0
- data/spec/rails_app/app/javascript/components/subscriptions/NotificationKey.vue +141 -0
- data/spec/rails_app/app/javascript/components/subscriptions/Subscription.vue +226 -0
- data/spec/rails_app/app/javascript/config/development.js +5 -0
- data/spec/rails_app/app/javascript/config/environment.js +7 -0
- data/spec/rails_app/app/javascript/config/production.js +5 -0
- data/spec/rails_app/app/javascript/config/test.js +5 -0
- data/spec/rails_app/app/javascript/packs/application.js +18 -0
- data/spec/rails_app/app/javascript/packs/spa.js +14 -0
- data/spec/rails_app/app/javascript/router/index.js +73 -0
- data/spec/rails_app/app/javascript/store/index.js +37 -0
- data/spec/rails_app/app/models/admin.rb +16 -15
- data/spec/rails_app/app/models/article.rb +26 -21
- data/spec/rails_app/app/models/comment.rb +24 -71
- data/spec/rails_app/app/models/dummy/dummy_group.rb +8 -0
- data/spec/rails_app/app/models/dummy/dummy_notifiable_target.rb +8 -0
- data/spec/rails_app/app/models/user.rb +44 -20
- data/spec/rails_app/app/views/activity_notification/notifications/default/article/_update.html.erb +146 -0
- data/spec/rails_app/app/views/articles/index.html.erb +51 -7
- data/spec/rails_app/app/views/articles/show.html.erb +1 -1
- data/spec/rails_app/app/views/layouts/_header.html.erb +8 -10
- data/spec/rails_app/app/views/spa/index.html.erb +2 -0
- data/spec/rails_app/babel.config.js +72 -0
- data/spec/rails_app/bin/webpack +18 -0
- data/spec/rails_app/bin/webpack-dev-server +18 -0
- data/spec/rails_app/config/application.rb +18 -2
- data/spec/rails_app/config/dynamoid.rb +11 -3
- data/spec/rails_app/config/environment.rb +2 -1
- data/spec/rails_app/config/environments/development.rb +5 -0
- data/spec/rails_app/config/environments/production.rb +6 -0
- data/spec/rails_app/config/environments/test.rb +5 -0
- data/spec/rails_app/config/initializers/activity_notification.rb +11 -3
- data/spec/rails_app/config/initializers/copy_it.aws.rb.template +6 -0
- data/spec/rails_app/config/initializers/devise_token_auth.rb +55 -0
- data/spec/rails_app/config/initializers/mysql.rb +9 -0
- data/spec/rails_app/config/locales/activity_notification.en.yml +2 -2
- data/spec/rails_app/config/routes.rb +37 -1
- data/spec/rails_app/config/webpack/development.js +5 -0
- data/spec/rails_app/config/webpack/environment.js +7 -0
- data/spec/rails_app/config/webpack/loaders/vue.js +6 -0
- data/spec/rails_app/config/webpack/production.js +5 -0
- data/spec/rails_app/config/webpack/test.js +5 -0
- data/spec/rails_app/config/webpacker.yml +97 -0
- data/spec/rails_app/db/migrate/20191201000000_add_tokens_to_users.rb +10 -0
- data/spec/rails_app/db/schema.rb +4 -1
- data/spec/rails_app/db/seeds.rb +10 -2
- data/spec/rails_app/lib/custom_optional_targets/raise_error.rb +14 -0
- data/spec/rails_app/package.json +23 -0
- data/spec/rails_app/postcss.config.js +12 -0
- data/spec/roles/acts_as_group_spec.rb +0 -2
- data/spec/roles/acts_as_notifiable_spec.rb +6 -8
- data/spec/roles/acts_as_notifier_spec.rb +0 -2
- data/spec/roles/acts_as_target_spec.rb +0 -4
- data/spec/spec_helper.rb +7 -15
- data/spec/version_spec.rb +31 -0
- metadata +191 -13
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Creates DATETIME(3) column types by default which support microseconds.
|
|
2
|
+
# Without it, only regular (second precise) DATETIME columns are created.
|
|
3
|
+
if defined?(ActiveRecord)
|
|
4
|
+
module ActiveRecord::ConnectionAdapters
|
|
5
|
+
if defined?(AbstractMysqlAdapter)
|
|
6
|
+
AbstractMysqlAdapter::NATIVE_DATABASE_TYPES[:datetime][:limit] = 3
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
end
|
|
@@ -7,9 +7,9 @@ en:
|
|
|
7
7
|
create:
|
|
8
8
|
text: 'Article has been created'
|
|
9
9
|
update:
|
|
10
|
-
text: 'Article %{article_title} has been updated'
|
|
10
|
+
text: 'Article "%{article_title}" has been updated'
|
|
11
11
|
destroy:
|
|
12
|
-
text: '
|
|
12
|
+
text: 'The author removed an article "%{article_title}"'
|
|
13
13
|
comment:
|
|
14
14
|
create:
|
|
15
15
|
text: '%{notifier_name} posted a comment on the article "%{article_title}"'
|
|
@@ -1,14 +1,50 @@
|
|
|
1
1
|
Rails.application.routes.draw do
|
|
2
|
+
# Routes for example Rails application
|
|
2
3
|
root to: 'articles#index'
|
|
3
4
|
devise_for :users
|
|
4
|
-
resources :articles
|
|
5
|
+
resources :articles, except: [:destroy]
|
|
5
6
|
resources :comments, only: [:create, :destroy]
|
|
6
7
|
|
|
8
|
+
# activity_notification routes for users
|
|
7
9
|
notify_to :users, with_subscription: true
|
|
8
10
|
notify_to :users, with_devise: :users, devise_default_routes: true, with_subscription: true
|
|
9
11
|
|
|
12
|
+
# activity_notification routes for admins
|
|
10
13
|
notify_to :admins, with_devise: :users, with_subscription: true
|
|
11
14
|
scope :admins, as: :admins do
|
|
12
15
|
notify_to :admins, with_devise: :users, devise_default_routes: true, with_subscription: true, routing_scope: :admins
|
|
13
16
|
end
|
|
17
|
+
|
|
18
|
+
# Routes for single page application working with activity_notification REST API backend
|
|
19
|
+
resources :spa, only: [:index]
|
|
20
|
+
namespace :api do
|
|
21
|
+
scope :"v#{ActivityNotification::GEM_VERSION::MAJOR}" do
|
|
22
|
+
mount_devise_token_auth_for 'User', at: 'auth'
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Routes of activity_notification REST API backend for users
|
|
27
|
+
scope :api do
|
|
28
|
+
scope :"v#{ActivityNotification::GEM_VERSION::MAJOR}" do
|
|
29
|
+
notify_to :users, api_mode: true, with_subscription: true
|
|
30
|
+
notify_to :users, api_mode: true, with_devise: :users, devise_default_routes: true, with_subscription: true
|
|
31
|
+
resources :apidocs, only: [:index], controller: 'activity_notification/apidocs'
|
|
32
|
+
resources :users, only: [:index, :show] do
|
|
33
|
+
collection do
|
|
34
|
+
get :find
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Routes of activity_notification REST API backend for admins
|
|
41
|
+
scope :api do
|
|
42
|
+
scope :"v#{ActivityNotification::GEM_VERSION::MAJOR}" do
|
|
43
|
+
notify_to :admins, api_mode: true, with_devise: :users, with_subscription: true
|
|
44
|
+
scope :admins, as: :admins do
|
|
45
|
+
notify_to :admins, api_mode: true, with_devise: :users, devise_default_routes: true, with_subscription: true
|
|
46
|
+
end
|
|
47
|
+
resources :admins, only: [:index, :show]
|
|
48
|
+
end
|
|
49
|
+
end
|
|
14
50
|
end
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const { environment } = require('@rails/webpacker')
|
|
2
|
+
const { VueLoaderPlugin } = require('vue-loader')
|
|
3
|
+
const vue = require('./loaders/vue')
|
|
4
|
+
|
|
5
|
+
environment.plugins.prepend('VueLoaderPlugin', new VueLoaderPlugin())
|
|
6
|
+
environment.loaders.prepend('vue', vue)
|
|
7
|
+
module.exports = environment
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Note: You must restart bin/webpack-dev-server for changes to take effect
|
|
2
|
+
|
|
3
|
+
default: &default
|
|
4
|
+
source_path: app/javascript
|
|
5
|
+
source_entry_path: packs
|
|
6
|
+
public_root_path: public
|
|
7
|
+
public_output_path: packs
|
|
8
|
+
cache_path: tmp/cache/webpacker
|
|
9
|
+
check_yarn_integrity: false
|
|
10
|
+
webpack_compile_output: true
|
|
11
|
+
|
|
12
|
+
# Additional paths webpack should lookup modules
|
|
13
|
+
# ['app/assets', 'engine/foo/app/assets']
|
|
14
|
+
resolved_paths: []
|
|
15
|
+
|
|
16
|
+
# Reload manifest.json on all requests so we reload latest compiled packs
|
|
17
|
+
cache_manifest: false
|
|
18
|
+
|
|
19
|
+
# Extract and emit a css file
|
|
20
|
+
extract_css: false
|
|
21
|
+
|
|
22
|
+
static_assets_extensions:
|
|
23
|
+
- .jpg
|
|
24
|
+
- .jpeg
|
|
25
|
+
- .png
|
|
26
|
+
- .gif
|
|
27
|
+
- .tiff
|
|
28
|
+
- .ico
|
|
29
|
+
- .svg
|
|
30
|
+
- .eot
|
|
31
|
+
- .otf
|
|
32
|
+
- .ttf
|
|
33
|
+
- .woff
|
|
34
|
+
- .woff2
|
|
35
|
+
|
|
36
|
+
extensions:
|
|
37
|
+
- .vue
|
|
38
|
+
- .mjs
|
|
39
|
+
- .js
|
|
40
|
+
- .sass
|
|
41
|
+
- .scss
|
|
42
|
+
- .css
|
|
43
|
+
- .module.sass
|
|
44
|
+
- .module.scss
|
|
45
|
+
- .module.css
|
|
46
|
+
- .png
|
|
47
|
+
- .svg
|
|
48
|
+
- .gif
|
|
49
|
+
- .jpeg
|
|
50
|
+
- .jpg
|
|
51
|
+
|
|
52
|
+
development:
|
|
53
|
+
<<: *default
|
|
54
|
+
compile: true
|
|
55
|
+
|
|
56
|
+
# Verifies that correct packages and versions are installed by inspecting package.json, yarn.lock, and node_modules
|
|
57
|
+
check_yarn_integrity: true
|
|
58
|
+
|
|
59
|
+
# Reference: https://webpack.js.org/configuration/dev-server/
|
|
60
|
+
dev_server:
|
|
61
|
+
https: false
|
|
62
|
+
host: localhost
|
|
63
|
+
port: 3035
|
|
64
|
+
public: localhost:3035
|
|
65
|
+
hmr: false
|
|
66
|
+
# Inline should be set to true if using HMR
|
|
67
|
+
inline: true
|
|
68
|
+
overlay: true
|
|
69
|
+
compress: true
|
|
70
|
+
disable_host_check: true
|
|
71
|
+
use_local_ip: false
|
|
72
|
+
quiet: false
|
|
73
|
+
pretty: false
|
|
74
|
+
headers:
|
|
75
|
+
'Access-Control-Allow-Origin': '*'
|
|
76
|
+
watch_options:
|
|
77
|
+
ignored: '**/node_modules/**'
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
test:
|
|
81
|
+
<<: *default
|
|
82
|
+
compile: true
|
|
83
|
+
|
|
84
|
+
# Compile test packs to a separate directory
|
|
85
|
+
public_output_path: packs-test
|
|
86
|
+
|
|
87
|
+
production:
|
|
88
|
+
<<: *default
|
|
89
|
+
|
|
90
|
+
# Production depends on precompilation of packs prior to booting for performance.
|
|
91
|
+
compile: false
|
|
92
|
+
|
|
93
|
+
# Extract and emit a css file
|
|
94
|
+
extract_css: false
|
|
95
|
+
|
|
96
|
+
# Cache manifest.json for performance
|
|
97
|
+
cache_manifest: true
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
class AddTokensToUsers < ActiveRecord::Migration[5.2]
|
|
2
|
+
def change
|
|
3
|
+
## Required
|
|
4
|
+
add_column :users, :provider, :string, null: false, default: "email"
|
|
5
|
+
add_column :users, :uid, :string, null: false, default: ""
|
|
6
|
+
|
|
7
|
+
## Tokens
|
|
8
|
+
add_column :users, :tokens, :text
|
|
9
|
+
end
|
|
10
|
+
end
|
data/spec/rails_app/db/schema.rb
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
#
|
|
11
11
|
# It's strongly recommended that you check this file into your version control system.
|
|
12
12
|
|
|
13
|
-
ActiveRecord::Schema.define(version:
|
|
13
|
+
ActiveRecord::Schema.define(version: 2019_12_01_000000) do
|
|
14
14
|
|
|
15
15
|
create_table "admins", force: :cascade do |t|
|
|
16
16
|
t.integer "user_id"
|
|
@@ -89,6 +89,9 @@ ActiveRecord::Schema.define(version: 2018_12_09_000000) do
|
|
|
89
89
|
t.string "name"
|
|
90
90
|
t.datetime "created_at", null: false
|
|
91
91
|
t.datetime "updated_at", null: false
|
|
92
|
+
t.string "provider", default: "email", null: false
|
|
93
|
+
t.string "uid", default: "", null: false
|
|
94
|
+
t.text "tokens"
|
|
92
95
|
t.index ["email"], name: "index_users_on_email"
|
|
93
96
|
end
|
|
94
97
|
|
data/spec/rails_app/db/seeds.rb
CHANGED
|
@@ -2,8 +2,15 @@
|
|
|
2
2
|
# This file is seed file for test data on development environment.
|
|
3
3
|
|
|
4
4
|
def clean_database
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
models = [Comment, Article, Admin, User]
|
|
6
|
+
if ENV['AN_USE_EXISTING_DYNAMODB_TABLE']
|
|
7
|
+
ActivityNotification::Notification.where('id.not_null': true).delete_all
|
|
8
|
+
ActivityNotification::Subscription.where('id.not_null': true).delete_all
|
|
9
|
+
else
|
|
10
|
+
models.concat([ActivityNotification::Notification, ActivityNotification::Subscription])
|
|
11
|
+
end
|
|
12
|
+
models.each do |model|
|
|
13
|
+
model.delete_all
|
|
7
14
|
end
|
|
8
15
|
end
|
|
9
16
|
|
|
@@ -68,6 +75,7 @@ puts "* Created #{Article.count} article records"
|
|
|
68
75
|
notifications = ActivityNotification::Notification.filtered_by_type("Article")
|
|
69
76
|
puts "** Generated #{ActivityNotification::Notification.filtered_by_type("Article").count} notification records for new articles"
|
|
70
77
|
puts "*** #{ActivityNotification::Notification.filtered_by_type("Article").filtered_by_target_type("User").count} notifications as #{ActivityNotification::Notification.filtered_by_type("Article").filtered_by_target_type("User").group_owners_only.count} groups to users"
|
|
78
|
+
puts "*** #{ActivityNotification::Notification.filtered_by_type("Article").filtered_by_target_type("Admin").count} notifications as #{ActivityNotification::Notification.filtered_by_type("Article").filtered_by_target_type("Admin").group_owners_only.count} groups to admins"
|
|
71
79
|
|
|
72
80
|
Article.all.each do |article|
|
|
73
81
|
User.all.each do |user|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module CustomOptionalTarget
|
|
2
|
+
# Optional target implementation to raise error.
|
|
3
|
+
class RaiseError < ActivityNotification::OptionalTarget::Base
|
|
4
|
+
def initialize_target(options = {})
|
|
5
|
+
@raise_error = options[:raise_error] == false ? false : true
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def notify(notification, options = {})
|
|
9
|
+
if @raise_error
|
|
10
|
+
raise 'Intentional RuntimeError in CustomOptionalTarget::RaiseError'
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "activity_notification",
|
|
3
|
+
"description": "Sample single page application for activity_notification using Vue.js",
|
|
4
|
+
"dependencies": {
|
|
5
|
+
"@rails/webpacker": "^4.2.0",
|
|
6
|
+
"axios": "^0.19.0",
|
|
7
|
+
"vue": "^2.6.10",
|
|
8
|
+
"vuex": "^3.1.2",
|
|
9
|
+
"vuex-persistedstate": "^2.7.0",
|
|
10
|
+
"vue-loader": "^15.7.2",
|
|
11
|
+
"vue-router": "^3.1.3",
|
|
12
|
+
"vue-template-compiler": "^2.6.10",
|
|
13
|
+
"vue-moment": "^4.1.0",
|
|
14
|
+
"vue-moment-tz": "^2.1.1",
|
|
15
|
+
"vue-pluralize": "^0.0.2",
|
|
16
|
+
"actioncable-vue": "^1.5.1",
|
|
17
|
+
"push.js": "^1.0.12"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"webpack-dev-server": "^3.9.0"
|
|
21
|
+
},
|
|
22
|
+
"license": "MIT"
|
|
23
|
+
}
|
|
@@ -54,7 +54,7 @@ describe ActivityNotification::ActsAsNotifiable do
|
|
|
54
54
|
|
|
55
55
|
context "true as :tracked" do
|
|
56
56
|
before do
|
|
57
|
-
dummy_notifiable_class.acts_as_notifiable :users, targets: [user_target], tracked: true
|
|
57
|
+
dummy_notifiable_class.acts_as_notifiable :users, targets: [user_target], tracked: true, notifiable_path: -> { "dummy_path" }
|
|
58
58
|
@created_notifiable = dummy_notifiable_class.create
|
|
59
59
|
end
|
|
60
60
|
|
|
@@ -103,7 +103,7 @@ describe ActivityNotification::ActsAsNotifiable do
|
|
|
103
103
|
|
|
104
104
|
context "with :only option (creation only)" do
|
|
105
105
|
before do
|
|
106
|
-
dummy_notifiable_class.acts_as_notifiable :users, targets: [user_target], tracked: { only: [:create] }
|
|
106
|
+
dummy_notifiable_class.acts_as_notifiable :users, targets: [user_target], tracked: { only: [:create] }, notifiable_path: -> { "dummy_path" }
|
|
107
107
|
@created_notifiable = dummy_notifiable_class.create
|
|
108
108
|
end
|
|
109
109
|
|
|
@@ -133,7 +133,7 @@ describe ActivityNotification::ActsAsNotifiable do
|
|
|
133
133
|
|
|
134
134
|
context "with :except option (except update)" do
|
|
135
135
|
before do
|
|
136
|
-
dummy_notifiable_class.acts_as_notifiable :users, targets: [user_target], tracked: { except: [:update] }
|
|
136
|
+
dummy_notifiable_class.acts_as_notifiable :users, targets: [user_target], tracked: { except: [:update] }, notifiable_path: -> { "dummy_path" }
|
|
137
137
|
@created_notifiable = dummy_notifiable_class.create
|
|
138
138
|
end
|
|
139
139
|
|
|
@@ -163,7 +163,7 @@ describe ActivityNotification::ActsAsNotifiable do
|
|
|
163
163
|
|
|
164
164
|
context "with :key option" do
|
|
165
165
|
before do
|
|
166
|
-
dummy_notifiable_class.acts_as_notifiable :users, targets: [user_target], tracked: { key: "test.key" }
|
|
166
|
+
dummy_notifiable_class.acts_as_notifiable :users, targets: [user_target], tracked: { key: "test.key" }, notifiable_path: -> { "dummy_path" }
|
|
167
167
|
@created_notifiable = dummy_notifiable_class.create
|
|
168
168
|
end
|
|
169
169
|
|
|
@@ -199,7 +199,7 @@ describe ActivityNotification::ActsAsNotifiable do
|
|
|
199
199
|
context "with :notify_later option" do
|
|
200
200
|
before do
|
|
201
201
|
ActiveJob::Base.queue_adapter = :test
|
|
202
|
-
dummy_notifiable_class.acts_as_notifiable :users, targets: [user_target], tracked: { notify_later: true }
|
|
202
|
+
dummy_notifiable_class.acts_as_notifiable :users, targets: [user_target], tracked: { notify_later: true }, notifiable_path: -> { "dummy_path" }
|
|
203
203
|
@created_notifiable = dummy_notifiable_class.create
|
|
204
204
|
end
|
|
205
205
|
|
|
@@ -420,14 +420,12 @@ describe ActivityNotification::ActsAsNotifiable do
|
|
|
420
420
|
end
|
|
421
421
|
end
|
|
422
422
|
end
|
|
423
|
-
|
|
424
|
-
#TODO test other options
|
|
425
423
|
end
|
|
426
424
|
|
|
427
425
|
describe ".available_notifiable_options" do
|
|
428
426
|
it "returns list of available options in acts_as_notifiable" do
|
|
429
427
|
expect(dummy_model_class.available_notifiable_options)
|
|
430
|
-
.to eq([:targets, :group, :group_expiry_delay, :notifier, :parameters, :email_allowed, :action_cable_allowed, :notifiable_path, :printable_notifiable_name, :printable_name, :dependent_notifications, :optional_targets])
|
|
428
|
+
.to eq([:targets, :group, :group_expiry_delay, :notifier, :parameters, :email_allowed, :action_cable_allowed, :action_cable_api_allowed, :notifiable_path, :printable_notifiable_name, :printable_name, :dependent_notifications, :optional_targets])
|
|
431
429
|
end
|
|
432
430
|
end
|
|
433
431
|
end
|
|
@@ -18,14 +18,10 @@ describe ActivityNotification::ActsAsTarget do
|
|
|
18
18
|
expect(dummy_model_class.acts_as_target).to eq({})
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
|
-
|
|
22
|
-
#TODO test other options
|
|
23
21
|
end
|
|
24
22
|
|
|
25
23
|
describe ".acts_as_notification_target" do
|
|
26
24
|
it "is an alias of acts_as_target" do
|
|
27
|
-
#TODO make better way to test alias
|
|
28
|
-
#expect(dummy_model_class.acts_as_notification_target).to receive(:acts_as_target)
|
|
29
25
|
expect(dummy_model_class.respond_to?(:acts_as_notification_target)).to be_truthy
|
|
30
26
|
end
|
|
31
27
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -14,30 +14,22 @@ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new [
|
|
|
14
14
|
SimpleCov.start('rails') do
|
|
15
15
|
add_filter '/spec/'
|
|
16
16
|
add_filter '/lib/generators/templates/'
|
|
17
|
-
add_filter '/lib/activity_notification/version
|
|
18
|
-
if Rails::VERSION::MAJOR >= 5
|
|
19
|
-
skip_token_tag = 'except-rails5-plus'
|
|
20
|
-
else
|
|
21
|
-
skip_token_tag = 'only-rails5-plus'
|
|
22
|
-
add_filter '/app/channels/activity_notification/'
|
|
23
|
-
end
|
|
24
|
-
if Gem::Version.new("5.1.6") <= Rails.gem_version && Rails.gem_version < Gem::Version.new("5.2.2")
|
|
25
|
-
skip_token_tag += '#only-rails-without-callback-issue'
|
|
26
|
-
else
|
|
27
|
-
skip_token_tag += '#only-rails-with-callback-issue'
|
|
28
|
-
end
|
|
17
|
+
add_filter '/lib/activity_notification/version'
|
|
29
18
|
if ENV['AN_ORM'] == 'mongoid'
|
|
30
19
|
add_filter '/lib/activity_notification/orm/active_record'
|
|
31
20
|
add_filter '/lib/activity_notification/orm/dynamoid'
|
|
32
21
|
elsif ENV['AN_ORM'] == 'dynamoid'
|
|
33
22
|
add_filter '/lib/activity_notification/orm/active_record'
|
|
34
23
|
add_filter '/lib/activity_notification/orm/mongoid'
|
|
35
|
-
skip_token_tag += '#except-dynamoid'
|
|
36
24
|
else
|
|
37
25
|
add_filter '/lib/activity_notification/orm/mongoid'
|
|
38
26
|
add_filter '/lib/activity_notification/orm/dynamoid'
|
|
39
27
|
end
|
|
40
|
-
|
|
28
|
+
if Rails::VERSION::MAJOR < 5
|
|
29
|
+
add_filter '/app/channels/'
|
|
30
|
+
add_filter '/lib/activity_notification/optional_targets/action_cable_channel'
|
|
31
|
+
add_filter '/lib/activity_notification/optional_targets/action_cable_api_channel'
|
|
32
|
+
end
|
|
41
33
|
end
|
|
42
34
|
|
|
43
35
|
# Dummy application
|
|
@@ -59,7 +51,7 @@ end
|
|
|
59
51
|
|
|
60
52
|
RSpec.configure do |config|
|
|
61
53
|
config.include FactoryBot::Syntax::Methods
|
|
62
|
-
config.before(:
|
|
54
|
+
config.before(:each) do
|
|
63
55
|
FactoryBot.reload
|
|
64
56
|
clean_database
|
|
65
57
|
end
|