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.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +6 -16
  3. data/CHANGELOG.md +14 -0
  4. data/README.md +1 -1
  5. data/activity_notification.gemspec +1 -1
  6. data/app/controllers/activity_notification/notifications_controller.rb +0 -20
  7. data/bin/bundle_update.sh +0 -1
  8. data/lib/activity_notification/common.rb +11 -3
  9. data/lib/activity_notification/controllers/common_controller.rb +1 -17
  10. data/lib/activity_notification/models/concerns/notifiable.rb +1 -1
  11. data/lib/activity_notification/models/concerns/target.rb +5 -9
  12. data/lib/activity_notification/orm/active_record.rb +1 -1
  13. data/lib/activity_notification/orm/active_record/notification.rb +3 -3
  14. data/lib/activity_notification/orm/dynamoid/notification.rb +1 -1
  15. data/lib/activity_notification/orm/mongoid/notification.rb +1 -1
  16. data/lib/activity_notification/renderable.rb +2 -2
  17. data/lib/activity_notification/roles/acts_as_notifiable.rb +11 -15
  18. data/lib/activity_notification/version.rb +1 -1
  19. data/lib/generators/templates/migrations/migration.rb +1 -1
  20. data/spec/channels/notification_api_channel_spec.rb +42 -44
  21. data/spec/channels/notification_api_with_devise_channel_spec.rb +57 -59
  22. data/spec/channels/notification_channel_spec.rb +41 -43
  23. data/spec/channels/notification_with_devise_channel_spec.rb +75 -77
  24. data/spec/concerns/common_spec.rb +25 -3
  25. data/spec/concerns/models/target_spec.rb +10 -12
  26. data/spec/concerns/renderable_spec.rb +5 -5
  27. data/spec/controllers/controller_spec_utility.rb +15 -51
  28. data/spec/generators/migration/migration_generator_spec.rb +2 -10
  29. data/spec/helpers/view_helpers_spec.rb +1 -1
  30. data/spec/optional_targets/action_cable_api_channel_spec.rb +21 -24
  31. data/spec/optional_targets/action_cable_channel_spec.rb +26 -29
  32. data/spec/rails_app/config/application.rb +2 -6
  33. data/spec/rails_app/config/environments/test.rb +2 -11
  34. data/spec/spec_helper.rb +1 -5
  35. metadata +5 -8
  36. data/gemfiles/Gemfile.rails-4.2 +0 -24
  37. 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
- if Rails::VERSION::MAJOR >= 5
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
- if Rails::VERSION::MAJOR >= 5
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
- if Rails::VERSION::MAJOR >= 5
2
- require 'activity_notification/optional_targets/action_cable_api_channel'
3
- describe ActivityNotification::OptionalTarget::ActionCableApiChannel do
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
- describe "as public instance methods" do
7
- describe "#to_optional_target_name" do
8
- it "is return demodulized symbol class name" do
9
- expect(test_instance.to_optional_target_name).to eq(:action_cable_api_channel)
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
- describe "#initialize_target" do
14
- it "does not raise NotImplementedError" do
15
- test_instance.initialize_target
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
- describe "#notify" do
20
- it "does not raise NotImplementedError" do
21
- test_instance.notify(create(:notification))
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
- describe "as protected instance methods" do
27
- describe "#render_notification_message" do
28
- context "as default" do
29
- it "renders notification message as formatted JSON" do
30
- expect(test_instance.send(:render_notification_message, create(:notification)).with_indifferent_access[:notification].has_key?(:id)).to be_truthy
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
- if Rails::VERSION::MAJOR >= 5
2
- require 'activity_notification/optional_targets/action_cable_channel'
3
- describe ActivityNotification::OptionalTarget::ActionCableChannel do
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
- describe "as public instance methods" do
7
- describe "#to_optional_target_name" do
8
- it "is return demodulized symbol class name" do
9
- expect(test_instance.to_optional_target_name).to eq(:action_cable_channel)
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
- describe "#initialize_target" do
14
- it "does not raise NotImplementedError" do
15
- test_instance.initialize_target
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
- describe "#notify" do
20
- it "does not raise NotImplementedError" do
21
- test_instance.notify(create(:notification))
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
- describe "as protected instance methods" do
27
- describe "#render_notification_message" do
28
- context "as default" do
29
- it "renders notification message with default template" do
30
- expect(test_instance.send(:render_notification_message, create(:notification))).to be_include("<div class='notification_list")
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
- context "with unexisting template as fallback option" do
35
- it "raise ActionView::MissingTemplate" do
36
- expect { expect(test_instance.send(:render_notification_message, create(:notification), fallback: :hoge)) }
37
- .to raise_error(ActionView::MissingTemplate)
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' if Rails::VERSION::MAJOR >= 5
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
- # Do not swallow errors in after_commit/after_rollback callbacks.
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
- if Rails::VERSION::MAJOR >= 5
17
- config.public_file_server.enabled = true
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
@@ -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.1.4
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-07 00:00:00.000000000 Z
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: 4.2.0
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: 4.2.0
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.0.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
@@ -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