File: ruby_2_6_rails_4_2_patch.rb

package info (click to toggle)
ruby-active-model-serializers 0.10.12-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,752 kB
  • sloc: ruby: 13,138; sh: 53; makefile: 6
file content (24 lines) | stat: -rw-r--r-- 671 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# frozen_string_literal: true

if RUBY_VERSION >= '2.6.0'
  if Rails::VERSION::MAJOR < 5
    module ActionController
      class TestResponse < ActionDispatch::TestResponse
        def recycle!
          # HACK: to avoid MonitorMixin double-initialize error:
          @mon_mutex_owner_object_id = nil
          @mon_mutex = nil
          initialize
        end
      end
    end
  else
    msg = 'Monkeypatch for ActionController::TestResponse not needed for '\
      'Rails 5+. We can drop this patch once we drop support for Rails < 5. '\
      "Current Rails version: #{ENV['RAILS_VERSION']}"

    puts
    puts "\033[33m **** #{msg} **** \033[0m"
    puts
  end
end