title: Controller action not running in rspec test
body: <p>I'm trying to test the index action of a controller that I have. I want it to return instances of something called Moments, which belong to a user. I am using FactoryGirl and Rspec. I verify the user has moments, as when I call <code>@user.moments</code>, it returns them. However when I use <code>get :index</code>, it returns a 200 with an empty <code>response.body</code>. </p>
  
  <p>Here is my Rspec:</p>
  
  <pre><code>require 'spec_helper'
  
  describe Api::V1::MomentsController do
  
      before do
          @moment = FactoryGirl.create(:moment)
      end
      it 'should return moments' do
          expect(controller).to receive(:index)
          @user = @moment.user
          request.env['Authorization'] = "Token token=#{@user.authentication_token}"
          get :index
          expect(response.status).to eq(200)
          puts response.body
      end
      after do
          @moment = nil
          @user = nil
      end 
  end
  </code></pre>
  
  <p>Here is my Factory:</p>
  
  <pre><code>FactoryGirl.define do
      def time_rand from = 0.0, to = Time.now 
        Time.at(from + rand * (to.to_f - from.to_f))
      end
      sequence :email do |n|
        "email#{n}@ploonky.com"
      end
      sequence :fullname do |n|
        "Waiter Number#{n}"
      end
      sequence :handle do |n|
        "Person#{n}"
      end
  
      factory :user, :aliases =&gt; [:owner] do
        fullname 
        birthdate "1978-12-12"
        email 
        password "password1"
        password_confirmation "password1"
        handle
        tags {
          Array(10).sample.times.map do
            FactoryGirl.create(:tag)
          end
        }
     end
     sequence :datetime do
       "#{time_rand}"
     end
     factory :moment do
       datetime 
       text "can't wait to get through this busy day"
       association :location, :factory =&gt; :location 
       user_id { location.user_id }
       is_public true
       is_deleted false
     end
  
    factory :location do
      label "home"
      street "248 Mckibbin st"
      city "brooklyn"
      state "NY"
      zip "11206"
      latitude 40.7063048
      longitude -73.9396323 
      association :user, :factory =&gt; :user
      country "USA"
      is_deleted false
    end
  
    factory :tag do 
      value "busy as hell"
      is_deleted false 
    end
  end
  </code></pre>
  
  <p>And finally, the controller action:</p>
  
  <pre><code>class Api::V1::MomentsController &lt; ApplicationController
    before_filter :restrict_access, :except =&gt; :public
    respond_to :json
    def index
      updateDate=params['updated_at'] ? DateTime.iso8601(params['updated_at']) : nil
      include_deleted = params['include_deleted'] ? params['include_deleted'].to_i : nil
  
      friends_ids=Friendship.get_friends(api_user,Friendship::APPROVED)
      friends_ids=friends_ids.map do |friend_ids|
        if friend_ids
          friend_ids[:id]
        end
      end
      user_ids=friends_ids.append(api_user.id) 
  
      moments=Moment.user_moments(user_ids, include_deleted == 1)
  
      #filter out moments older than updateDate
      if updateDate
        moments=moments.where('updated_at&gt;?',updateDate)
      end
      moments=buildFullMoments(moments, api_user)
      render :json =&gt; moments
    end
  end
  </code></pre>