activity_notification 1.7.0 → 1.7.1
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/.travis.yml +21 -50
- data/CHANGELOG.md +7 -0
- data/activity_notification.gemspec +2 -2
- data/lib/activity_notification/controllers/common_controller.rb +4 -4
- data/lib/activity_notification/models/concerns/notifiable.rb +4 -4
- data/lib/activity_notification/roles/acts_as_notifiable.rb +13 -1
- data/lib/activity_notification/version.rb +1 -1
- data/spec/roles/acts_as_notifiable_spec.rb +1 -0
- data/spec/spec_helper.rb +11 -4
- data/spec/support/patch_rails_42_action_controller_test_response.rb +11 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f16ad8322faabd5fec778b470437863df703dcf1
|
4
|
+
data.tar.gz: 87eb45c1c03c92836aa5a72b7b1e07cf2fb8548b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a34fa413bd90c2fb8228115bc7f76f12ddb0ca8c7d981f761b10692ec3aa1bd4239781bdd3001c33aa5ed4497e4b7f842d05a77fe3e86ccddaa347df9e8d05f
|
7
|
+
data.tar.gz: ae29b5111bbef97182cd0fdbeab616c332a53779e19cb940afe2300e7672591a7ebb490044b006f97447cdb662371aff46311b7274eefd0ab9923476a7414c87
|
data/.travis.yml
CHANGED
@@ -5,14 +5,12 @@ branches:
|
|
5
5
|
- images
|
6
6
|
|
7
7
|
rvm:
|
8
|
-
- 2.
|
9
|
-
- 2.
|
10
|
-
- 2.
|
11
|
-
- 2.
|
12
|
-
- ruby-head
|
8
|
+
- 2.6.3
|
9
|
+
# - 2.5.5
|
10
|
+
# - 2.4.6
|
11
|
+
# - 2.3.8
|
13
12
|
|
14
13
|
gemfile:
|
15
|
-
- Gemfile
|
16
14
|
- gemfiles/Gemfile.rails-4.2
|
17
15
|
- gemfiles/Gemfile.rails-5.0
|
18
16
|
- gemfiles/Gemfile.rails-5.1
|
@@ -20,51 +18,18 @@ gemfile:
|
|
20
18
|
|
21
19
|
env:
|
22
20
|
- AN_ORM=active_record
|
23
|
-
- AN_ORM=
|
21
|
+
- AN_ORM=active_record AN_TEST_DB=mysql
|
22
|
+
- AN_ORM=active_record AN_TEST_DB=postgresql
|
23
|
+
- AN_ORM=mongoid AN_TEST_DB=mongodb
|
24
24
|
|
25
25
|
matrix:
|
26
|
-
|
26
|
+
include:
|
27
27
|
- rvm: ruby-head
|
28
|
+
gemfile: Gemfile
|
29
|
+
env: AN_ORM=active_record
|
30
|
+
- rvm: ruby-head
|
31
|
+
gemfile: Gemfile
|
28
32
|
env: AN_ORM=mongoid
|
29
|
-
- gemfile: Gemfile
|
30
|
-
env: AN_ORM=mongoid
|
31
|
-
include:
|
32
|
-
- rvm: 2.5.1
|
33
|
-
gemfile: gemfiles/Gemfile.rails-4.2
|
34
|
-
env: AN_ORM=active_record AN_TEST_DB=mysql
|
35
|
-
- rvm: 2.5.1
|
36
|
-
gemfile: gemfiles/Gemfile.rails-4.2
|
37
|
-
env: AN_ORM=active_record AN_TEST_DB=postgresql
|
38
|
-
- rvm: 2.5.1
|
39
|
-
gemfile: gemfiles/Gemfile.rails-4.2
|
40
|
-
env: AN_ORM=mongoid AN_TEST_DB=mongodb
|
41
|
-
- rvm: 2.5.1
|
42
|
-
gemfile: gemfiles/Gemfile.rails-5.0
|
43
|
-
env: AN_ORM=active_record AN_TEST_DB=mysql
|
44
|
-
- rvm: 2.5.1
|
45
|
-
gemfile: gemfiles/Gemfile.rails-5.0
|
46
|
-
env: AN_ORM=active_record AN_TEST_DB=postgresql
|
47
|
-
- rvm: 2.5.1
|
48
|
-
gemfile: gemfiles/Gemfile.rails-5.0
|
49
|
-
env: AN_ORM=mongoid AN_TEST_DB=mongodb
|
50
|
-
- rvm: 2.5.1
|
51
|
-
gemfile: gemfiles/Gemfile.rails-5.1
|
52
|
-
env: AN_ORM=active_record AN_TEST_DB=mysql
|
53
|
-
- rvm: 2.5.1
|
54
|
-
gemfile: gemfiles/Gemfile.rails-5.1
|
55
|
-
env: AN_ORM=active_record AN_TEST_DB=postgresql
|
56
|
-
- rvm: 2.5.1
|
57
|
-
gemfile: gemfiles/Gemfile.rails-5.1
|
58
|
-
env: AN_ORM=mongoid AN_TEST_DB=mongodb
|
59
|
-
- rvm: 2.5.1
|
60
|
-
gemfile: gemfiles/Gemfile.rails-5.2
|
61
|
-
env: AN_ORM=active_record AN_TEST_DB=mysql
|
62
|
-
- rvm: 2.5.1
|
63
|
-
gemfile: gemfiles/Gemfile.rails-5.2
|
64
|
-
env: AN_ORM=active_record AN_TEST_DB=postgresql
|
65
|
-
- rvm: 2.5.1
|
66
|
-
gemfile: gemfiles/Gemfile.rails-5.2
|
67
|
-
env: AN_ORM=mongoid AN_TEST_DB=mongodb
|
68
33
|
allow_failures:
|
69
34
|
- rvm: ruby-head
|
70
35
|
fast_finish: true
|
@@ -77,14 +42,20 @@ sudo: false
|
|
77
42
|
cache: bundler
|
78
43
|
|
79
44
|
before_install:
|
80
|
-
|
45
|
+
# Specify bundler version as '< 2.0' for Rails 4.2
|
46
|
+
- gem install bundler --no-document -v '1.17.3'
|
47
|
+
|
48
|
+
install:
|
49
|
+
# Specify bundler version as '< 2.0' for Rails 4.2
|
50
|
+
- bundle _1.17.3_ install
|
81
51
|
|
82
52
|
before_script:
|
83
|
-
|
53
|
+
# Specify bundler version as '< 2.0' for Rails 4.2
|
54
|
+
- bundle _1.17.3_ update
|
84
55
|
- mysql -e 'create database activity_notification_test'
|
85
56
|
- psql -c 'create database activity_notification_test' -U postgres
|
86
57
|
|
87
58
|
script: bundle exec rspec
|
88
59
|
|
89
60
|
notifications:
|
90
|
-
email: true
|
61
|
+
email: true
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## 1.7.0 / 2019-04-30
|
2
|
+
[Full Changelog](http://github.com/simukappu/activity_notification/compare/v1.7.0...v1.7.1)
|
3
|
+
|
4
|
+
Enhancements:
|
5
|
+
|
6
|
+
* Use after_commit for tracked callbacks instead of after_create and after_update - [#99](https://github.com/simukappu/activity_notification/issues/99)
|
7
|
+
|
1
8
|
## 1.7.0 / 2018-12-09
|
2
9
|
[Full Changelog](http://github.com/simukappu/activity_notification/compare/v1.6.1...v1.7.0)
|
3
10
|
|
@@ -24,12 +24,12 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.add_dependency 'i18n', '>= 0.5.0'
|
25
25
|
s.add_dependency 'jquery-rails', '>= 3.1.1'
|
26
26
|
|
27
|
-
s.add_development_dependency 'sqlite3', '>= 1.3.13'
|
27
|
+
s.add_development_dependency 'sqlite3', '>= 1.3.13', '< 1.4.0'
|
28
28
|
s.add_development_dependency 'mysql2', '>= 0.5.2'
|
29
29
|
s.add_development_dependency 'pg', '>= 1.0.0'
|
30
30
|
s.add_development_dependency 'mongoid', '>= 4.0.0', '< 7.0.0'
|
31
31
|
s.add_development_dependency 'rspec-rails', '>= 3.8.0'
|
32
|
-
s.add_development_dependency 'factory_bot_rails', '>= 4.11.0'
|
32
|
+
s.add_development_dependency 'factory_bot_rails', '>= 4.11.0', '< 5.0.0'
|
33
33
|
s.add_development_dependency 'simplecov', '~> 0'
|
34
34
|
s.add_development_dependency 'yard', '>= 0.9.16'
|
35
35
|
s.add_development_dependency 'yard-activesupport-concern', '>= 0.0.1'
|
@@ -101,17 +101,17 @@ module ActivityNotification
|
|
101
101
|
# @api protected
|
102
102
|
# @return [Boolean] True
|
103
103
|
def compatibly_redirect_back(request_params = {})
|
104
|
-
# :
|
104
|
+
# :only-rails5+:
|
105
105
|
if Rails::VERSION::MAJOR >= 5
|
106
106
|
redirect_back fallback_location: { action: :index }, **request_params
|
107
|
-
# :
|
108
|
-
# :
|
107
|
+
# :only-rails5+:
|
108
|
+
# :except-rails5+:
|
109
109
|
elsif request.referer
|
110
110
|
redirect_to :back, **request_params
|
111
111
|
else
|
112
112
|
redirect_to action: :index, **request_params
|
113
113
|
end
|
114
|
-
# :
|
114
|
+
# :except-rails5+:
|
115
115
|
true
|
116
116
|
end
|
117
117
|
end
|
@@ -424,15 +424,15 @@ module ActivityNotification
|
|
424
424
|
unless generated_notifications.empty?
|
425
425
|
record = self.class.human_attribute_name("generated_notifications_as_notifiable_for_#{target_type.to_s.pluralize.underscore}").downcase
|
426
426
|
self.errors.add(:base, :'restrict_dependent_destroy.has_many', record: record)
|
427
|
-
# :
|
427
|
+
# :only-rails5+:
|
428
428
|
if Rails::VERSION::MAJOR >= 5
|
429
429
|
throw(:abort)
|
430
|
-
# :
|
431
|
-
# :
|
430
|
+
# :only-rails5+:
|
431
|
+
# :except-rails5+:
|
432
432
|
else
|
433
433
|
false
|
434
434
|
end
|
435
|
-
# :
|
435
|
+
# :except-rails5+:
|
436
436
|
end
|
437
437
|
when :destroy
|
438
438
|
generated_notifications.each { |n| n.destroy }
|
@@ -278,7 +278,18 @@ module ActivityNotification
|
|
278
278
|
# @param [Symbol] tracked_action Tracked action (:create or :update)
|
279
279
|
# @param [Proc] tracked_proc Proc or lambda function to execute
|
280
280
|
def add_tracked_callback(tracked_callbacks, tracked_action, tracked_proc)
|
281
|
-
|
281
|
+
return unless tracked_callbacks.include? tracked_action
|
282
|
+
|
283
|
+
# FIXME: Avoid Rails issue that after commit callbacks on update does not triggered when optimistic locking is enabled
|
284
|
+
# See the followings:
|
285
|
+
# https://github.com/rails/rails/issues/30779
|
286
|
+
# https://github.com/rails/rails/pull/32167
|
287
|
+
# :only-rails-without-callback-issue:
|
288
|
+
if !(Gem::Version.new("5.1.6") <= Rails.gem_version && Rails.gem_version < Gem::Version.new("5.2.2")) && respond_to?(:after_commit)
|
289
|
+
after_commit tracked_proc, on: tracked_action
|
290
|
+
# :only-rails-without-callback-issue:
|
291
|
+
# :only-rails-with-callback-issue:
|
292
|
+
else
|
282
293
|
case tracked_action
|
283
294
|
when :create
|
284
295
|
after_create tracked_proc
|
@@ -286,6 +297,7 @@ module ActivityNotification
|
|
286
297
|
after_update tracked_proc
|
287
298
|
end
|
288
299
|
end
|
300
|
+
# :only-rails-with-callback-issue:
|
289
301
|
end
|
290
302
|
|
291
303
|
# Adds destroy dependency.
|
@@ -12,6 +12,7 @@ describe ActivityNotification::ActsAsNotifiable do
|
|
12
12
|
dummy_notifiable_class.reset_callbacks :create
|
13
13
|
dummy_notifiable_class.reset_callbacks :update
|
14
14
|
dummy_notifiable_class.reset_callbacks :destroy
|
15
|
+
dummy_notifiable_class.reset_callbacks :commit if dummy_notifiable_class.respond_to? :after_commit
|
15
16
|
@notifiable = dummy_notifiable_class.create
|
16
17
|
end
|
17
18
|
|
data/spec/spec_helper.rb
CHANGED
@@ -15,10 +15,15 @@ SimpleCov.start('rails') do
|
|
15
15
|
add_filter '/spec/'
|
16
16
|
add_filter '/lib/generators/templates/'
|
17
17
|
add_filter '/lib/activity_notification/version.rb'
|
18
|
-
if Rails::VERSION::MAJOR
|
19
|
-
nocov_token '
|
20
|
-
|
21
|
-
nocov_token '
|
18
|
+
if Rails::VERSION::MAJOR >= 5
|
19
|
+
nocov_token 'except-rails5+'
|
20
|
+
else
|
21
|
+
nocov_token 'only-rails5+'
|
22
|
+
end
|
23
|
+
if Gem::Version.new("5.1.6") <= Rails.gem_version && Rails.gem_version < Gem::Version.new("5.2.2")
|
24
|
+
nocov_token 'only-rails-without-callback-issue'
|
25
|
+
else
|
26
|
+
nocov_token 'only-rails-with-callback-issue'
|
22
27
|
end
|
23
28
|
if ENV['AN_ORM'] == 'mongoid'
|
24
29
|
add_filter '/lib/activity_notification/orm/active_record'
|
@@ -37,6 +42,8 @@ require 'ammeter/init'
|
|
37
42
|
require 'factory_bot_rails'
|
38
43
|
require 'activity_notification'
|
39
44
|
|
45
|
+
Dir[Rails.root.join("../../spec/support/**/*.rb")].each { |file| require file }
|
46
|
+
|
40
47
|
def clear_database
|
41
48
|
[ActivityNotification::Notification, ActivityNotification::Subscription, Comment, Article, Admin, User].each do |model_class|
|
42
49
|
model_class.delete_all
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# Rails 4.2 call `initialize` inside `recycle!`. However Ruby 2.6 doesn't allow calling `initialize` twice.
|
2
|
+
# See for detail: https://github.com/rails/rails/issues/34790
|
3
|
+
if RUBY_VERSION.to_f >= 2.6 && Rails::VERSION::MAJOR < 5
|
4
|
+
class ActionController::TestResponse < ActionDispatch::TestResponse
|
5
|
+
def recycle!
|
6
|
+
@mon_mutex_owner_object_id = nil
|
7
|
+
@mon_mutex = nil
|
8
|
+
initialize
|
9
|
+
end
|
10
|
+
end
|
11
|
+
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: 1.7.
|
4
|
+
version: 1.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shota Yamazaki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -65,6 +65,9 @@ dependencies:
|
|
65
65
|
- - ">="
|
66
66
|
- !ruby/object:Gem::Version
|
67
67
|
version: 1.3.13
|
68
|
+
- - "<"
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 1.4.0
|
68
71
|
type: :development
|
69
72
|
prerelease: false
|
70
73
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -72,6 +75,9 @@ dependencies:
|
|
72
75
|
- - ">="
|
73
76
|
- !ruby/object:Gem::Version
|
74
77
|
version: 1.3.13
|
78
|
+
- - "<"
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 1.4.0
|
75
81
|
- !ruby/object:Gem::Dependency
|
76
82
|
name: mysql2
|
77
83
|
requirement: !ruby/object:Gem::Requirement
|
@@ -141,6 +147,9 @@ dependencies:
|
|
141
147
|
- - ">="
|
142
148
|
- !ruby/object:Gem::Version
|
143
149
|
version: 4.11.0
|
150
|
+
- - "<"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 5.0.0
|
144
153
|
type: :development
|
145
154
|
prerelease: false
|
146
155
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -148,6 +157,9 @@ dependencies:
|
|
148
157
|
- - ">="
|
149
158
|
- !ruby/object:Gem::Version
|
150
159
|
version: 4.11.0
|
160
|
+
- - "<"
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: 5.0.0
|
151
163
|
- !ruby/object:Gem::Dependency
|
152
164
|
name: simplecov
|
153
165
|
requirement: !ruby/object:Gem::Requirement
|
@@ -485,6 +497,7 @@ files:
|
|
485
497
|
- spec/roles/acts_as_notifier_spec.rb
|
486
498
|
- spec/roles/acts_as_target_spec.rb
|
487
499
|
- spec/spec_helper.rb
|
500
|
+
- spec/support/patch_rails_42_action_controller_test_response.rb
|
488
501
|
homepage: https://github.com/simukappu/activity_notification
|
489
502
|
licenses:
|
490
503
|
- MIT
|
@@ -645,3 +658,4 @@ test_files:
|
|
645
658
|
- spec/roles/acts_as_notifier_spec.rb
|
646
659
|
- spec/roles/acts_as_target_spec.rb
|
647
660
|
- spec/spec_helper.rb
|
661
|
+
- spec/support/patch_rails_42_action_controller_test_response.rb
|