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 6213879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:46:34+00:00 2026-05-24T06:46:34+00:00

The following is in my spec/controllers/superadmin/users_controller_spec.rb: describe GET index do it receives the where

  • 0

The following is in my spec/controllers/superadmin/users_controller_spec.rb:

  describe "GET index" do
    it "receives the where action twice" do
      User.should_receive(:where).twice
      get :index
    end

    it "assigns @superadmins" do
      get :index
      assigns[:superadmins].should_not be_nil
    end

    it "assigns @admins" do
      get :index
      assigns[:admins].should_not be_nil
    end
  end

The following is in my app/controllers/superadmin/users_controller.rb:

class Superadmin::UsersController < SuperadminController
  def index
    @superadmins = User.where(:role => 'superadmin')
    @admins = User.where(:role => 'admin')
  end
  ...
end

If I recall correctly, this test used to pass. Ever since I set up PostgreSQL as the database for the test and development environments, this test has been failing… not sure why.

Error message:

Failures:

  1) Superadmin::UsersController GET index receives the where action twice
     Failure/Error: User.should_receive(:where).twice
       (<User(id: integer, role: string, first_name: string, last_name: string, login: string, email: string, crypted_password: string, password_salt: string, persistence_token: string, single_access_token: string, perishable_token: string, login_count: integer, failed_login_count: integer, last_request_at: datetime, current_login_at: datetime, last_login_at: datetime, current_login_ip: string, last_login_ip: string, created_at: datetime, updated_at: datetime, restaurant_id: integer, organization_id: integer) (class)>).where(any args)
           expected: 2 times
           received: 0 times
     # ./spec/controllers/superadmin/users_controller_spec.rb:6:in `block (3 levels) in <top (required)>'

  2) Superadmin::UsersController GET index assigns @superadmins
     Failure/Error: assigns[:superadmins].should_not be_nil
       expected: not nil
            got: nil
     # ./spec/controllers/superadmin/users_controller_spec.rb:12:in `block (3 levels) in <top (required)>'

  3) Superadmin::UsersController GET index assigns @admins
     Failure/Error: assigns[:admins].should_not be_nil
       expected: not nil
            got: nil
     # ./spec/controllers/superadmin/users_controller_spec.rb:17:in `block (3 levels) in <top (required)>

Assistance appreciated!

  • 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-24T06:46:35+00:00Added an answer on May 24, 2026 at 6:46 am

    I don’t see anything in the code you’ve provided that would make those tests fail. Do you have any before_filters that might be failing? I’m guessing that controller requires authentication. Are you setting that up in your tests in a before block?

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

Sidebar

Related Questions

I'm trying to run the following spec: describe UsersController, GET friends do it should
I'm trying to test/spec the following action method public virtual ActionResult ChangePassword(ChangePasswordModel model) {
When I run rspec spec I get the following: /usr/local/lib/ruby/gems/1.9.1/gems/rspec-rails-2.7.0/lib/rspec/rails/extensions/active_record/base.rb:26:in `': uninitialized constant ActiveModel
In my routes.rb i have the following: get 'home/index' root :to => 'home#index' If
I have a spec: it should redirect to the log_books_controller#new action when a user
Our code: describe GET show do it assigns the requested subcategory as @subcategory do
I have following spec to test controller method: context #create do it should redirect
In a branch spec, I have the following view: //depot/dev/t/a/g/... //depot/dev/t/r/g/... -//depot/dev/t/a/g/p/o*/... //depot/dev/t/r/g/p/... Perforce
Following is the association between 2 models: class FotoGossip < ActiveRecord::Base has_many :uploads end
Here is my current users_controller_spec.rb file require 'spec_helper' describe UsersController do render_views . .

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.