#82 ✓resolved
kgiszczak

Tests doesn't work with activerecord 2.3.2 ?

Reported by kgiszczak | April 9th, 2009 @ 09:29 AM

I'm using rails 2.3.2 Every time i try to create user session I get this error:


NoMethodError: undefined method `authenticate_with_http_basic' for #<ActionController::TestRequest:0x300c7f8>
    authlogic (2.0.5) lib/authlogic/test_case/controller_adapter.rb:7:in `authenticate_with_http_basic'
    authlogic (2.0.5) lib/authlogic/session/http_auth.rb:11:in `persist_by_http_auth'
    authlogic (2.0.5) lib/authlogic/session/callbacks.rb:78:in `persist'
    authlogic (2.0.5) lib/authlogic/session/persistence.rb:55:in `persisting?'
    authlogic (2.0.5) lib/authlogic/session/persistence.rb:39:in `find'
    authlogic (2.0.5) lib/authlogic/acts_as_authentic/session_maintenance.rb:85:in `get_session_information'
    authlogic (2.0.5) lib/authlogic/acts_as_authentic/session_maintenance.rb:84:in `each'
    authlogic (2.0.5) lib/authlogic/acts_as_authentic/session_maintenance.rb:84:in `get_session_information'
    /Library/Ruby/Gems/1.8/gems/thoughtbot-factory_girl-1.2.0/lib/factory_girl/proxy/create.rb:5:in `result'
    /Library/Ruby/Gems/1.8/gems/thoughtbot-factory_girl-1.2.0/lib/factory_girl/factory.rb:293:in `run'
    /Library/Ruby/Gems/1.8/gems/thoughtbot-factory_girl-1.2.0/lib/factory_girl/factory.rb:237:in `create'
    /Library/Ruby/Gems/1.8/gems/thoughtbot-factory_girl-1.2.0/lib/factory_girl/factory.rb:268:in `send'
    /Library/Ruby/Gems/1.8/gems/thoughtbot-factory_girl-1.2.0/lib/factory_girl/factory.rb:268:in `default_strategy'
    /Library/Ruby/Gems/1.8/gems/thoughtbot-factory_girl-1.2.0/lib/factory_girl.rb:20:in `Factory'
    /test/functional/home_controller_test.rb:18:in `__bind_1239283491_953667'
    /Library/Ruby/Gems/1.8/gems/thoughtbot-shoulda-2.10.1/lib/shoulda/context.rb:271:in `call'
    /Library/Ruby/Gems/1.8/gems/thoughtbot-shoulda-2.10.1/lib/shoulda/context.rb:271:in `run_current_setup_blocks'
    /Library/Ruby/Gems/1.8/gems/thoughtbot-shoulda-2.10.1/lib/shoulda/context.rb:270:in `each'
    /Library/Ruby/Gems/1.8/gems/thoughtbot-shoulda-2.10.1/lib/shoulda/context.rb:270:in `run_current_setup_blocks'

I'm createing session like this: UserSession.create(Factory(:user))

Comments and changes to this ticket

  • Ben Johnson

    Ben Johnson April 9th, 2009 @ 12:22 PM

    • State changed from “new” to “open”

    Hmm, because here is the method for authenticate_with_http_basic:

    def authenticate_with_http_basic(&block)
    end
    

    I'm not even doing anything. Try updating from the repo and see if that fixes it. I'll release an update if it does.

  • kgiszczak

    kgiszczak April 9th, 2009 @ 01:01 PM

    Hi, Ben

    I downloaded the latest version from github, and problem with authenticate_with_http_basic is resolved, but there is another one:

    
    NoMethodError: undefined method `user_agent' for #<Authlogic::TestCase::MockRequest:0x346073c>
    

    After adding this method to Authlogic::TestCase::MockRequest, I got exception that tere is no method accept_language. I had to add also 'referer' method, then tests pass.

    So in the end class Authlogic::TestCase::MockRequest looks like this:

    
    module Authlogic
      module TestCase
        class MockRequest # :nodoc:
          def request_method
            nil
          end
          
          def remote_ip
            "1.1.1.1"
          end
          
          def user_agent
          end
          
          def accept_language
          end
          
          def referer
          end
        end
      end
    end
    
  • Ben Johnson

    Ben Johnson April 9th, 2009 @ 01:11 PM

    • State changed from “open” to “resolved”

    Cool I applied this and it should be fixed.

  • Elias

    Elias December 11th, 2020 @ 12:19 PM

    I was looking at some of your posts on this website and I conceive this web site is really instructive! Keep putting up.. prime factorization

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Object based authentication solution that handles all of the non sense for you. It's as easy as ActiveRecord is with a database.

People watching this ticket

Pages