data_shifter 0.3.2 → 0.3.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2ebcb5560026f1fcfda0f56953e6a3e139d5fd831c5bb935f352b214c526a7c9
4
- data.tar.gz: 7b8d142da33da3ead2adc2033a7ad6ab35b9d280da9b50704301d5f0ab093428
3
+ metadata.gz: a2c27a241f01fd293278fdd45a9b8d5961d3a9ba304a95f657fd591ab5e2b4d6
4
+ data.tar.gz: 4db9925bd3e55bc8420bab92d9ed92a9e86e868ac0a1151f00b5245bace24319
5
5
  SHA512:
6
- metadata.gz: f104c5879fc422025eb752313da24db5a56af3ba2494adf47e7247e49cdcf3ddbd0d91129dafde8a911580e72dc4ae4229b90f7ff081fbd1c2dee20716672959
7
- data.tar.gz: df5cd362bbb77d66f6d555e5483471429ee1e2c9c089272d39a342ca0967e3de9165a482bc14d50618efc9061763fbac61faf6f14e16a44243a4cc8925aa76ea
6
+ metadata.gz: 151626dbec0bae6d652a71cfcf814ccd79ee442211275dcfa4e62a8d0de04838376a6c67385826f3c4320126ef28d2ac37889e61d59b12f2d29a794296cc921d
7
+ data.tar.gz: 2a696741fbfde60b730cc29470b4c47063813cd2dd3995726961c1405283f32e38203659625c56316d5dd5d06abe3bb251ad455a96d298ec1f38129e558bb4e0
data/CHANGELOG.md CHANGED
@@ -4,6 +4,10 @@
4
4
 
5
5
  * N/A
6
6
 
7
+ ## [0.3.2.1]
8
+
9
+ * [Bugfix] Dry-run Sidekiq guard restores the previous `Sidekiq::Testing` mode (`fake!`, `inline!`, or `disable!`) instead of always calling `disable!`, which leaked global state and could leave later specs enqueueing work to real Redis.
10
+
7
11
  ## [0.3.2]
8
12
 
9
13
  * [Bugfix] Rake tasks exit quietly after a failed shift run when the shift already printed its failure summary; failures before that summary are still reported on stderr. Replaces rescuing only `Axn::Failure`, which missed most re-raised exceptions from `run!`.
data/README.md CHANGED
@@ -114,7 +114,7 @@ In **dry run** mode, DataShifter automatically blocks or fakes these side effect
114
114
  | **HTTP** | Blocked via WebMock (`disable_net_connect!`). Allow specific hosts with `allow_external_requests [...]` or `DataShifter.config.allow_external_requests`. |
115
115
  | **ActionMailer** | `perform_deliveries = false` (restored after run). |
116
116
  | **ActiveJob** | Queue adapter set to `:test` (restored after run). |
117
- | **Sidekiq** | `Sidekiq::Testing.fake!` (restored with `disable!` after run). Only applied if `Sidekiq::Testing` is already loaded. |
117
+ | **Sidekiq** | `Sidekiq::Testing.fake!` for the run; previous mode (`fake!`, `inline!`, or `disable!`) is restored after. Only applied if `Sidekiq::Testing` is already loaded. |
118
118
 
119
119
  **Guarding other side effects:** For anything we don't cover (e.g. another service, or allowed HTTP that mutates), use e.g. `return if dry_run?` in your shift. DB changes are always rolled back in dry run; only non-DB side effects need this.
120
120
 
@@ -12,7 +12,7 @@ module DataShifter
12
12
  # production runs never load WebMock. On restore we revert to the previous state (enable!
13
13
  # or disable!) so e.g. specs that had WebMock enabled are not left with it disabled.
14
14
  # - ActionMailer / ActiveJob / Sidekiq: no extra loading; we only toggle existing config
15
- # for the duration of the block and restore in ensure, so impact is scoped to the run.
15
+ # for the duration of the block and restore in ensure (Sidekiq restores prior fake/inline/disable).
16
16
  module SideEffectGuards
17
17
  class << self
18
18
  # Applies side-effect guards, yields, then restores. Call only when running in dry run.
@@ -97,10 +97,23 @@ module DataShifter
97
97
  def apply_sidekiq(saved)
98
98
  return unless Sidekiq::Testing.respond_to?(:fake!)
99
99
 
100
+ saved[:sidekiq_testing_mode] = capture_sidekiq_testing_mode
100
101
  Sidekiq::Testing.fake!
101
102
  saved[:sidekiq] = true
102
103
  end
103
104
 
105
+ def capture_sidekiq_testing_mode
106
+ if Sidekiq::Testing.respond_to?(:__test_mode)
107
+ Sidekiq::Testing.__test_mode
108
+ elsif Sidekiq::Testing.fake?
109
+ :fake
110
+ elsif Sidekiq::Testing.inline?
111
+ :inline
112
+ else
113
+ :disable
114
+ end
115
+ end
116
+
104
117
  def restore_guards(saved)
105
118
  if saved.delete(:webmock)
106
119
  (saved.delete(:webmock_was_enabled) ? WebMock.enable! : WebMock.disable!)
@@ -112,7 +125,18 @@ module DataShifter
112
125
 
113
126
  return unless saved.delete(:sidekiq)
114
127
 
115
- Sidekiq::Testing.disable!
128
+ restore_sidekiq_testing_mode(saved.delete(:sidekiq_testing_mode))
129
+ end
130
+
131
+ def restore_sidekiq_testing_mode(mode)
132
+ case mode
133
+ when :fake
134
+ Sidekiq::Testing.fake!
135
+ when :inline
136
+ Sidekiq::Testing.inline!
137
+ else
138
+ Sidekiq::Testing.disable!
139
+ end
116
140
  end
117
141
  end
118
142
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DataShifter
4
- VERSION = "0.3.2"
4
+ VERSION = "0.3.2.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: data_shifter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kali Donovan