activity_notification 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +6 -16
  3. data/CHANGELOG.md +52 -0
  4. data/Gemfile +2 -3
  5. data/README.md +2 -2
  6. data/activity_notification.gemspec +1 -1
  7. data/app/channels/activity_notification/notification_api_with_devise_channel.rb +1 -1
  8. data/app/channels/activity_notification/notification_channel.rb +1 -1
  9. data/app/channels/activity_notification/notification_with_devise_channel.rb +1 -1
  10. data/app/controllers/activity_notification/notifications_api_with_devise_controller.rb +1 -1
  11. data/app/controllers/activity_notification/notifications_controller.rb +0 -20
  12. data/app/controllers/activity_notification/subscriptions_api_controller.rb +1 -1
  13. data/app/controllers/activity_notification/subscriptions_api_with_devise_controller.rb +1 -1
  14. data/bin/bundle_update.sh +0 -1
  15. data/docs/Functions.md +3 -3
  16. data/docs/Setup.md +190 -63
  17. data/gemfiles/Gemfile.rails-5.0 +3 -1
  18. data/gemfiles/Gemfile.rails-5.1 +3 -1
  19. data/gemfiles/Gemfile.rails-5.2 +3 -1
  20. data/gemfiles/Gemfile.rails-6.0 +2 -3
  21. data/lib/activity_notification.rb +1 -0
  22. data/lib/activity_notification/apis/notification_api.rb +8 -1
  23. data/lib/activity_notification/common.rb +15 -4
  24. data/lib/activity_notification/controllers/common_controller.rb +2 -18
  25. data/lib/activity_notification/controllers/concerns/swagger/notifications_parameters.rb +2 -2
  26. data/lib/activity_notification/models/concerns/notifiable.rb +12 -12
  27. data/lib/activity_notification/models/concerns/swagger/notification_schema.rb +34 -34
  28. data/lib/activity_notification/models/concerns/swagger/subscription_schema.rb +17 -17
  29. data/lib/activity_notification/models/concerns/target.rb +5 -9
  30. data/lib/activity_notification/optional_targets/action_cable_api_channel.rb +1 -1
  31. data/lib/activity_notification/optional_targets/action_cable_channel.rb +1 -1
  32. data/lib/activity_notification/orm/active_record.rb +1 -1
  33. data/lib/activity_notification/orm/active_record/notification.rb +3 -3
  34. data/lib/activity_notification/orm/dynamoid.rb +10 -3
  35. data/lib/activity_notification/orm/dynamoid/notification.rb +49 -14
  36. data/lib/activity_notification/orm/dynamoid/subscription.rb +1 -1
  37. data/lib/activity_notification/orm/mongoid.rb +10 -3
  38. data/lib/activity_notification/orm/mongoid/notification.rb +8 -6
  39. data/lib/activity_notification/orm/mongoid/subscription.rb +1 -1
  40. data/lib/activity_notification/renderable.rb +2 -2
  41. data/lib/activity_notification/roles/acts_as_notifiable.rb +13 -16
  42. data/lib/activity_notification/version.rb +1 -1
  43. data/lib/generators/templates/migrations/migration.rb +1 -1
  44. data/spec/channels/notification_api_channel_spec.rb +42 -44
  45. data/spec/channels/notification_api_with_devise_channel_spec.rb +57 -59
  46. data/spec/channels/notification_channel_spec.rb +41 -43
  47. data/spec/channels/notification_with_devise_channel_spec.rb +75 -77
  48. data/spec/concerns/apis/notification_api_spec.rb +1 -1
  49. data/spec/concerns/common_spec.rb +25 -3
  50. data/spec/concerns/models/notifiable_spec.rb +35 -35
  51. data/spec/concerns/models/target_spec.rb +10 -12
  52. data/spec/concerns/renderable_spec.rb +5 -5
  53. data/spec/config_spec.rb +26 -15
  54. data/spec/controllers/controller_spec_utility.rb +15 -51
  55. data/spec/generators/migration/migration_generator_spec.rb +2 -10
  56. data/spec/helpers/view_helpers_spec.rb +1 -1
  57. data/spec/models/subscription_spec.rb +8 -0
  58. data/spec/optional_targets/action_cable_api_channel_spec.rb +21 -24
  59. data/spec/optional_targets/action_cable_channel_spec.rb +26 -29
  60. data/spec/rails_app/app/controllers/users_controller.rb +5 -0
  61. data/spec/rails_app/app/javascript/App.vue +8 -72
  62. data/spec/rails_app/app/javascript/components/DeviseTokenAuth.vue +3 -4
  63. data/spec/rails_app/app/javascript/components/Top.vue +2 -3
  64. data/spec/rails_app/app/javascript/packs/spa.js +6 -3
  65. data/spec/rails_app/app/javascript/router/index.js +73 -0
  66. data/spec/rails_app/app/javascript/store/{auth.js → index.js} +0 -0
  67. data/spec/rails_app/app/models/dummy/dummy_group.rb +8 -0
  68. data/spec/rails_app/app/models/dummy/dummy_notifiable_target.rb +8 -0
  69. data/spec/rails_app/app/models/user.rb +2 -1
  70. data/spec/rails_app/config/application.rb +6 -7
  71. data/spec/rails_app/config/dynamoid.rb +11 -3
  72. data/spec/rails_app/config/environments/production.rb +3 -0
  73. data/spec/rails_app/config/environments/test.rb +2 -11
  74. data/spec/rails_app/config/initializers/activity_notification.rb +3 -3
  75. data/spec/rails_app/config/initializers/copy_it.aws.rb.template +6 -0
  76. data/spec/rails_app/config/routes.rb +5 -1
  77. data/spec/rails_app/db/seeds.rb +9 -2
  78. data/spec/roles/acts_as_notifiable_spec.rb +5 -5
  79. data/spec/spec_helper.rb +1 -5
  80. metadata +11 -10
  81. data/gemfiles/Gemfile.rails-4.2 +0 -23
  82. data/spec/support/patch_rails_42_action_controller_test_response.rb +0 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b1f6ad3e3fe40d4841cde7931cdc67065c87fd948db1674a1cbc3016f1338aba
4
- data.tar.gz: 0b15bf8fe764df0d3431543d29ec08b3f95548faf337a14b3c30f98379688742
3
+ metadata.gz: 771b080e7877b6a83105bc0f8842440fc4f2a12c0fa56b6e55f4d2b24b3e9d20
4
+ data.tar.gz: 2b8dcbeb13208ef8a44e3fa246ac464f1e36c8140cc1e087ebc6b39e55da1107
5
5
  SHA512:
6
- metadata.gz: 56c6fe87c9ab5444d02969775ca91d1c3054d1c63ff0e12f1308984b0b5c8f06c48f3dea8cd9bfa333f79f72f3951de99d028a1f586d2f485537104300346c07
7
- data.tar.gz: 309085505f26839eefdfed6a34a9d950af85013a1c161d384206e3c4a31e3156b80c1d37097d8c56dced7b10fea83715daaa10abf85e70185029e7df76fcc9d6
6
+ metadata.gz: e573698b449a5aef558b312c4fd0a7023d28adf2ab4210f941efc6a3025c4126cf4428ca561addf760e4e6a875696ffe6ba06d0bc0501007f663f4e59f3c0a07
7
+ data.tar.gz: 7c8d4771871af1dedd7440fcb670b9a50b5820fa9f09e3be5df9d2f6618002174dfaf00d7f71f6e725aecc28267b8a2263050ecbed662d3c6038a7dabd9383fe
@@ -5,14 +5,13 @@ branches:
5
5
  - images
6
6
 
7
7
  rvm:
8
- # - 2.7.0 # Need to respond to warnings for Ruby 3.0
9
- - 2.6.5
10
- # - 2.5.7
11
- # - 2.4.9
8
+ - 2.7.2
9
+ # - 2.6.6
10
+ # - 2.5.8
11
+ # - 2.4.10 #EOL
12
12
  # - 2.3.8 #EOL
13
13
 
14
14
  gemfile:
15
- - gemfiles/Gemfile.rails-4.2
16
15
  - gemfiles/Gemfile.rails-5.0
17
16
  - gemfiles/Gemfile.rails-5.1
18
17
  - gemfiles/Gemfile.rails-5.2
@@ -27,9 +26,6 @@ env:
27
26
  - AN_ORM=dynamoid
28
27
 
29
28
  matrix:
30
- exclude:
31
- - gemfile: gemfiles/Gemfile.rails-4.2
32
- env: AN_ORM=dynamoid
33
29
  include:
34
30
  - rvm: ruby-head
35
31
  gemfile: Gemfile
@@ -53,18 +49,12 @@ sudo: false
53
49
 
54
50
  cache: bundler
55
51
 
56
- before_install:
57
- # Specify bundler version as '< 2.0' for Rails 4.2
58
- - gem install bundler --no-document -v '1.17.3'
59
-
60
52
  install:
61
- # Specify bundler version as '< 2.0' for Rails 4.2
62
- - bundle _1.17.3_ install
53
+ - bundle install
63
54
  - if [ "$AN_ORM" = "dynamoid" ]; then bin/install_dynamodblocal.sh; fi
64
55
 
65
56
  before_script:
66
- # Specify bundler version as '< 2.0' for Rails 4.2
67
- - bundle _1.17.3_ update
57
+ - bundle update
68
58
  - if [ "$AN_TEST_DB" = "mysql" ]; then mysql -e 'create database activity_notification_test'; fi
69
59
  - if [ "$AN_TEST_DB" = "postgresql" ]; then psql -c 'create database activity_notification_test' -U postgres; fi
70
60
  - if [ "$AN_ORM" = "dynamoid" ]; then bin/start_dynamodblocal.sh; fi
@@ -1,3 +1,55 @@
1
+ ## 2.2.0 / 2020-12-05
2
+ [Full Changelog](http://github.com/simukappu/activity_notification/compare/v2.1.4...v2.2.0)
3
+
4
+ Enhancements:
5
+
6
+ * Remove support for Rails 4.2 - [#151](https://github.com/simukappu/activity_notification/issues/151)
7
+ * Turn on deprecation warnings in RSpec testing for Ruby 2.7 - [#122](https://github.com/simukappu/activity_notification/issues/122)
8
+ * Remove Ruby 2.7 deprecation warnings - [#122](https://github.com/simukappu/activity_notification/issues/122)
9
+
10
+ Breaking Changes:
11
+
12
+ * Specify DynamoDB global secondary index name
13
+ * Update additional fields to store into DynamoDB when *config.store_with_associated_records* is true
14
+
15
+ ## 2.1.4 / 2020-11-07
16
+ [Full Changelog](http://github.com/simukappu/activity_notification/compare/v2.1.3...v2.1.4)
17
+
18
+ Enhancements:
19
+
20
+ * Make *Common#to_class_name* method return base_class name in order to work with STI models - [#89](https://github.com/simukappu/activity_notification/issues/89) [#139](https://github.com/simukappu/activity_notification/pull/139)
21
+
22
+ Bug Fixes:
23
+
24
+ * Rename *Notifiable#notification_action_cable_allowed?* to *notifiable_action_cable_allowed?* to fix duplicate method name error - [#138](https://github.com/simukappu/activity_notification/issues/138)
25
+ * Fix hash syntax in swagger schemas - [#146](https://github.com/simukappu/activity_notification/issues/146) [#147](https://github.com/simukappu/activity_notification/pull/147)
26
+
27
+ ## 2.1.3 / 2020-08-11
28
+ [Full Changelog](http://github.com/simukappu/activity_notification/compare/v2.1.2...v2.1.3)
29
+
30
+ Enhancements:
31
+
32
+ * Enable to use namespaced model - [#132](https://github.com/simukappu/activity_notification/pull/132)
33
+
34
+ Bug Fixes:
35
+
36
+ * Fix mongoid any_of selector error in filtered_by_group scope - [MONGOID-4887](https://jira.mongodb.org/browse/MONGOID-4887)
37
+
38
+ ## 2.1.2 / 2020-02-24
39
+ [Full Changelog](http://github.com/simukappu/activity_notification/compare/v2.1.1...v2.1.2)
40
+
41
+ Bug Fixes:
42
+
43
+ * Fix scope of uniqueness validation in subscription model with mongoid - [#126](https://github.com/simukappu/activity_notification/issues/126) [#128](https://github.com/simukappu/activity_notification/pull/128)
44
+ * Fix uninitialized constant DeviseTokenAuth when *config.eager_load = true* - [#129](https://github.com/simukappu/activity_notification/issues/129)
45
+
46
+ ## 2.1.1 / 2020-02-11
47
+ [Full Changelog](http://github.com/simukappu/activity_notification/compare/v2.1.0...v2.1.1)
48
+
49
+ Bug Fixes:
50
+
51
+ * Fix eager_load by autoloading VERSION - [#124](https://github.com/simukappu/activity_notification/issues/124) [#125](https://github.com/simukappu/activity_notification/pull/125)
52
+
1
53
  ## 2.1.0 / 2020-02-04
2
54
  [Full Changelog](http://github.com/simukappu/activity_notification/compare/v2.0.0...v2.1.0)
3
55
 
data/Gemfile CHANGED
@@ -16,14 +16,13 @@ group :development do
16
16
  end
17
17
 
18
18
  group :test do
19
- #TODO https://github.com/rails/rails/issues/35417
20
- gem 'rspec-rails', '4.0.0.beta4'
21
19
  gem 'rails-controller-testing'
22
20
  gem 'ammeter'
23
21
  gem 'timecop'
24
22
  gem 'committee'
25
23
  gem 'committee-rails'
26
- gem 'coveralls', require: false
24
+ # gem 'coveralls', require: false
25
+ gem 'coveralls_reborn', require: false
27
26
  end
28
27
 
29
28
  gem 'webpacker', groups: [:production, :development]
data/README.md CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  *activity_notification* provides integrated user activity notifications for [Ruby on Rails](https://rubyonrails.org). You can easily use it to configure multiple notification targets and make activity notifications with notifiable models, like adding comments, responding etc.
12
12
 
13
- *activity_notification* supports Rails 4.2+ with [ActiveRecord](https://guides.rubyonrails.org/active_record_basics.html), [Mongoid](https://mongoid.org) and [Dynamoid](https://github.com/Dynamoid/dynamoid) ORM. It is tested for [MySQL](https://www.mysql.com), [PostgreSQL](https://www.postgresql.org), [SQLite3](https://www.sqlite.org) with ActiveRecord, [MongoDB](https://www.mongodb.com) with Mongoid and [Amazon DynamoDB](https://aws.amazon.com/dynamodb) with Dynamoid. The latest *activity_notification* [v2](https://rubygems.org/gems/activity_notification) is almost compatible with [v1](https://rubygems.org/gems/activity_notification/versions/1.7.1).
13
+ *activity_notification* supports Rails 5.0+ with [ActiveRecord](https://guides.rubyonrails.org/active_record_basics.html), [Mongoid](https://mongoid.org) and [Dynamoid](https://github.com/Dynamoid/dynamoid) ORM. It is tested for [MySQL](https://www.mysql.com), [PostgreSQL](https://www.postgresql.org), [SQLite3](https://www.sqlite.org) with ActiveRecord, [MongoDB](https://www.mongodb.com) with Mongoid and [Amazon DynamoDB](https://aws.amazon.com/dynamodb) with Dynamoid. If you are using Rails 4.2, use [v2.1.4](https://rubygems.org/gems/activity_notification/versions/2.1.4) or older version of *activity_notification*.
14
14
 
15
15
 
16
16
  ## About
@@ -68,7 +68,7 @@ The deployed demo application is included in this gem's source code as a test ap
68
68
  ### Public REST API reference as OpenAPI Specification
69
69
 
70
70
  REST API reference as OpenAPI Specification is published in SwaggerHub here:
71
- * **https://app.swaggerhub.com/apis/simukappu/activity-notification/**
71
+ * **https://app.swaggerhub.com/apis-docs/simukappu/activity-notification/**
72
72
 
73
73
  You can see sample single page application using [Vue.js](https://vuejs.org) as a part of example Rails application here:
74
74
  * **https://activity-notification-example.herokuapp.com/spa/**
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.require_paths = ["lib"]
21
21
  s.required_ruby_version = '>= 2.1.0'
22
22
 
23
- s.add_dependency 'railties', '>= 4.2.0', '< 6.1'
23
+ s.add_dependency 'railties', '>= 5.0.0', '< 6.1'
24
24
  s.add_dependency 'i18n', '>= 0.5.0'
25
25
  s.add_dependency 'jquery-rails', '>= 3.1.1'
26
26
  s.add_dependency 'swagger-blocks', '>= 3.0.0'
@@ -24,7 +24,7 @@ if defined?(ActionCable)
24
24
  # @return [Object] Target instance (Reject subscription when request parameters are not enough)
25
25
  def set_target
26
26
  reject and return if (target_type = params[:target_type]).blank?
27
- if params[:target_id].blank? && params["#{target_type.to_s.to_resource_name}_id"].blank?
27
+ if params[:target_id].blank? && params["#{target_type.to_s.to_resource_name[/([^\/]+)$/]}_id"].blank?
28
28
  reject and return if params[:devise_type].blank?
29
29
  current_target = find_current_target(params[:devise_type])
30
30
  params[:target_id] = target_type.to_model_class.resolve_current_devise_target(current_target)
@@ -22,7 +22,7 @@ if defined?(ActionCable)
22
22
  target_class = target_type.to_s.to_model_class
23
23
  @target = params[:target_id].present? ?
24
24
  target_class.find_by!(id: params[:target_id]) :
25
- target_class.find_by!(id: params["#{target_type.to_s.to_resource_name}_id"])
25
+ target_class.find_by!(id: params["#{target_type.to_s.to_resource_name[/([^\/]+)$/]}_id"])
26
26
  rescue
27
27
  reject
28
28
  end
@@ -29,7 +29,7 @@ if defined?(ActionCable)
29
29
  # @return [Object] Target instance (Reject subscription when request parameters are not enough)
30
30
  def set_target
31
31
  reject and return if (target_type = params[:target_type]).blank?
32
- if params[:target_id].blank? && params["#{target_type.to_s.to_resource_name}_id"].blank?
32
+ if params[:target_id].blank? && params["#{target_type.to_s.to_resource_name[/([^\/]+)$/]}_id"].blank?
33
33
  reject and return if params[:devise_type].blank?
34
34
  current_target = find_current_target(params[:devise_type])
35
35
  params[:target_id] = target_type.to_model_class.resolve_current_devise_target(current_target)
@@ -1,7 +1,7 @@
1
1
  module ActivityNotification
2
2
  # Controller to manage notifications API with Devise authentication.
3
3
  class NotificationsApiWithDeviseController < NotificationsApiController
4
- include DeviseTokenAuth::Concerns::SetUserByToken
4
+ include DeviseTokenAuth::Concerns::SetUserByToken if defined?(DeviseTokenAuth)
5
5
  include DeviseAuthenticationController
6
6
  end
7
7
  end
@@ -117,26 +117,6 @@ module ActivityNotification
117
117
  super
118
118
  end
119
119
 
120
- # :nocov:
121
- if Rails::VERSION::MAJOR == 4
122
- # Defines custom renderer class method for Rails 4.2
123
- def self.renderer
124
- view_context = ActionView::Base.new(ActionController::Base.view_paths, {})
125
- view_context.class_eval do
126
- include Rails.application.routes.url_helpers
127
- def default_url_options
128
- ActionMailer::Base.default_url_options
129
- end
130
- def render(params = {})
131
- assign(params[:assigns])
132
- super(params)
133
- end
134
- end
135
- view_context
136
- end
137
- end
138
- # :nocov:
139
-
140
120
  protected
141
121
 
142
122
  # Sets @notification instance variable from request parameters.
@@ -44,7 +44,7 @@ module ActivityNotification
44
44
  params[:subscription][:optional_targets]["subscribing_to_#{optional_target_name}"] = subscribing_param unless subscribing_param.nil?
45
45
  end
46
46
  super
47
- render status: 201, location: { action: :show, id: @subscription }, json: subscription_json
47
+ render status: 201, json: subscription_json if @subscription
48
48
  end
49
49
 
50
50
  # Finds and shows a subscription from specified key.
@@ -1,7 +1,7 @@
1
1
  module ActivityNotification
2
2
  # Controller to manage subscriptions API with Devise authentication.
3
3
  class SubscriptionsApiWithDeviseController < SubscriptionsApiController
4
- include DeviseTokenAuth::Concerns::SetUserByToken
4
+ include DeviseTokenAuth::Concerns::SetUserByToken if defined?(DeviseTokenAuth)
5
5
  include DeviseAuthenticationController
6
6
  end
7
7
  end
@@ -1,7 +1,6 @@
1
1
  #!/bin/bash
2
2
 
3
3
  bundle update
4
- BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.2 bundle update
5
4
  BUNDLE_GEMFILE=gemfiles/Gemfile.rails-5.0 bundle update
6
5
  BUNDLE_GEMFILE=gemfiles/Gemfile.rails-5.1 bundle update
7
6
  BUNDLE_GEMFILE=gemfiles/Gemfile.rails-5.2 bundle update
@@ -65,9 +65,9 @@ config.mailer_sender = ->(key){ key == 'inquiry.post' ? 'support@example.com' :
65
65
 
66
66
  #### Email templates
67
67
 
68
- *activity_notification* will look for email template in a similar way as notification views, but the view file name is not start with an underscore. For example, if you have a notification with *:key* set to *"notification.comment.reply"* and target_type *users*, the gem will look for a partial in *app/views/activity_notification/mailer/users/comment/reply.html.(|erb|haml|slim|something_else)*.
68
+ *activity_notification* will look for email template in a similar way as notification views, but the view file name does not start with an underscore. For example, if you have a notification with *:key* set to *"notification.comment.reply"* and target_type *users*, the gem will look for a partial in *app/views/activity_notification/mailer/users/comment/reply.html.(|erb|haml|slim|something_else)*.
69
69
 
70
- If this template is missing, the gem will look for a partial in *default* as the target type which means *activity_notification/mailer/default/_default.html.(|erb|haml|slim|something_else)*.
70
+ If this template is missing, the gem will use *default* as the target type which means *activity_notification/mailer/default/default.html.(|erb|haml|slim|something_else)*.
71
71
 
72
72
  #### Email subject
73
73
 
@@ -422,7 +422,7 @@ You can see [sample single page application](/spec/rails_app/app/javascript/) us
422
422
 
423
423
  OpenAPI Specification in [online demo](https://activity-notification-example.herokuapp.com/) is published here: **https://activity-notification-example.herokuapp.com/api/v2/apidocs**
424
424
 
425
- Public API reference is also hosted in [SwaggerHub](https://swagger.io/tools/swaggerhub/) here: **https://app.swaggerhub.com/apis/simukappu/activity-notification/**
425
+ Public API reference is also hosted in [SwaggerHub](https://swagger.io/tools/swaggerhub/) here: **https://app.swaggerhub.com/apis-docs/simukappu/activity-notification/**
426
426
 
427
427
  You can also publish OpenAPI Specification in your own application using *[ActivityNotification::ApidocsController](/app/controllers/activity_notification/apidocs_controller.rb)* like this:
428
428
 
@@ -109,76 +109,189 @@ When **store_with_associated_records** is set to *false* as default, *activity_n
109
109
 
110
110
  ```json
111
111
  {
112
- "id": {
113
- "S": "f05756ef-661e-4ef5-9e99-5af51243125c"
114
- },
115
- "target_key": {
116
- "S": "User#1"
117
- },
118
- "notifiable_key": {
119
- "S": "Comment#2"
120
- },
121
- "key": {
122
- "S": "comment.default"
123
- },
124
- "group_key": {
125
- "S": "Article#1"
126
- },
127
- "notifier_key": {
128
- "S": "User#2"
129
- },
130
- "created_at": {
131
- "N": "1560085332.689929"
132
- },
133
- "updated_at": {
134
- "N": "1560085332.695515"
135
- },
136
- "parameters": {
137
- "M": {}
138
- }
112
+ "id": {
113
+ "S": "f05756ef-661e-4ef5-9e99-5af51243125c"
114
+ },
115
+ "target_key": {
116
+ "S": "User#1"
117
+ },
118
+ "notifiable_key": {
119
+ "S": "Comment#2"
120
+ },
121
+ "key": {
122
+ "S": "comment.default"
123
+ },
124
+ "group_key": {
125
+ "S": "Article#1"
126
+ },
127
+ "notifier_key": {
128
+ "S": "User#2"
129
+ },
130
+ "created_at": {
131
+ "S": "2020-03-08T08:22:53+00:00"
132
+ },
133
+ "updated_at": {
134
+ "S": "2020-03-08T08:22:53+00:00"
135
+ },
136
+ "parameters": {
137
+ "M": {}
138
+ }
139
139
  }
140
140
  ```
141
141
 
142
- When you set **store_with_associated_records** to *true*, *activity_notification* stores notificaion records including associated target, notifiable and notifier like this:
142
+ When you set **store_with_associated_records** to *true*, *activity_notification* stores notificaion records including associated target, notifiable, notifier and several instance methods like this:
143
143
 
144
144
  ```json
145
145
  {
146
- "id": {
147
- "S": "f05756ef-661e-4ef5-9e99-5af51243125c"
148
- },
149
- "target_key": {
150
- "S": "User#1"
151
- },
152
- "target_record": {
153
- "S": "{\"id\":1,\"email\":\"ichiro@example.com\",\"name\":\"Ichiro\",\"created_at\":\"2019-06-09T13:10:44.853Z\",\"updated_at\":\"2019-06-09T13:10:44.853Z\"}"
154
- },
155
- "notifiable_key": {
156
- "S": "Comment#2"
157
- },
158
- "notifiable_record": {
159
- "S": "{\"id\":2,\"user_id\":2,\"article_id\":1,\"body\":\"This is the first Stephen's comment to Ichiro's article.\",\"created_at\":\"2019-06-09T13:10:45.677Z\",\"updated_at\":\"2019-06-09T13:10:45.677Z\"}"
160
- },
161
- "key": {
162
- "S": "comment.default"
163
- },
164
- "group_key": {
165
- "S": "Article#1"
166
- },
167
- "notifier_key": {
168
- "S": "User#2"
169
- },
170
- "notifier_record": {
171
- "S": "{\"id\":2,\"email\":\"stephen@example.com\",\"name\":\"Stephen\",\"created_at\":\"2019-06-09T13:10:45.006Z\",\"updated_at\":\"2019-06-09T13:10:45.006Z\"}"
172
- },
173
- "created_at": {
174
- "N": "1560085332.689929"
175
- },
176
- "updated_at": {
177
- "N": "1560085332.695515"
178
- },
179
- "parameters": {
180
- "M": {}
146
+ "id": {
147
+ "S": "f05756ef-661e-4ef5-9e99-5af51243125c"
148
+ },
149
+ "target_key": {
150
+ "S": "User#1"
151
+ },
152
+ "notifiable_key": {
153
+ "S": "Comment#2"
154
+ },
155
+ "key": {
156
+ "S": "comment.default"
157
+ },
158
+ "group_key": {
159
+ "S": "Article#1"
160
+ },
161
+ "notifier_key": {
162
+ "S": "User#2"
163
+ },
164
+ "created_at": {
165
+ "S": "2020-03-08T08:22:53+00:00"
166
+ },
167
+ "updated_at": {
168
+ "S": "2020-03-08T08:22:53+00:00"
169
+ },
170
+ "parameters": {
171
+ "M": {}
172
+ },
173
+ "stored_target": {
174
+ "M": {
175
+ "id": {
176
+ "N": "1"
177
+ },
178
+ "email": {
179
+ "S": "ichiro@example.com"
180
+ },
181
+ "name": {
182
+ "S": "Ichiro"
183
+ },
184
+ "created_at": {
185
+ "S": "2020-03-08T08:22:23.451Z"
186
+ },
187
+ "updated_at": {
188
+ "S": "2020-03-08T08:22:23.451Z"
189
+ },
190
+ // { ... },
191
+ "printable_type": {
192
+ "S": "User"
193
+ },
194
+ "printable_target_name": {
195
+ "S": "Ichiro"
196
+ },
197
+ }
198
+ },
199
+ "stored_notifiable": {
200
+ "M": {
201
+ "id": {
202
+ "N": "2"
203
+ },
204
+ "user_id": {
205
+ "N": "2"
206
+ },
207
+ "article_id": {
208
+ "N": "1"
209
+ },
210
+ "body": {
211
+ "S": "This is the first Stephen's comment to Ichiro's article."
212
+ },
213
+ "created_at": {
214
+ "S": "2020-03-08T08:22:47.683Z"
215
+ },
216
+ "updated_at": {
217
+ "S": "2020-03-08T08:22:47.683Z"
218
+ },
219
+ "printable_type": {
220
+ "S": "Comment"
221
+ }
222
+ }
223
+ },
224
+ "stored_notifier": {
225
+ "M": {
226
+ "id": {
227
+ "N": "2"
228
+ },
229
+ "email": {
230
+ "S": "stephen@example.com"
231
+ },
232
+ "name": {
233
+ "S": "Stephen"
234
+ },
235
+ "created_at": {
236
+ "S": "2020-03-08T08:22:23.573Z"
237
+ },
238
+ "updated_at": {
239
+ "S": "2020-03-08T08:22:23.573Z"
240
+ },
241
+ // { ... },
242
+ "printable_type": {
243
+ "S": "User"
244
+ },
245
+ "printable_notifier_name": {
246
+ "S": "Stephen"
247
+ }
248
+ }
249
+ },
250
+ "stored_group": {
251
+ "M": {
252
+ "id": {
253
+ "N": "1"
254
+ },
255
+ "user_id": {
256
+ "N": "1"
257
+ },
258
+ "title": {
259
+ "S": "Ichiro's first article"
260
+ },
261
+ "body": {
262
+ "S": "This is the first Ichiro's article. Please read it!"
263
+ },
264
+ "created_at": {
265
+ "S": "2020-03-08T08:22:23.952Z"
266
+ },
267
+ "updated_at": {
268
+ "S": "2020-03-08T08:22:23.952Z"
269
+ },
270
+ "printable_type": {
271
+ "S": "Article"
272
+ },
273
+ "printable_group_name": {
274
+ "S": "article \"Ichiro's first article\""
275
+ }
181
276
  }
277
+ },
278
+ "stored_notifiable_path": {
279
+ "S": "/articles/1"
280
+ },
281
+ "stored_printable_notifiable_name": {
282
+ "S": "comment \"This is the first Stephen's comment to Ichiro's article.\""
283
+ },
284
+ "stored_group_member_notifier_count": {
285
+ "N": "2"
286
+ },
287
+ "stored_group_notification_count": {
288
+ "N": "3"
289
+ },
290
+ "stored_group_members": {
291
+ "L": [
292
+ // { ... }, { ... }, ...
293
+ ]
294
+ }
182
295
  }
183
296
  ```
184
297
 
@@ -343,6 +456,20 @@ end
343
456
  Then, you can access several pages like */users/1/notifications* and manage open/unopen of notifications using *[ActivityNotification::NotificationsController](/app/controllers/activity_notification/notifications_controller.rb)*.
344
457
  If you use Devise integration and you want to configure simple default routes for authenticated users, see [Configuring simple default routes](#configuring-simple-default-routes).
345
458
 
459
+ #### Routes with namespaced model
460
+
461
+ It is possible to configure a target model as a submodule, e.g. if your target is `Entity::User`,
462
+ however by default the **ActivityNotification** controllers will be placed under the same namespace,
463
+ so it is mandatory to explicitly call the controllers this way
464
+
465
+ ```ruby
466
+ Rails.application.routes.draw do
467
+ notify_to :users, controller: '/activity_notification/notifications', target_type: 'entity/users'
468
+ end
469
+ ```
470
+
471
+ This will generate the necessary routes for the `Entity::User` target with parameters `:user_id`
472
+
346
473
  #### Routes with scope
347
474
 
348
475
  You can also configure *activity_notification* routes with scope like this: