Sha256: 353ce54c14b29b21eaea10ca8e2e93a39024443fe7593b9ef4f1b4fccca8ab01

Contents?: true

Size: 1.19 KB

Versions: 6

Compression:

Stored size: 1.19 KB

Contents

require 'spec_helper'

module Bookkeeper
  describe SearchController do
    describe "POST create" do
      describe "with search results" do
        it "assigns the researched term as @q" do
          post :create, {search: {q: 'searchable'}, use_route: :purchases}
          expect(assigns(:q)).to eq('searchable')
        end
        it "Finds the purchase by title" do
          purchase = create(:bookkeeper_purchase, title: 'My searchable purchase')
          post :create, {search: {q: 'searchable'}, use_route: :purchases}
          expect(assigns(:results)).to eq([purchase])
        end
        it "Finds the purchase by description" do
          purchase = create(:bookkeeper_purchase, description: 'My searchable purchase')
          post :create, {search: {q: 'searchable'}, use_route: :purchases}
          expect(assigns(:results)).to eq([purchase])
        end
      end

      describe "without search results" do
        it "Doesn't find the purchase" do
          purchase = create(:bookkeeper_purchase, title: 'My searchable purchase')
          post :create, {search: {q: 'unsearchable'}, use_route: :purchases}
          expect(assigns(:results)).to eq([])
        end
      end
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
bookkeeper-0.0.7 spec/controllers/bookkeeper/search_controller_spec.rb
bookkeeper-0.0.6 spec/controllers/bookkeeper/search_controller_spec.rb
bookkeeper-0.0.5 spec/controllers/bookkeeper/search_controller_spec.rb
bookkeeper-0.0.4 spec/controllers/bookkeeper/search_controller_spec.rb
bookkeeper-0.0.3 spec/controllers/bookkeeper/search_controller_spec.rb
bookkeeper-0.0.2 spec/controllers/bookkeeper/search_controller_spec.rb