<commit_before>require 'opt_out'

module AdapterTests
  def self.included(base)
    base.extend Macros
  end

  module Macros
    attr_accessor :original_config, :test_config

    def test_adapter(adapter, options = {})
      self.original_config = OptOut.config.dup
      self.test_config = {
        :adapter => adapter,
        :options => options
      }
    end
  end

  def setup
    OptOut.configure do |c|
      c.adapter = self.class.test_config[:adapter]
      c.options = self.class.test_config[:options]
    end
    OptOut.reset
  end

  def teardown
    OptOut.config.adapter = self.class.original_config[:adapter]
    OptOut.config.options = self.class.original_config[:options]    
    OptOut.reset
  end

  def test_auto_subscribed
    assert OptOut.subscribed?('newsletters', '5')
  end

  def test_resubscribe
    OptOut.unsubscribe('newsletters', '5')
    OptOut.subscribe('newsletters', '5')
    assert OptOut.subscribed?('newsletters', '5')
    assert !OptOut.unsubscribed?('newsletters', '5')
  end

  def test_unsubscribe
    OptOut.unsubscribe('newsletters', '5')
    assert !OptOut.subscribed?('newsletters', '5')
    assert OptOut.unsubscribed?('newsletters', '5')
  end

  def test_multi_unsubscribe
    OptOut.unsubscribe('newsletters', '5')
    OptOut.unsubscribe('newsletters', '5')
    assert !OptOut.subscribed?('newsletters', '5')
    assert OptOut.unsubscribed?('newsletters', '5')
  end

  def test_unsubscribers
    OptOut.unsubscribe('newsletters', '5')
    OptOut.unsubscribe('newsletters', '6')
    assert_equal ['5', '6'], OptOut.unsubscribers('newsletters').sort
  end
end<commit_msg>fallback to redis_url on jankies<commit_after>require 'opt_out'

module AdapterTests
  def self.included(base)
    base.extend Macros
  end

  module Macros
    attr_accessor :original_config, :test_config

    def test_adapter(adapter, options = {})
      self.original_config = OptOut.config.dup
      self.test_config = {
        :adapter => adapter,
        :options => options
      }
    end
  end

  def setup
    OptOut.configure do |c|
      c.adapter = self.class.test_config[:adapter]
      c.options = self.class.test_config[:options]
    end
    OptOut.reset
  end

  def teardown
    OptOut.config.adapter = self.class.original_config[:adapter]
    OptOut.config.options = self.class.original_config[:options]
    OptOut.reset
  end

  def test_auto_subscribed
    assert OptOut.subscribed?('newsletters', '5')
  end

  def test_resubscribe
    OptOut.unsubscribe('newsletters', '5')
    OptOut.subscribe('newsletters', '5')
    assert OptOut.subscribed?('newsletters', '5')
    assert !OptOut.unsubscribed?('newsletters', '5')
  end

  def test_unsubscribe
    OptOut.unsubscribe('newsletters', '5')
    assert !OptOut.subscribed?('newsletters', '5')
    assert OptOut.unsubscribed?('newsletters', '5')
  end

  def test_multi_unsubscribe
    OptOut.unsubscribe('newsletters', '5')
    OptOut.unsubscribe('newsletters', '5')
    assert !OptOut.subscribed?('newsletters', '5')
    assert OptOut.unsubscribed?('newsletters', '5')
  end

  def test_unsubscribers
    OptOut.unsubscribe('newsletters', '5')
    OptOut.unsubscribe('newsletters', '6')
    assert_equal ['5', '6'], OptOut.unsubscribers('newsletters').sort
  end
end

{'fraction_non_alphanumeric': 0.12492345376607471, 'fraction_numerical': 0.009797917942437232, 'mean_word_length': 3.6939655172413794, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4720307', 'n_tokens_mistral': 1111, 'n_tokens_neox': 1062, 'n_words': 205}