SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2004
    Location
    NC
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    problems developing a test

    Hello,

    I'm pretty new to ruby and I'm trying to develop a test for a simple
    method.

    The method is this:

    Code:
    def show_details
          @accounts = Account.find( params[:id] )
    end
    and the test method I'm trying is this:

    Code:
    def test_show_details
        get :index, :context => 'admin', :id => 1
        assert_response :success
        assert_equal assigns(:accounts), accounts(:blake_acount)
    end
    we have some test data in .yml file called accounts.yml which is stored
    in /test/fixtures/ directory and it contains this section on
    blake_account:

    blake_account:
    id: 1
    user_id: 1
    first_name: Blake
    expire_on: <%= Date.today + 32 %>
    recurring: false
    country_code: US

    Don't understand why this fails?

  2. #2
    SitePoint Guru
    Join Date
    Aug 2005
    Posts
    986
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What is the failure message you're getting?

  3. #3
    SitePoint Zealot
    Join Date
    Jul 2004
    Location
    NC
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The error I'm getting is:

    Expected response to be a <:success>, but was <302>

  4. #4
    SitePoint Guru
    Join Date
    Aug 2005
    Posts
    986
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The get call request calls this url:

    Code:
    controller/index/1?context=admin
    Is this correct?

  5. #5
    SitePoint Addict
    Join Date
    Mar 2004
    Location
    Grand Junction, CO
    Posts
    292
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My guess is that you've got authentication in your app. In your test though, you didn't populate the session, so making that request redirects to the login screen.

  6. #6
    Your daddy. WALoeIII's Avatar
    Join Date
    Apr 2001
    Location
    USA
    Posts
    526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by pergesu View Post
    My guess is that you've got authentication in your app. In your test though, you didn't populate the session, so making that request redirects to the login screen.
    Aye. A 302 redirect is a temporary redirect, and I agree with pergesu that its probably a login filter catching and redirecting your test to the login page.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •