From 4b28635e13d5aeb37d3ba198ddbf45e5248534e3 Mon Sep 17 00:00:00 2001 From: Andrew Konchin Date: Sun, 3 Nov 2024 15:32:51 +0200 Subject: [PATCH] Skip specs for callback aborting on Rails 4.2 --- spec/dynamoid/persistence_spec.rb | 8 +++++ .../dynamoid/transaction_write/create_spec.rb | 16 ++++++++++ .../transaction_write/destroy_spec.rb | 16 ++++++++++ spec/dynamoid/transaction_write/save_spec.rb | 32 +++++++++++++++++++ .../update_attributes_spec.rb | 16 ++++++++++ 5 files changed, 88 insertions(+) diff --git a/spec/dynamoid/persistence_spec.rb b/spec/dynamoid/persistence_spec.rb index 821867ba..29a8ac1e 100644 --- a/spec/dynamoid/persistence_spec.rb +++ b/spec/dynamoid/persistence_spec.rb @@ -4852,6 +4852,10 @@ def around_destroy_callback end it 'aborts destroying and returns false if a before_destroy callback throws :abort' do + if ActiveSupport.version < Gem::Version.new('5.0') + skip "Rails 4.x and below don't support aborting with `throw :abort`" + end + klass = new_class do before_destroy { throw :abort } end @@ -4870,6 +4874,10 @@ def around_destroy_callback describe 'destroy!' do it 'aborts destroying and raises RecordNotDestroyed if a before_destroy callback throws :abort' do + if ActiveSupport.version < Gem::Version.new('5.0') + skip "Rails 4.x and below don't support aborting with `throw :abort`" + end + klass = new_class do before_destroy { throw :abort } end diff --git a/spec/dynamoid/transaction_write/create_spec.rb b/spec/dynamoid/transaction_write/create_spec.rb index 3b50c82f..26975fde 100644 --- a/spec/dynamoid/transaction_write/create_spec.rb +++ b/spec/dynamoid/transaction_write/create_spec.rb @@ -276,6 +276,10 @@ def around_save_callback end it 'aborts creation and returns false if callback throws :abort' do + if ActiveSupport.version < Gem::Version.new('5.0') + skip "Rails 4.x and below don't support aborting with `throw :abort`" + end + klass = new_class do field :name before_create { throw :abort } @@ -294,6 +298,10 @@ def around_save_callback end it 'does not roll back the transaction when a model creation aborted by a callback' do + if ActiveSupport.version < Gem::Version.new('5.0') + skip "Rails 4.x and below don't support aborting with `throw :abort`" + end + klass_with_callback = new_class do field :name before_create { throw :abort } @@ -642,6 +650,10 @@ def around_save_callback end it 'aborts creation and raises exception if callback throws :abort' do + if ActiveSupport.version < Gem::Version.new('5.0') + skip "Rails 4.x and below don't support aborting with `throw :abort`" + end + klass = new_class do field :name before_create { throw :abort } @@ -658,6 +670,10 @@ def around_save_callback end it 'rolls back the transaction when a model creation aborted by a callback' do + if ActiveSupport.version < Gem::Version.new('5.0') + skip "Rails 4.x and below don't support aborting with `throw :abort`" + end + klass_with_callback = new_class do field :name before_create { throw :abort } diff --git a/spec/dynamoid/transaction_write/destroy_spec.rb b/spec/dynamoid/transaction_write/destroy_spec.rb index e4eeb789..256f4e44 100644 --- a/spec/dynamoid/transaction_write/destroy_spec.rb +++ b/spec/dynamoid/transaction_write/destroy_spec.rb @@ -139,6 +139,10 @@ def around_destroy_callback end it 'aborts destroying and returns false if callback throws :abort' do + if ActiveSupport.version < Gem::Version.new('5.0') + skip "Rails 4.x and below don't support aborting with `throw :abort`" + end + klass = new_class do before_destroy { throw :abort } end @@ -155,6 +159,10 @@ def around_destroy_callback end it 'does not roll back the transaction when a destroying of some model aborted by a before_destroy callback' do + if ActiveSupport.version < Gem::Version.new('5.0') + skip "Rails 4.x and below don't support aborting with `throw :abort`" + end + klass = new_class do before_destroy { throw :abort } end @@ -277,6 +285,10 @@ def around_destroy_callback end it 'returns false if :abort is thrown' do + if ActiveSupport.version < Gem::Version.new('5.0') + skip "Rails 4.x and below don't support aborting with `throw :abort`" + end + klass_with_callback = new_class do before_destroy { throw :abort } end @@ -325,6 +337,10 @@ def around_destroy_callback end it 'aborts destroying and raises RecordNotDestroyed if callback throws :abort' do + if ActiveSupport.version < Gem::Version.new('5.0') + skip "Rails 4.x and below don't support aborting with `throw :abort`" + end + klass = new_class do before_destroy { throw :abort } end diff --git a/spec/dynamoid/transaction_write/save_spec.rb b/spec/dynamoid/transaction_write/save_spec.rb index e2a19e7c..15138abd 100644 --- a/spec/dynamoid/transaction_write/save_spec.rb +++ b/spec/dynamoid/transaction_write/save_spec.rb @@ -547,6 +547,10 @@ def around_save_callback end it 'aborts creation and returns false if callback throws :abort' do + if ActiveSupport.version < Gem::Version.new('5.0') + skip "Rails 4.x and below don't support aborting with `throw :abort`" + end + klass = new_class do field :name before_create { throw :abort } @@ -565,6 +569,10 @@ def around_save_callback end it 'aborts updating and returns false if callback throws :abort' do + if ActiveSupport.version < Gem::Version.new('5.0') + skip "Rails 4.x and below don't support aborting with `throw :abort`" + end + klass = new_class do field :name before_update { throw :abort } @@ -584,6 +592,10 @@ def around_save_callback end it 'does not roll back the transaction when a model creation aborted by a callback' do + if ActiveSupport.version < Gem::Version.new('5.0') + skip "Rails 4.x and below don't support aborting with `throw :abort`" + end + klass_with_callback = new_class do field :name before_create { throw :abort } @@ -611,6 +623,10 @@ def around_save_callback end it 'does not roll back the transaction when a model updating aborted by a callback' do + if ActiveSupport.version < Gem::Version.new('5.0') + skip "Rails 4.x and below don't support aborting with `throw :abort`" + end + klass_with_callback = new_class do field :name before_update { throw :abort } @@ -1253,6 +1269,10 @@ def around_update_callback end it 'aborts creation and raises exception if callback throws :abort' do + if ActiveSupport.version < Gem::Version.new('5.0') + skip "Rails 4.x and below don't support aborting with `throw :abort`" + end + klass = new_class do field :name before_create { throw :abort } @@ -1273,6 +1293,10 @@ def around_update_callback end it 'aborts updating and raises exception if callback throws :abort' do + if ActiveSupport.version < Gem::Version.new('5.0') + skip "Rails 4.x and below don't support aborting with `throw :abort`" + end + klass = new_class do field :name before_update { throw :abort } @@ -1292,6 +1316,10 @@ def around_update_callback end it 'rolls back the transaction when a model creation aborted by a callback' do + if ActiveSupport.version < Gem::Version.new('5.0') + skip "Rails 4.x and below don't support aborting with `throw :abort`" + end + klass_with_callback = new_class do field :name before_create { throw :abort } @@ -1321,6 +1349,10 @@ def around_update_callback end it 'rolls back the transaction when a model updating aborted by a callback' do + if ActiveSupport.version < Gem::Version.new('5.0') + skip "Rails 4.x and below don't support aborting with `throw :abort`" + end + klass_with_callback = new_class do field :name before_update { throw :abort } diff --git a/spec/dynamoid/transaction_write/update_attributes_spec.rb b/spec/dynamoid/transaction_write/update_attributes_spec.rb index ebfbdb0b..5687300c 100644 --- a/spec/dynamoid/transaction_write/update_attributes_spec.rb +++ b/spec/dynamoid/transaction_write/update_attributes_spec.rb @@ -254,6 +254,10 @@ def around_save_callback end it 'aborts updating and returns false if callback throws :abort' do + if ActiveSupport.version < Gem::Version.new('5.0') + skip "Rails 4.x and below don't support aborting with `throw :abort`" + end + klass = new_class do before_update { throw :abort } end @@ -270,6 +274,10 @@ def around_save_callback end it 'does not roll back the transaction when a model updating aborted by a callback' do + if ActiveSupport.version < Gem::Version.new('5.0') + skip "Rails 4.x and below don't support aborting with `throw :abort`" + end + klass = new_class do before_update { throw :abort } end @@ -622,6 +630,10 @@ def around_update_callback end it 'aborts updating and raises exception if callback throws :abort' do + if ActiveSupport.version < Gem::Version.new('5.0') + skip "Rails 4.x and below don't support aborting with `throw :abort`" + end + klass = new_class do field :name before_update { throw :abort } @@ -638,6 +650,10 @@ def around_update_callback end it 'rolls back the transaction when a model updating aborted by a callback' do + if ActiveSupport.version < Gem::Version.new('5.0') + skip "Rails 4.x and below don't support aborting with `throw :abort`" + end + klass = new_class do field :name before_update { throw :abort }