Created
March 28, 2012 21:31
-
-
Save mrdanadams/2230763 to your computer and use it in GitHub Desktop.
Revisions
-
mrdanadams revised this gist
Mar 28, 2012 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,3 @@ gem 'sunspot_rails' gem 'kaminari' gem 'sunspot_with_kaminari' -
mrdanadams created this gist
Mar 28, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ gem 'websolr-sunspot_rails' gem 'kaminari' gem 'sunspot_with_kaminari' This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ # Solr faking. # see http://opensoul.org/blog/archives/2010/04/07/cucumber-and-sunspot/ # Note: we need to do more than this if we start doing search tests in cucumber $original_sunspot_session = Sunspot.session Before("~@search") do Sunspot.session = Sunspot::Rails::StubSessionProxy.new($original_sunspot_session) end This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ <h3 class="summary"><%= t('.your-search-header'), start: @start, end: @end, total: pluralize(@total, 'result') %></h3> <% @results.each do |p| %> <div class="result"><!-- ... --></div> <% end %> <%= paginate @search, window: 1 %> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ RSpec.configure do |c| c.before :suite do module Sunspot def self.stub_session @sub_session ||= Sunspot::Rails::StubSessionProxy.new self.session end end end c.before :each do Sunspot.session = Sunspot.stub_session Sunspot.session = Sunspot.session.original_session if example.metadata[:solr] Sunspot.remove_all! end end This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,2 @@ bundle exec rake sunspot:solr:start bundle exec rake sunspot:solr:stop This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ class SearchController < ApplicationController def search page_size = 10 @search = Profile.solr_search do keywords params[:q] do boost_fields name: 10.0, user: 4.0 end with :include_search, true paginate page: params[:page], per_page: page_size end @results = @search.results @total = @search.total @paging = @total > page_size @start = (@search.current_page - 1) * page_size + 1 @end = [@start + page_size - 1, @total].min render (if @results.empty? then :no_results else :results end) end end This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ describe 'Search' do def commit Sunspot.commit end def search(q) visit "/search?q=#{q}" end it 'does something interesting', :solr do Something.create! commit search 'foobar' end This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ # Note: ENV['SOLR_URL'] and ENV['WEBSOLR_URL'] override any values here # The defaults are same as what's below so you only need to override as desired. # Removed production since that should never be used in heroku. # See Sunspot::Rails::Configuration.solr_url development: solr: hostname: localhost port: 8982 log_level: INFO test: solr: hostname: localhost port: 8981 log_level: WARNING