<commit_before>module Devise
  module OmniAuth
    module TestHelpers
      def self.test_mode!
        Faraday.default_adapter = :test if defined?(Faraday)
        ActiveSupport.on_load(:action_controller) { include Devise::OmniAuth::TestHelpers }
        ActiveSupport.on_load(:action_view) { include Devise::OmniAuth::TestHelpers }
      end

      def self.stub!(provider, stubs=nil, &block)
        raise "You either need to pass stubs as a block or as a parameter" unless block_given? || stubs

        config = Devise.omniauth_configs[provider]
        raise "Could not find configuration for #{provider.to_s} omniauth provider" unless config

        config.check_if_allow_stubs!
        stubs ||= Faraday::Adapter::Test::Stubs.new(&block)

        config.build_connection do |b|
          b.adapter :test, stubs
        end
      end

      def self.reset_stubs!(*providers)
        target = providers.any? ? Devise.omniauth_configs.slice(*providers) : Devise.omniauth_configs
        target.each_value do |config|
          next unless config.allow_stubs?
          config.build_connection { |b| b.adapter Faraday.default_adapter }
        end
      end

      def self.short_circuit_authorizers!
        module_eval <<-ALIASES, __FILE__, __LINE__ + 1
          def omniauth_authorize_path(*args)
            omniauth_callback_path(*args)
          end
        ALIASES

        Devise.mappings.each_value do |m|
          next unless m.omniauthable?

          module_eval <<-ALIASES, __FILE__, __LINE__ + 1
            def #{m.name}_omniauth_authorize_path(provider)
              #{m.name}_omniauth_callback_path(provider)<commit_msg>Fixing parameters for _omniauth_authorize_path method after short-circuiting it.<commit_after>module Devise
  module OmniAuth
    module TestHelpers
      def self.test_mode!
        Faraday.default_adapter = :test if defined?(Faraday)
        ActiveSupport.on_load(:action_controller) { include Devise::OmniAuth::TestHelpers }
        ActiveSupport.on_load(:action_view) { include Devise::OmniAuth::TestHelpers }
      end

      def self.stub!(provider, stubs=nil, &block)
        raise "You either need to pass stubs as a block or as a parameter" unless block_given? || stubs

        config = Devise.omniauth_configs[provider]
        raise "Could not find configuration for #{provider.to_s} omniauth provider" unless config

        config.check_if_allow_stubs!
        stubs ||= Faraday::Adapter::Test::Stubs.new(&block)

        config.build_connection do |b|
          b.adapter :test, stubs
        end
      end

      def self.reset_stubs!(*providers)
        target = providers.any? ? Devise.omniauth_configs.slice(*providers) : Devise.omniauth_configs
        target.each_value do |config|
          next unless config.allow_stubs?
          config.build_connection { |b| b.adapter Faraday.default_adapter }
        end
      end

      def self.short_circuit_authorizers!
        module_eval <<-ALIASES, __FILE__, __LINE__ + 1
          def omniauth_authorize_path(*args)
            omniauth_callback_path(*args)
          end
        ALIASES

        Devise.mappings.each_value do |m|
          next unless m.omniauthable?

          module_eval <<-ALIASES, __FILE__, __LINE__ + 1
            def #{m.name}_omniauth_authorize_path(provider, params = {})
              #{m.name}_omniauth_callback_path(provider, params)
{'fraction_non_alphanumeric': 0.08550295857988166, 'fraction_numerical': 0.001183431952662722, 'mean_word_length': 2.756666666666667, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5306586', 'n_tokens_mistral': 1040, 'n_tokens_neox': 1001, 'n_words': 224}