<commit_before>module AuthenticatedTestHelper
  def self.included(klass)
    klass.send(:extend, ClassMethods)
  end

  # Sets the current person in the session from the person fixtures.
  def login_as(person)
    @request.session[:person_id] = person ? people(person).id : nil
  end

  def authorize_as(person)
    @request.env["HTTP_AUTHORIZATION"] = person ? ActionController::HttpAuthentication::Basic.encode_credentials(people(person).login, 'monkey') : nil
  end
  
  module ClassMethods
    def logged_in_as(person)
      context "Logged in as #{person}" do
        setup do
          login_as(person)
        end

        yield
      end
    end
    
    def not_logged_in
      context "Not logged in" do
        setup do
          login_as(nil)
        end

        yield
      end
    end
    
    def should_deny_access
      should_respond_with :redirect
      should_redirect_to  'login_url'
      should_set_the_flash_to(/must be logged in/i)
    end
  end
end<commit_msg>Revert auth_test_helper to original Restful auth code<commit_after>module AuthenticatedTestHelper
  # Sets the current person in the session from the person fixtures.
  def login_as(person)
    @request.session[:person_id] = person ? people(person).id : nil
  end

  def authorize_as(person)
    @request.env["HTTP_AUTHORIZATION"] = person ? ActionController::HttpAuthentication::Basic.encode_credentials(people(person).login, 'monkey') : nil
  end
end
{'fraction_non_alphanumeric': 0.0778318276580959, 'fraction_numerical': 0.0, 'mean_word_length': 3.210526315789474, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5194579', 'n_tokens_mistral': 439, 'n_tokens_neox': 430, 'n_words': 111}