Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5987311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:47:47+00:00 2026-05-22T22:47:47+00:00

I know the ideal thing to do would be to fill the login form

  • 0

I know the ideal thing to do would be to fill the login form and follow that flow. The thing is that I am not using devise for login in. I do login in my application the user after authenticating with Facebook and fb_graph gem.

So the devise sign_in view only has the link “connect with Facebook”, but I am able to see that route, and I assume that will try to sign_in a user if a post is made to that url.

I tried doing a post to the sign_in (which view is empty) directly with cucumber, and even though the response is ok, the user is not logged in.

Given /^I am a logged in user$/ do
  @user = Factory(:user)
  res = post("/users/sign_in", :email => @user.email, :password => "password")
  p res
end

How can I test this?

Thanks,

UPDATE:

The scenario looks like this:

Scenario: Going to the index page
  Given I am a logged in user
  And there is a subject created
  And there is 1 person for that subject
  When I go to that subject persons index page
  And show me the page
  Then I should see "Back to Subjects list"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T22:47:48+00:00Added an answer on May 22, 2026 at 10:47 pm

    Instead of doing that, which I am not proud of I ended up doing the following:

    Application controller

    before_filter :authenticate_user!, :except => [:login]
    
    # This action is supposed to only be accessed in the test environment.
    # This is for being able of running the cucumber tests.
    def login
      @user = User.find(params[:id])
      sign_in(@user)
      current_user = @user
      render :text => "user logged in"
    end
    

    Routes

    # This is for being able of testing the application with cucumber. Since we are not using devise defaults login
    match 'login/:id' => 'application#login', :as => 'login', :via => [:get] if Rails.env.test?
    

    User Steps

    Given /^I am a logged in (student|employee)+ user$/ do |role|
      @user = @that = Factory(:user, :role => role, :name => "#{role} User Name")
      Given("that user is logged in")
    end
    
    Given /^that user is logged in$/ do
      Given("I go to that users login page")
    end
    

    Path

    when /that users login page/
      login_path(@that || @user)
    

    This Way in my scenarios I only have to type:

    Given I am a logged in student user
    

    And the rest is just normal cucumber…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not the biggest fan of WordPress, but I think the one thing that
I have a PHP application form for medical health plans where the user fills
I know the ideal place to ask is at . I posted my question
I want to know the ideal instance site for a portal, may it be
Does anyone know of any resources that can give me an idea of how
I am looking for ideas but what I want to know is that I
I would like to know if it's a good idea to mix Moustache or
I just started using IntelliJ-IDEA, and I don't know if the problem resides with
I have a form to edit employee information. If the user wishes to enter
I'm looking for an algorithm to do this effect, but it's not helping that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.