module ControllerMacros
#  include Devise::TestHelpers, :type=>:controller
  def login_fet_user
    before(:each) do
      @request.env["devise.mapping"] = Devise.mappings[:user]
      user = FactoryGirl.build(:user)
      user = User.find_by_email(user.email) || user
      user.save
      user.add_role(:fetuser)
     # user.confirm! 
      sign_in user
    end
  end
  def login_user
    before(:each) do
      @request.env["devise.mapping"] = Devise.mappings[:user]
      user = FactoryGirl.build(:other_user)
      user = User.find_by_email(user.email) || user
      user.save
     # user.confirm! 
      sign_in user
    end
  end
  def logout_user
    before(:each) do
      sign_out :user
    end
  end
  def has_invalid_params
          before(:each) do 
        object_class.any_instance.stub(:save).and_return(false)      
        object_class.any_instance.stub(:update_attributes).and_return(false)      

      end

  end

end
