activity_notification 2.1.4 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -16
- data/CHANGELOG.md +14 -0
- data/README.md +1 -1
- data/activity_notification.gemspec +1 -1
- data/app/controllers/activity_notification/notifications_controller.rb +0 -20
- data/bin/bundle_update.sh +0 -1
- data/lib/activity_notification/common.rb +11 -3
- data/lib/activity_notification/controllers/common_controller.rb +1 -17
- data/lib/activity_notification/models/concerns/notifiable.rb +1 -1
- data/lib/activity_notification/models/concerns/target.rb +5 -9
- data/lib/activity_notification/orm/active_record.rb +1 -1
- data/lib/activity_notification/orm/active_record/notification.rb +3 -3
- data/lib/activity_notification/orm/dynamoid/notification.rb +1 -1
- data/lib/activity_notification/orm/mongoid/notification.rb +1 -1
- data/lib/activity_notification/renderable.rb +2 -2
- data/lib/activity_notification/roles/acts_as_notifiable.rb +11 -15
- data/lib/activity_notification/version.rb +1 -1
- data/lib/generators/templates/migrations/migration.rb +1 -1
- data/spec/channels/notification_api_channel_spec.rb +42 -44
- data/spec/channels/notification_api_with_devise_channel_spec.rb +57 -59
- data/spec/channels/notification_channel_spec.rb +41 -43
- data/spec/channels/notification_with_devise_channel_spec.rb +75 -77
- data/spec/concerns/common_spec.rb +25 -3
- data/spec/concerns/models/target_spec.rb +10 -12
- data/spec/concerns/renderable_spec.rb +5 -5
- data/spec/controllers/controller_spec_utility.rb +15 -51
- data/spec/generators/migration/migration_generator_spec.rb +2 -10
- data/spec/helpers/view_helpers_spec.rb +1 -1
- data/spec/optional_targets/action_cable_api_channel_spec.rb +21 -24
- data/spec/optional_targets/action_cable_channel_spec.rb +26 -29
- data/spec/rails_app/config/application.rb +2 -6
- data/spec/rails_app/config/environments/test.rb +2 -11
- data/spec/spec_helper.rb +1 -5
- metadata +5 -8
- data/gemfiles/Gemfile.rails-4.2 +0 -24
- data/spec/support/patch_rails_42_action_controller_test_response.rb +0 -11
@@ -31,11 +31,7 @@ describe ActivityNotification::Generators::MigrationGenerator, type: :generator
|
|
31
31
|
describe 'CreateNotifications migration file' do
|
32
32
|
subject { file(Dir["tmp/db/migrate/*_create_activity_notification_tables.rb"].first.gsub!('tmp/', '')) }
|
33
33
|
it { is_expected.to exist }
|
34
|
-
|
35
|
-
it { is_expected.to contain(/class CreateActivityNotificationTables < ActiveRecord::Migration\[\d\.\d\]/) }
|
36
|
-
else
|
37
|
-
it { is_expected.to contain(/class CreateActivityNotificationTables < ActiveRecord::Migration/) }
|
38
|
-
end
|
34
|
+
it { is_expected.to contain(/class CreateActivityNotificationTables < ActiveRecord::Migration\[\d\.\d\]/) }
|
39
35
|
|
40
36
|
if ActivityNotification.config.orm == :active_record
|
41
37
|
it 'can be executed to migrate scheme' do
|
@@ -55,11 +51,7 @@ describe ActivityNotification::Generators::MigrationGenerator, type: :generator
|
|
55
51
|
describe 'CreateCustomNotifications migration file' do
|
56
52
|
subject { file(Dir["tmp/db/migrate/*_create_custom_notifications.rb"].first.gsub!('tmp/', '')) }
|
57
53
|
it { is_expected.to exist }
|
58
|
-
|
59
|
-
it { is_expected.to contain(/class CreateCustomNotifications < ActiveRecord::Migration\[\d\.\d\]/) }
|
60
|
-
else
|
61
|
-
it { is_expected.to contain(/class CreateCustomNotifications < ActiveRecord::Migration/) }
|
62
|
-
end
|
54
|
+
it { is_expected.to contain(/class CreateCustomNotifications < ActiveRecord::Migration\[\d\.\d\]/) }
|
63
55
|
|
64
56
|
if ActivityNotification.config.orm == :active_record
|
65
57
|
it 'can be executed to migrate scheme' do
|
@@ -1,5 +1,5 @@
|
|
1
1
|
describe ActivityNotification::ViewHelpers, type: :helper do
|
2
|
-
let(:view_context) { ActionView::Base.new }
|
2
|
+
let(:view_context) { ActionView::Base.new(ActionView::LookupContext.new(ActionController::Base.view_paths)) }
|
3
3
|
let(:notification) {
|
4
4
|
create(:notification, target: create(:confirmed_user))
|
5
5
|
}
|
@@ -1,37 +1,34 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
let(:test_instance) { ActivityNotification::OptionalTarget::ActionCableApiChannel.new(skip_initializing_target: true) }
|
1
|
+
require 'activity_notification/optional_targets/action_cable_api_channel'
|
2
|
+
describe ActivityNotification::OptionalTarget::ActionCableApiChannel do
|
3
|
+
let(:test_instance) { ActivityNotification::OptionalTarget::ActionCableApiChannel.new(skip_initializing_target: true) }
|
5
4
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
end
|
5
|
+
describe "as public instance methods" do
|
6
|
+
describe "#to_optional_target_name" do
|
7
|
+
it "is return demodulized symbol class name" do
|
8
|
+
expect(test_instance.to_optional_target_name).to eq(:action_cable_api_channel)
|
11
9
|
end
|
10
|
+
end
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
12
|
+
describe "#initialize_target" do
|
13
|
+
it "does not raise NotImplementedError" do
|
14
|
+
test_instance.initialize_target
|
17
15
|
end
|
16
|
+
end
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
18
|
+
describe "#notify" do
|
19
|
+
it "does not raise NotImplementedError" do
|
20
|
+
test_instance.notify(create(:notification))
|
23
21
|
end
|
24
22
|
end
|
23
|
+
end
|
25
24
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
25
|
+
describe "as protected instance methods" do
|
26
|
+
describe "#render_notification_message" do
|
27
|
+
context "as default" do
|
28
|
+
it "renders notification message as formatted JSON" do
|
29
|
+
expect(test_instance.send(:render_notification_message, create(:notification)).with_indifferent_access[:notification].has_key?(:id)).to be_truthy
|
32
30
|
end
|
33
31
|
end
|
34
32
|
end
|
35
|
-
|
36
33
|
end
|
37
34
|
end
|
@@ -1,44 +1,41 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
let(:test_instance) { ActivityNotification::OptionalTarget::ActionCableChannel.new(skip_initializing_target: true) }
|
1
|
+
require 'activity_notification/optional_targets/action_cable_channel'
|
2
|
+
describe ActivityNotification::OptionalTarget::ActionCableChannel do
|
3
|
+
let(:test_instance) { ActivityNotification::OptionalTarget::ActionCableChannel.new(skip_initializing_target: true) }
|
5
4
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
end
|
5
|
+
describe "as public instance methods" do
|
6
|
+
describe "#to_optional_target_name" do
|
7
|
+
it "is return demodulized symbol class name" do
|
8
|
+
expect(test_instance.to_optional_target_name).to eq(:action_cable_channel)
|
11
9
|
end
|
10
|
+
end
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
12
|
+
describe "#initialize_target" do
|
13
|
+
it "does not raise NotImplementedError" do
|
14
|
+
test_instance.initialize_target
|
17
15
|
end
|
16
|
+
end
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
18
|
+
describe "#notify" do
|
19
|
+
it "does not raise NotImplementedError" do
|
20
|
+
test_instance.notify(create(:notification))
|
23
21
|
end
|
24
22
|
end
|
23
|
+
end
|
25
24
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
25
|
+
describe "as protected instance methods" do
|
26
|
+
describe "#render_notification_message" do
|
27
|
+
context "as default" do
|
28
|
+
it "renders notification message with default template" do
|
29
|
+
expect(test_instance.send(:render_notification_message, create(:notification))).to be_include("<div class='notification_list")
|
32
30
|
end
|
31
|
+
end
|
33
32
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
33
|
+
context "with unexisting template as fallback option" do
|
34
|
+
it "raise ActionView::MissingTemplate" do
|
35
|
+
expect { expect(test_instance.send(:render_notification_message, create(:notification), fallback: :hoge)) }
|
36
|
+
.to raise_error(ActionView::MissingTemplate)
|
39
37
|
end
|
40
38
|
end
|
41
39
|
end
|
42
|
-
|
43
40
|
end
|
44
41
|
end
|
@@ -24,18 +24,14 @@ require "action_controller/railtie"
|
|
24
24
|
require "action_mailer/railtie"
|
25
25
|
require "action_view/railtie"
|
26
26
|
require "sprockets/railtie"
|
27
|
-
require 'action_cable/engine'
|
27
|
+
require 'action_cable/engine'
|
28
28
|
|
29
29
|
Bundler.require(*Rails.groups)
|
30
30
|
require "activity_notification"
|
31
31
|
|
32
32
|
module Dummy
|
33
33
|
class Application < Rails::Application
|
34
|
-
|
35
|
-
if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2 && ENV['AN_TEST_DB'] != 'mongodb'
|
36
|
-
config.active_record.raise_in_transactional_callbacks = true
|
37
|
-
end
|
38
|
-
if Rails::VERSION::MAJOR >= 5 && Rails::VERSION::MINOR >= 2 && ENV['AN_TEST_DB'] != 'mongodb'
|
34
|
+
if Gem::Version.new("5.2.0") <= Rails.gem_version && Rails.gem_version < Gem::Version.new("6.0.0") && ENV['AN_TEST_DB'] != 'mongodb'
|
39
35
|
config.active_record.sqlite3.represent_boolean_as_integer = true
|
40
36
|
end
|
41
37
|
|
@@ -13,17 +13,8 @@ Rails.application.configure do
|
|
13
13
|
config.eager_load = false
|
14
14
|
|
15
15
|
# Configure static file server for tests with Cache-Control for performance.
|
16
|
-
|
17
|
-
|
18
|
-
else
|
19
|
-
config.serve_static_files = true
|
20
|
-
end
|
21
|
-
|
22
|
-
if Rails::VERSION::MAJOR >= 5
|
23
|
-
config.public_file_server.headers = {'Cache-Control' => 'public, max-age=3600'}
|
24
|
-
else
|
25
|
-
config.static_cache_control = "public, max-age=3600"
|
26
|
-
end
|
16
|
+
config.public_file_server.enabled = true
|
17
|
+
config.public_file_server.headers = {'Cache-Control' => 'public, max-age=3600'}
|
27
18
|
|
28
19
|
# Show full error reports and disable caching.
|
29
20
|
config.consider_all_requests_local = true
|
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
ENV["RAILS_ENV"] ||= "test"
|
2
|
+
Warning[:deprecated] = true if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.7.2")
|
2
3
|
|
3
4
|
require 'bundler/setup'
|
4
5
|
Bundler.setup
|
@@ -25,11 +26,6 @@ SimpleCov.start('rails') do
|
|
25
26
|
add_filter '/lib/activity_notification/orm/mongoid'
|
26
27
|
add_filter '/lib/activity_notification/orm/dynamoid'
|
27
28
|
end
|
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
|
33
29
|
end
|
34
30
|
|
35
31
|
# Dummy application
|
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.
|
4
|
+
version: 2.2.0
|
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-
|
11
|
+
date: 2020-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 5.0.0
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '6.1'
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 5.0.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '6.1'
|
@@ -385,7 +385,6 @@ files:
|
|
385
385
|
- docs/Functions.md
|
386
386
|
- docs/Setup.md
|
387
387
|
- docs/Testing.md
|
388
|
-
- gemfiles/Gemfile.rails-4.2
|
389
388
|
- gemfiles/Gemfile.rails-5.0
|
390
389
|
- gemfiles/Gemfile.rails-5.1
|
391
390
|
- gemfiles/Gemfile.rails-5.2
|
@@ -662,7 +661,6 @@ files:
|
|
662
661
|
- spec/roles/acts_as_notifier_spec.rb
|
663
662
|
- spec/roles/acts_as_target_spec.rb
|
664
663
|
- spec/spec_helper.rb
|
665
|
-
- spec/support/patch_rails_42_action_controller_test_response.rb
|
666
664
|
- spec/version_spec.rb
|
667
665
|
homepage: https://github.com/simukappu/activity_notification
|
668
666
|
licenses:
|
@@ -683,7 +681,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
683
681
|
- !ruby/object:Gem::Version
|
684
682
|
version: '0'
|
685
683
|
requirements: []
|
686
|
-
rubygems_version: 3.
|
684
|
+
rubygems_version: 3.1.4
|
687
685
|
signing_key:
|
688
686
|
specification_version: 4
|
689
687
|
summary: Integrated user activity notifications for Ruby on Rails
|
@@ -882,5 +880,4 @@ test_files:
|
|
882
880
|
- spec/roles/acts_as_notifier_spec.rb
|
883
881
|
- spec/roles/acts_as_target_spec.rb
|
884
882
|
- spec/spec_helper.rb
|
885
|
-
- spec/support/patch_rails_42_action_controller_test_response.rb
|
886
883
|
- spec/version_spec.rb
|
data/gemfiles/Gemfile.rails-4.2
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
gemspec path: '../'
|
4
|
-
|
5
|
-
gem 'rails', '~> 4.2.0'
|
6
|
-
gem 'sqlite3', '~> 1.3.13'
|
7
|
-
gem 'mysql2', '~> 0.4.10'
|
8
|
-
gem 'pg', '~> 0.21.0'
|
9
|
-
|
10
|
-
group :development do
|
11
|
-
gem 'bullet'
|
12
|
-
gem 'rack-cors'
|
13
|
-
end
|
14
|
-
|
15
|
-
group :test do
|
16
|
-
gem 'ammeter'
|
17
|
-
gem 'timecop'
|
18
|
-
gem 'committee'
|
19
|
-
gem 'committee-rails'
|
20
|
-
# gem 'coveralls', require: false
|
21
|
-
gem 'coveralls_reborn', require: false
|
22
|
-
end
|
23
|
-
|
24
|
-
gem 'dotenv-rails', groups: [:development, :test]
|
@@ -1,11 +0,0 @@
|
|
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
|