[rspec-users] search controller

farheen at deeproot.co.in farheen at deeproot.co.in
Tue Jun 26 11:40:40 UTC 2012


 Hi all,
 having problems to mock params for the following controller, need help
    def index
    if params[:q].present?
      @q = params[:q]
      @field = params[:field]
      case @field
      when "filenames"
        @attachments = Attachment.where( :file_name => /#{@q}/i )
        @documents = Array.new
        @attachments.each do |a|
          @documents << a.document
        end
        @documents.uniq!
      when "vendor_code", "document_number", "batch_number", "cheque_number"
        @documents = Document.where( @field => @q )
      end
      puts "@documents = #{@documents.inspect}"
    end
  end
 Regards,
 Farheen Zahara







More information about the rspec-users mailing list