Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
functinal testing, sign_in test helper
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Pablo Rodriguez  
View profile  
 More options May 9 2012, 4:55 pm
From: Pablo Rodriguez <pablorodriguez...@gmail.com>
Date: Wed, 9 May 2012 13:55:10 -0700 (PDT)
Local: Wed, May 9 2012 4:55 pm
Subject: functinal testing, sign_in test helper
I have this Users::SessionsController,  for Devise

class Users::SessionsController < Devise::SessionsController
  include ApplicationHelper

  after_filter :set_company_id,:only =>[ :new, :create ]
  after_filter :clear_company_id, :only =>[:destroy]

  def set_company_id
    if current_user && current_user.company
      set_company_in_cookie(Array(current_user.company.id))
    end
  end

  def clear_company_id
        cookies.delete(:company_id)
  end
end

require 'test_helper'

Then in my Test I have this... Im using Devise so I use sign_in @user
to log into the system, sign_in should be over
Users::SessionsController then the after_filter must be called and
set_company_in_cookie(Array(current_user.company.id)) be called, this
helper set company id in session.. but do not happend so then in the
view when I try to get the value from session I get nil.. what Im
doing wrong ? thanks

class WorkordersControllerTest < ActionController::TestCase
  setup do
    @user =  FactoryGirl.create(:gustavo_de_antonio)
  end

  test "should get index" do
   sign_in @user
   get :index
   assert_response :success
   assert_template :index
  end

end


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Carlos Antonio da Silva  
View profile  
 More options May 10 2012, 8:37 am
From: Carlos Antonio da Silva <carlosantoniodasi...@gmail.com>
Date: Thu, 10 May 2012 09:37:26 -0300
Local: Thurs, May 10 2012 8:37 am
Subject: Re: [devise] functinal testing, sign_in test helper

Does this work when you manually test? Are just the automated tests that are failing?

--
At.
Carlos Antonio


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Pablo Rodriguez  
View profile  
 More options May 14 2012, 7:54 am
From: Pablo Rodriguez <pablorodriguez...@gmail.com>
Date: Mon, 14 May 2012 04:54:43 -0700 (PDT)
Local: Mon, May 14 2012 7:54 am
Subject: Re: [devise] functinal testing, sign_in test helper

Yes it work when I use the application with a navigator, after login I need
to put user's company id in the session... is there any better aproach for
that ?
seems like when I run the Functional test the  Users::SessionsController 's
filters are not been called, the class is loaded , I put msg in the class
and see the msg in logs but the
filters methods are never called...
do you suggest to use other aproach for this ?

thanks for your response

El jueves, 10 de mayo de 2012 09:37:26 UTC-3, Carlos Antonio da Silva
escribió:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »