activity_notification 2.1.2 → 2.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f21c6ee444304e1291b2f032fe3d8bc485741a89c73123b781ba6f69a883c3d9
4
- data.tar.gz: 6b80e107e1c256c8fa4acdbe08ba7b62d96b9b6d61f0f912186aac73db720535
3
+ metadata.gz: 9a517c56b317fe1705d3666039793aee93ed55c77c2493b70018eb1da4268f97
4
+ data.tar.gz: ba26afa004950dc8ec175abb6f36a948014f3ff7be81b8d185665f25f22137fe
5
5
  SHA512:
6
- metadata.gz: 1d4a6f4da5491d589d7f0b4433323f270465e35edd758122b5e58fcd30a30e9cada9cc7a5b129246ba114b755940dea5e6550d7e5b7d00ff23d8673bbceafbcf
7
- data.tar.gz: f240f26d35c835babf447d4b22d2b7acdb1853970a2b50967e9fc3131ec52f73a6dfad86875dc191d69c4993bdca41133dc0005ffcc7f1e6ca8c995ab003d912
6
+ metadata.gz: 88b587552a4c2e1bfeda92759b44f7611309409b3bfb11c7a777739a30e3af4f28f96d532b39c42edfed0b07de274239014d6d117590f51dc1ac09fc8898e8de
7
+ data.tar.gz: c9e40bf9e14e6c5c0f4898161748e2ab07e9b1e95c8fbb2daaf151a5d94bab9727280f840216c7375819aac2f6564659d9fa9b05ce8a320dd2e3c7b42269acb3
@@ -1,3 +1,14 @@
1
+ ## 2.1.3 / 2020-08-1
2
+ [Full Changelog](http://github.com/simukappu/activity_notification/compare/v2.1.2...v2.1.3)
3
+
4
+ Enhancements:
5
+
6
+ * Enable to use namespaced model - [#132](https://github.com/simukappu/activity_notification/pull/132)
7
+
8
+ Bug Fixes:
9
+
10
+ * Fix mongoid any_of selector error in filtered_by_group scope - [MONGOID-4887](https://jira.mongodb.org/browse/MONGOID-4887)
11
+
1
12
  ## 2.1.2 / 2020-02-24
2
13
  [Full Changelog](http://github.com/simukappu/activity_notification/compare/v2.1.1...v2.1.2)
3
14
 
data/Gemfile CHANGED
@@ -23,7 +23,8 @@ group :test do
23
23
  gem 'timecop'
24
24
  gem 'committee'
25
25
  gem 'committee-rails'
26
- gem 'coveralls', require: false
26
+ # gem 'coveralls', require: false
27
+ gem 'coveralls_reborn', require: false
27
28
  end
28
29
 
29
30
  gem 'webpacker', groups: [:production, :development]
@@ -31,7 +31,7 @@ Gem::Specification.new do |s|
31
31
  s.add_development_dependency 'pg', '>= 1.0.0'
32
32
  s.add_development_dependency 'mongoid', '>= 4.0.0'
33
33
  s.add_development_dependency 'dynamoid', '3.1.0'
34
- s.add_development_dependency 'rspec-rails', '>= 3.8.0'
34
+ s.add_development_dependency 'rspec-rails', '>= 3.8.0', '< 4.0.0'
35
35
  s.add_development_dependency 'factory_bot_rails', '>= 4.11.0', '< 5.0.0'
36
36
  s.add_development_dependency 'simplecov', '~> 0'
37
37
  s.add_development_dependency 'yard', '>= 0.9.16'
@@ -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)
@@ -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.
@@ -343,6 +343,20 @@ end
343
343
  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
344
  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
345
 
346
+ #### Routes with namespaced model
347
+
348
+ It is possible to configure a target model as a submodule, e.g. if your target is `Entity::User`,
349
+ however by default the **ActivityNotification** controllers will be placed under the same namespace,
350
+ so it is mandatory to explicitly call the controllers this way
351
+
352
+ ```ruby
353
+ Rails.application.routes.draw do
354
+ notify_to :users, controller: '/activity_notification/notifications', target_type: 'entity/users'
355
+ end
356
+ ```
357
+
358
+ This will generate the necessary routes for the `Entity::User` target with parameters `:user_id`
359
+
346
360
  #### Routes with scope
347
361
 
348
362
  You can also configure *activity_notification* routes with scope like this:
@@ -17,7 +17,8 @@ group :test do
17
17
  gem 'timecop'
18
18
  gem 'committee'
19
19
  gem 'committee-rails'
20
- gem 'coveralls', require: false
20
+ # gem 'coveralls', require: false
21
+ gem 'coveralls_reborn', require: false
21
22
  end
22
23
 
23
24
  gem 'dotenv-rails', groups: [:development, :test]
@@ -17,7 +17,8 @@ group :test do
17
17
  gem 'timecop'
18
18
  gem 'committee'
19
19
  gem 'committee-rails'
20
- gem 'coveralls', require: false
20
+ # gem 'coveralls', require: false
21
+ gem 'coveralls_reborn', require: false
21
22
  end
22
23
 
23
24
  gem 'dotenv-rails', groups: [:development, :test]
@@ -16,7 +16,8 @@ group :test do
16
16
  gem 'timecop'
17
17
  gem 'committee'
18
18
  gem 'committee-rails'
19
- gem 'coveralls', require: false
19
+ # gem 'coveralls', require: false
20
+ gem 'coveralls_reborn', require: false
20
21
  end
21
22
 
22
23
  gem 'dotenv-rails', groups: [:development, :test]
@@ -16,7 +16,8 @@ group :test do
16
16
  gem 'timecop'
17
17
  gem 'committee'
18
18
  gem 'committee-rails'
19
- gem 'coveralls', require: false
19
+ # gem 'coveralls', require: false
20
+ gem 'coveralls_reborn', require: false
20
21
  end
21
22
 
22
23
  gem 'dotenv-rails', groups: [:development, :test]
@@ -17,7 +17,8 @@ group :test do
17
17
  gem 'timecop'
18
18
  gem 'committee'
19
19
  gem 'committee-rails'
20
- gem 'coveralls', require: false
20
+ # gem 'coveralls', require: false
21
+ gem 'coveralls_reborn', require: false
21
22
  end
22
23
 
23
24
  gem 'dotenv-rails', groups: [:development, :test]
@@ -26,7 +26,7 @@ module ActivityNotification
26
26
  target_class = target_type.to_model_class
27
27
  @target = params[:target_id].present? ?
28
28
  target_class.find_by!(id: params[:target_id]) :
29
- target_class.find_by!(id: params["#{target_type.to_resource_name}_id"])
29
+ target_class.find_by!(id: params["#{target_type.to_resource_name[/([^\/]+)$/]}_id"])
30
30
  else
31
31
  render status: 400, json: error_response(code: 400, message: "Invalid parameter", type: "Parameter is missing or the value is empty: target_type")
32
32
  end
@@ -482,7 +482,7 @@ module ActivityNotification
482
482
  # Casts to symbol of resources name.
483
483
  # @api private
484
484
  def cast_to_resources_sym(target_type)
485
- target_type.to_s.to_resources_name.to_sym
485
+ cast_to_resources_name(target_type).to_sym
486
486
  end
487
487
  end
488
488
  end
@@ -140,7 +140,9 @@ module ActivityNotification
140
140
  scope :filtered_by_group, ->(group) {
141
141
  group.present? ?
142
142
  where(group_id: group.id, group_type: group.class.name) :
143
- any_of({ :group_id.exists => false, :group_type.exists => false }, { group_id: nil, group_type: nil })
143
+ Gem::Version.new(::Mongoid::VERSION) >= Gem::Version.new('7.1.0') ?
144
+ where(:group_id.exists => false, :group_type.exists => false).or(group_id: nil, group_type: nil) :
145
+ any_of({ :group_id.exists => false, :group_type.exists => false }, { group_id: nil, group_type: nil })
144
146
  }
145
147
 
146
148
  # Selects filtered notifications later than specified time.
@@ -1,3 +1,3 @@
1
1
  module ActivityNotification
2
- VERSION = "2.1.2"
2
+ VERSION = "2.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activity_notification
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 2.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shota Yamazaki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-24 00:00:00.000000000 Z
11
+ date: 2020-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -163,6 +163,9 @@ dependencies:
163
163
  - - ">="
164
164
  - !ruby/object:Gem::Version
165
165
  version: 3.8.0
166
+ - - "<"
167
+ - !ruby/object:Gem::Version
168
+ version: 4.0.0
166
169
  type: :development
167
170
  prerelease: false
168
171
  version_requirements: !ruby/object:Gem::Requirement
@@ -170,6 +173,9 @@ dependencies:
170
173
  - - ">="
171
174
  - !ruby/object:Gem::Version
172
175
  version: 3.8.0
176
+ - - "<"
177
+ - !ruby/object:Gem::Version
178
+ version: 4.0.0
173
179
  - !ruby/object:Gem::Dependency
174
180
  name: factory_bot_rails
175
181
  requirement: !ruby/object:Gem::Requirement