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

  • Home
  • SEARCH
  • 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 6874923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:15:21+00:00 2026-05-27T04:15:21+00:00

I have trying to solve an issue with my Spec tests and I get

  • 0

I have trying to solve an issue with my Spec tests and I get the following error
Failures:

  1) SessionsController POST 'create' with valid email and password should sign in the user
     Failure/Error: Unable to find matching line from backtrace
     SystemStackError:
       stack level too deep
     # /Users/Aurelien/.rvm/gems/ruby-1.9.2-p290@rails3/gems/activerecord-3.1.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:103

Finished in 37.77 seconds
9 examples, 1 failure

Failed examples:

rspec ./spec/controllers/sessions_controller_spec.rb:35 # SessionsController POST 'create' with valid email and password should sign in the user

Prior to this I had problems with associations with my factories.

Factory.define :role do |role|
  role.name                   "Registered"
  role.association :user, :factory => :user
end

Factory.define :admin do |role|
  role.name                   "Admin"
  role.association :user, :factory => :user
end

Factory.define :user do |user|
  user.first_name             "Foo"
  user.last_name              "Bar"
  user.email                  "foo@bar.com"
  user.password               "foobar"
  user.password_confirmation  "foobar"
  user.status                 "At foobar"
  user.description            "Lorem Ipsum sit dolor amet."
  user.username               "foobar"
  user.association :role, :factory => :role
  user.association :admin, :factory => :role
end

Factory.define :user_with_admin_role, :parent => :user do |user|
  user.after_create { |u| Factory(:role, :user => u) }
end

Factory.define :reg_user do |user|
  user.first_name             "bar"
  user.last_name              "foo"
  user.email                  "bar@foo.com"
  user.password               "foobar"
  user.password_confirmation  "foobar"
  user.status                 "At foobar"
  user.description            "Lorem Ipsum sit dolor amet."
  user.username               "barfoo"
  user.association :role, :factory => :role
end

and my session tests so far are:

describe "POST 'create'" do
    describe "invalid signin" do
      before(:each) do
        @attr = { :email => "email@example.org", :password => "invalid" }
      end

      it "should re-render the 'new' page with a flash error" do
        post :create, :session => @attr
        flash.now[:error] =~ /invalid/i
        response.should render_template('new')
      end

    end

    describe "with valid email and password" do

      before(:each) do
        @user = Factory(:user)
        @attr = { :email => @user.email, :password => @user.password}
      end

      it "should sign in the user" do
        post :create, :session => @attr
        controller.current_user.should == @user
      end

    end

  end

I am really not sure what is creating the problem.
In my model I assign a default role to every user as “Registered” and the “Admin” role for the first user.

user.rb

def assign_default_role
    if User.count == 0
      self.roles << Role.find_by_name("Admin")
      self.roles << Role.find_by_name("Registered")
    end
    self.roles << Role.find_by_name("Registered") unless User.count == 0
  end

Any advise would be most welcome.
Thanks

  • 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-27T04:15:22+00:00Added an answer on May 27, 2026 at 4:15 am

    The problem line is this:

    @user = Factory(:user)
    

    You have a circular reference: your :user factory creates a :role and :admin factory. Then the :role and :admin factories each create another :user factory, which then creates yet another :role and :admin factory, and so on until you get a stack level too deep error.

    You’ll need to remove the associations from some of these. I’d recommend removing the role.association lines from both :role and :admin. Whenever you create a :user, it will still create the :role and :admin lines for you.

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

Sidebar

Related Questions

The issue I am trying to solve is that I have a folder with
for quite a while I have been trying to solve an issue with a
im trying to solve this issue. I have a web site with this simplified
I have a difficult JSF issue I am trying to solve. Note, I am
I have been trying to solve this issue for a day now and have
I have a rather complicated issue that I am trying to solve in PHP
I have been trying to solve this problem for a while, but couldn't with
In trying to solve the ajax back button problem I have found the Really
Trying to solve a problem with templatetags. I have two templatetags: @register.inclusion_tag('directory/_alphabet.html') def alphabet_list(names):
I'm trying to solve the 3n+1 problem and I have a for loop 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.