diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5f0b429..d9f9e92 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,8 +3,8 @@ name: build on: push: branches: - - '**' - - '!images' + - 'master' + - 'development' pull_request: branches: - '**' @@ -23,6 +23,7 @@ jobs: - gemfiles/Gemfile.rails-6.0 - gemfiles/Gemfile.rails-6.1 - gemfiles/Gemfile.rails-7.0 + - gemfiles/Gemfile.rails-7.1 orm: - active_record - mongoid @@ -30,27 +31,29 @@ jobs: include: # https://www.ruby-lang.org/en/downloads - gemfile: gemfiles/Gemfile.rails-5.0 - ruby-version: 2.7.5 + ruby-version: 2.7.7 - gemfile: gemfiles/Gemfile.rails-5.1 - ruby-version: 2.7.5 + ruby-version: 2.7.7 - gemfile: gemfiles/Gemfile.rails-5.2 - ruby-version: 2.7.5 + ruby-version: 2.7.7 - gemfile: gemfiles/Gemfile.rails-6.0 - ruby-version: 3.0.3 + ruby-version: 2.7.7 - gemfile: gemfiles/Gemfile.rails-6.1 - ruby-version: 3.0.3 + ruby-version: 2.7.7 - gemfile: gemfiles/Gemfile.rails-7.0 - ruby-version: 3.0.3 + ruby-version: 3.1.6 + - gemfile: gemfiles/Gemfile.rails-7.1 + ruby-version: 3.2.4 - gemfile: Gemfile - ruby-version: 3.0.3 + ruby-version: 3.3.3 orm: active_record test-db: mysql - gemfile: Gemfile - ruby-version: 3.0.3 + ruby-version: 3.3.3 orm: active_record test-db: postgresql - gemfile: Gemfile - ruby-version: 3.0.3 + ruby-version: 3.3.3 orm: mongoid test-db: mongodb - gemfile: Gemfile @@ -64,6 +67,8 @@ jobs: orm: dynamoid - gemfile: gemfiles/Gemfile.rails-7.0 orm: dynamoid + - gemfile: gemfiles/Gemfile.rails-7.1 + orm: dynamoid env: RAILS_ENV: test @@ -97,10 +102,10 @@ jobs: - 27017:27017 env: MONGO_INITDB_DATABASE: activity_notification_test - options: --health-cmd mongo --health-interval 10s --health-timeout 5s --health-retries 5 + options: --health-cmd mongosh --health-interval 10s --health-timeout 5s --health-retries 5 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Ruby uses: ruby/setup-ruby@v1 with: diff --git a/CHANGELOG.md b/CHANGELOG.md index 78b9068..088e6fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,24 @@ +## 2.3.1 / 2024-07-23 +[Full Changelog](http://github.com/simukappu/activity_notification/compare/v2.3.0...v2.3.1) + +Bug Fixes: + +* Fix serialize arguments for Rails 7.1 - [#178](https://github.com/simukappu/activity_notification/issues/178) [#179](https://github.com/simukappu/activity_notification/pull/179) + +## 2.3.0 / 2024-06-02 +[Full Changelog](http://github.com/simukappu/activity_notification/compare/v2.2.4...v2.3.0) + +Enhancements: + +* Allow use with Rails 7.1 - [#173](https://github.com/simukappu/activity_notification/issues/173) [#177](https://github.com/simukappu/activity_notification/pull/177) + +## 2.2.4 / 2023-03-20 +[Full Changelog](http://github.com/simukappu/activity_notification/compare/v2.2.3...v2.2.4) + +Bug Fixes: + +* Fix broken serialization with Rails security patch - [#166](https://github.com/simukappu/activity_notification/issues/166) [#167](https://github.com/simukappu/activity_notification/pull/167) + ## 2.2.3 / 2022-02-12 [Full Changelog](http://github.com/simukappu/activity_notification/compare/v2.2.2...v2.2.3) diff --git a/Gemfile b/Gemfile index 29e05d9..a19e085 100644 --- a/Gemfile +++ b/Gemfile @@ -2,9 +2,10 @@ source 'https://rubygems.org' gemspec -gem 'rails', '~> 6.0.0' +gem 'rails', '~> 7.1.0' group :production do + gem 'sprockets-rails' gem 'puma' gem 'pg' gem 'devise' @@ -20,7 +21,7 @@ group :test do gem 'ammeter' gem 'timecop' gem 'committee' - gem 'committee-rails' + gem 'committee-rails', '< 0.6' # gem 'coveralls', require: false gem 'coveralls_reborn', require: false end diff --git a/activity_notification.gemspec b/activity_notification.gemspec index fe7846a..cbceb0c 100644 --- a/activity_notification.gemspec +++ b/activity_notification.gemspec @@ -26,10 +26,10 @@ Gem::Specification.new do |s| s.add_dependency 'swagger-blocks', '>= 3.0.0' s.add_development_dependency 'puma', '>= 3.12.0' - s.add_development_dependency 'sqlite3', '>= 1.3.13' + s.add_development_dependency 'sqlite3', '>= 1.3.13', '< 2.0' s.add_development_dependency 'mysql2', '>= 0.5.2' s.add_development_dependency 'pg', '>= 1.0.0' - s.add_development_dependency 'mongoid', '>= 4.0.0' + s.add_development_dependency 'mongoid', '>= 4.0.0', '< 9.0' s.add_development_dependency 'dynamoid', '3.1.0' s.add_development_dependency 'rspec-rails', '>= 3.8.0' s.add_development_dependency 'factory_bot_rails', '>= 4.11.0', '< 5.0.0' diff --git a/docs/Setup.md b/docs/Setup.md index 6af7956..e7ffb2a 100644 --- a/docs/Setup.md +++ b/docs/Setup.md @@ -46,6 +46,22 @@ The same can be done for the subscription table name, e.g., if you're using the config.subscription_table_name = "notifications_subscriptions" ``` +If you're redefining `yaml_column_permitted_classes` in *config/application.rb*, then you need to add a few classes to the whitelist to make sure *activity_notification* still works as expected. + +```ruby +config.active_record.yaml_column_permitted_classes ||= [] + +# your override(s), e.g: MyWhitelistedClass +config.active_record.yaml_column_permitted_classes << MyWhitelistedClass + +# overrides required for activity_notification to work +config.yaml_column_permitted_classes << ActiveSupport::HashWithIndifferentAccess +config.yaml_column_permitted_classes << ActiveSupport::TimeWithZone +config.yaml_column_permitted_classes << ActiveSupport::TimeZone +config.yaml_column_permitted_classes << Symbol +config.yaml_column_permitted_classes << Time +``` + #### Using Mongoid ORM When you use *activity_notification* with [Mongoid](http://mongoid.org) ORM, set **AN_ORM** environment variable to **mongoid**: diff --git a/gemfiles/Gemfile.rails-5.0 b/gemfiles/Gemfile.rails-5.0 index 46b0219..b5ed521 100644 --- a/gemfiles/Gemfile.rails-5.0 +++ b/gemfiles/Gemfile.rails-5.0 @@ -17,7 +17,7 @@ group :test do gem 'ammeter' gem 'timecop' gem 'committee' - gem 'committee-rails' + gem 'committee-rails', '< 0.6' # gem 'coveralls', require: false gem 'coveralls_reborn', require: false end diff --git a/gemfiles/Gemfile.rails-5.1 b/gemfiles/Gemfile.rails-5.1 index e209b3a..4bd36e3 100644 --- a/gemfiles/Gemfile.rails-5.1 +++ b/gemfiles/Gemfile.rails-5.1 @@ -16,9 +16,10 @@ group :test do gem 'ammeter' gem 'timecop' gem 'committee' - gem 'committee-rails' + gem 'committee-rails', '< 0.6' # gem 'coveralls', require: false gem 'coveralls_reborn', require: false + gem 'mongoid', '>= 4.0.0', '< 8.0' end gem 'dotenv-rails', groups: [:development, :test] diff --git a/gemfiles/Gemfile.rails-5.2 b/gemfiles/Gemfile.rails-5.2 index b0ff27f..eddd5f4 100644 --- a/gemfiles/Gemfile.rails-5.2 +++ b/gemfiles/Gemfile.rails-5.2 @@ -16,7 +16,7 @@ group :test do gem 'ammeter' gem 'timecop' gem 'committee' - gem 'committee-rails' + gem 'committee-rails', '< 0.6' # gem 'coveralls', require: false gem 'coveralls_reborn', require: false end diff --git a/gemfiles/Gemfile.rails-6.0 b/gemfiles/Gemfile.rails-6.0 index 87565e3..fe4cd93 100644 --- a/gemfiles/Gemfile.rails-6.0 +++ b/gemfiles/Gemfile.rails-6.0 @@ -3,6 +3,7 @@ source 'https://rubygems.org' gemspec path: '../' gem 'rails', '~> 6.0.0' +gem 'psych', '< 4' group :development do gem 'bullet' @@ -14,7 +15,7 @@ group :test do gem 'ammeter' gem 'timecop' gem 'committee' - gem 'committee-rails' + gem 'committee-rails', '< 0.6' # gem 'coveralls', require: false gem 'coveralls_reborn', require: false end diff --git a/gemfiles/Gemfile.rails-6.1 b/gemfiles/Gemfile.rails-6.1 index 5dadcd8..6ce4b8e 100644 --- a/gemfiles/Gemfile.rails-6.1 +++ b/gemfiles/Gemfile.rails-6.1 @@ -14,7 +14,7 @@ group :test do gem 'ammeter' gem 'timecop' gem 'committee' - gem 'committee-rails' + gem 'committee-rails', '< 0.6' # gem 'coveralls', require: false gem 'coveralls_reborn', require: false end diff --git a/gemfiles/Gemfile.rails-7.0 b/gemfiles/Gemfile.rails-7.0 index f03d7e2..0896ce3 100644 --- a/gemfiles/Gemfile.rails-7.0 +++ b/gemfiles/Gemfile.rails-7.0 @@ -3,11 +3,6 @@ source 'https://rubygems.org' gemspec path: '../' gem 'rails', '~> 7.0.0' -# https://github.com/lynndylanhurley/devise_token_auth/pull/1517 -gem 'devise_token_auth', git: 'https://github.com/lynndylanhurley/devise_token_auth.git' -# https://jira.mongodb.org/browse/MONGOID-5193 -gem 'mongoid', git: 'https://github.com/mongodb/mongoid.git' - gem 'sprockets-rails' group :development do @@ -20,7 +15,7 @@ group :test do gem 'ammeter' gem 'timecop' gem 'committee' - gem 'committee-rails' + gem 'committee-rails', '< 0.6' # gem 'coveralls', require: false gem 'coveralls_reborn', require: false end diff --git a/gemfiles/Gemfile.rails-7.1 b/gemfiles/Gemfile.rails-7.1 new file mode 100644 index 0000000..33d2bdf --- /dev/null +++ b/gemfiles/Gemfile.rails-7.1 @@ -0,0 +1,23 @@ +source 'https://rubygems.org' + +gemspec path: '../' + +gem 'rails', '~> 7.1.0' +gem 'sprockets-rails' + +group :development do + gem 'bullet' + gem 'rack-cors' +end + +group :test do + gem 'rails-controller-testing' + gem 'ammeter' + gem 'timecop' + gem 'committee' + gem 'committee-rails', '< 0.6' + # gem 'coveralls', require: false + gem 'coveralls_reborn', require: false +end + +gem 'dotenv-rails', groups: [:development, :test] diff --git a/lib/activity_notification/orm/active_record/notification.rb b/lib/activity_notification/orm/active_record/notification.rb index b654090..68596bd 100644 --- a/lib/activity_notification/orm/active_record/notification.rb +++ b/lib/activity_notification/orm/active_record/notification.rb @@ -45,7 +45,13 @@ class Notification < ::ActiveRecord::Base belongs_to :notifier, polymorphic: true, optional: true # Serialize parameters Hash - serialize :parameters, Hash + # :nocov: + if Rails.gem_version >= Gem::Version.new('7.1') + serialize :parameters, type: Hash, coder: YAML + else + serialize :parameters, Hash + end + # :nocov: validates :target, presence: true validates :notifiable, presence: true diff --git a/lib/activity_notification/orm/active_record/subscription.rb b/lib/activity_notification/orm/active_record/subscription.rb index b5c1ef7..5293227 100644 --- a/lib/activity_notification/orm/active_record/subscription.rb +++ b/lib/activity_notification/orm/active_record/subscription.rb @@ -14,7 +14,13 @@ class Subscription < ::ActiveRecord::Base belongs_to :target, polymorphic: true # Serialize parameters Hash - serialize :optional_targets, Hash + # :nocov: + if Rails.gem_version >= Gem::Version.new('7.1') + serialize :optional_targets, type: Hash, coder: YAML + else + serialize :optional_targets, Hash + end + # :nocov: validates :target, presence: true validates :key, presence: true, uniqueness: { scope: :target } diff --git a/lib/activity_notification/version.rb b/lib/activity_notification/version.rb index 3563485..f9eb778 100644 --- a/lib/activity_notification/version.rb +++ b/lib/activity_notification/version.rb @@ -1,3 +1,3 @@ module ActivityNotification - VERSION = "2.2.3" + VERSION = "2.3.1" end diff --git a/spec/concerns/renderable_spec.rb b/spec/concerns/renderable_spec.rb index 78a5efa..39d2526 100644 --- a/spec/concerns/renderable_spec.rb +++ b/spec/concerns/renderable_spec.rb @@ -77,7 +77,7 @@ test_instance.target = create(:admin) test_instance.key = "notification.#{simple_text_key}" expect(test_instance.text) - .to eq("translation missing: en.notification.admin.#{simple_text_key}.text") + .to eq("Translation missing: en.notification.admin.#{simple_text_key}.text") end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 609a3ce..5767bb8 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -46,6 +46,7 @@ def clean_database end RSpec.configure do |config| + config.expect_with :minitest, :rspec config.include FactoryBot::Syntax::Methods config.before(:each) do FactoryBot.reload