#98 ✓resolved
Jeff Wigal

Can't get TestCase to work

Reported by Jeff Wigal | April 27th, 2009 @ 08:56 PM

I'm having a heck of a time getting my tests working with Authlogic.

I put together a bare-bones rails app up and running, the only plugin I have installed is authlogic.

  • user belongs_to :site
  • site has_many :users
  • account model only has a name:string attribute

I've tried the following variations:

  • Rails 2.2.2, 2.3.2
  • Session- and ActiveRecord-based session store
  • Windows & Linux. My windows box has a very minimal gem setup (just blew it away and started from scratch last week, not related to this problem)
  • within an application with about 12 different plugins and gems, and my app with no other gems/plugins

I'm requiring test_case in my test_helper.rb file

require 'authlogic/test_case'

Here's my integration test

require File.dirname(__FILE__) + '/../test_helper'

class LoginLogoutTest < ActionController::IntegrationTest
  fixtures :all
  setup :activate_authlogic
  # Replace this with your real tests.

  test "can login via post" do
    get new_user_session_path
    post_via_redirect user_session_path, :login => @user.login, :password => "awesomeness"
    logger.info session.inspect
    assert_response :success
    get accounts_path
    logger.info session.inspect
    assert_response :success

  end

  test "can login via create" do
    get new_user_session_path
    UserSession.create!(@user)
    logger.info session.inspect
    get accounts_path
    logger.info session.inspect
    assert_response :success
  end


  def setup
    site = Site.create!(:name => "booberry")
    @user = User.create!(
          :site => site,
          :first_name => "john",
          :last_name => "boy",
          :login => "jeff",
          :email => "jeff@wigaldesign.com",
          :password => "awesomeness", 
          :password_confirmation => "awesomeness")
  end
end

Plugin seems to work great in production/development mode using a browser. What am I missing?

Comments and changes to this ticket

  • Ben Johnson

    Ben Johnson April 27th, 2009 @ 11:00 PM

    • State changed from “new” to “open”

    You should be posting to user_sessions_path (plural). Does that fix it?

  • Steve Noyce

    Steve Noyce April 29th, 2009 @ 12:38 PM

    This sounds close to the problem I'm seeing also. Things work great in the real world, but my functional tests all fail.

    I do PersonSession.create(people(:one)) (using Person model) and nothing seems to happen. Anything that requires a login insists on redirecting to the login world.

  • Ben Johnson

    Ben Johnson May 4th, 2009 @ 12:32 AM

    Let me update the tests in the authlogic exmaple app and see if I can reproduce the problem. I am not having any issues in the app I am currently working on, but I'll update the example app so we can all have something to play around with and compare it to.

  • Ben Johnson

    Ben Johnson May 7th, 2009 @ 01:00 PM

    Nice, I'm at the Erector presentation. I really like webrat too.

  • Steve Noyce

    Steve Noyce May 11th, 2009 @ 01:11 PM

    I guess I'm a little concerned that I haven't gotten a bare-bones installation to work even for functional tests. (Let me know if this is a different issue than integration tests) Should it be necessary to hack in stuff from the earlier release in order to make things go?

    Steve

  • Ben Johnson

    Ben Johnson May 11th, 2009 @ 02:02 PM

    I pushed out some changes to the authlogic_example, checkout the tests and see what you think.

  • Ben Johnson

    Ben Johnson May 11th, 2009 @ 02:20 PM

    That would be great, thanks.

  • Ben Johnson

    Ben Johnson June 3rd, 2009 @ 03:20 AM

    Is this still an issue? Did the above method work? If so, that's an easy fix. Correct me if I'm wrong but isn't params still available in 2.2? I thought params has been around since rails started.

  • Steve Noyce

    Steve Noyce June 3rd, 2009 @ 11:01 AM

    FWIW, I got things working for my functional tests using Factory Girl and creating new user objects for each test.

    Thanks,
    Steve

  • Ben Johnson

    Ben Johnson June 3rd, 2009 @ 12:11 PM

    • State changed from “open” to “resolved”

    Good deal.

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

Tags

Pages