To edit pages or tickets please login with username/password: aaf/aaf

Changeset 232

Show
Ignore:
Timestamp:
08/27/07 20:38:27 (1 year ago)
Author:
jk
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/demo/app/models/search.rb

    r223 r232  
    1515  # run the search 
    1616  def run 
    17     Content.find_with_ferret @query, :page => @page, :per_page => 10, :sort => 'title' 
     17    Content.find_with_ferret @query, :page => @page, :per_page => 10, :sort => 'title', :lazy => true 
    1818  end 
    1919end 
  • trunk/demo/app/views/contents/edit.rhtml

    r228 r232  
    11<h1>Editing content</h1> 
    22 
    3 <% form_tag :action => 'update', :id => @content do %> 
     3<% form_for :content, @content, content_path(@content), :html => { :method => :put } do |f| %> 
    44  <%= render :partial => 'form', :object => f %> 
    55  <%= submit_tag 'Edit' %> 
    66<% end %> 
    77 
    8 <%= link_to 'Show', :action => 'show', :id => @content %> | 
    9 <%= link_to 'Back', :action => 'list' %> 
     8<%= link_to 'Show', content_path(@content) %> | 
     9<%= link_to 'Back', contents_path %> 
  • trunk/demo/app/views/searches/search.html.erb

    r230 r232  
    11<h1>Search</h1> 
    2 <% form_tag search_path do |f| %> 
     2<% form_tag search_path do %> 
    33  <fieldset> 
    44    <legend>Search</legend> 
  • trunk/demo/test/functional/contents_controller_test.rb

    r228 r232  
    99 
    1010  def setup 
    11     @controller = ContentController.new 
     11    @controller = ContentsController.new 
    1212    @request    = ActionController::TestRequest.new 
    1313    @response   = ActionController::TestResponse.new 
  • trunk/demo/test/functional/searches_controller_test.rb

    r228 r232  
    99 
    1010  def setup 
    11     @controller = SearchController.new 
     11    @controller = SearchesController.new 
    1212    @request    = ActionController::TestRequest.new 
    1313    @response   = ActionController::TestResponse.new 
     
    1515  end 
    1616 
    17   def test_show 
     17  def test_search 
    1818    get :search 
    19     assert_template 'show
     19    assert_template 'search
    2020    assert_response :success 
    2121    assert_nil assigns(:results) 
     
    2424  def test_search 
    2525    get :search, :q => 'title' 
    26     assert_template 'show
     26    assert_template 'search
    2727    assert_equal 1, assigns(:results).total_hits 
    2828    assert_equal 1, assigns(:results).size 
    2929     
    3030    get :search, :q => 'monkey' 
    31     assert_template 'show
     31    assert_template 'search
    3232    assert assigns(:results).empty? 
    3333     
     
    3939    Content.create :title => 'another content object', :description => 'description goes hers' 
    4040    get :search, :q => 'another' 
    41     assert_template 'show
     41    assert_template 'search
    4242    assert_equal 1, assigns(:results).total_hits 
    4343    assert_equal 1, assigns(:results).size 
  • trunk/demo/test/unit/content_test.rb

    r228 r232  
    274274  end 
    275275 
    276   # TODO: Sort usage fails with drb 
    277   #def test_sort_class 
    278   #  sorting = Ferret::Search::Sort.new(Ferret::Search::SortField.new(:id, :type => :string, :reverse => true)) 
    279   #  result = Content.find_by_contents('comment_count:2 OR comment_count:1', :sort => sorting) 
    280   #  assert result.size > 2 
    281   #  result = Content.find_by_contents('comment_count:2 OR comment_count:1', :sort => sorting, :limit => 2) 
    282   #  assert_equal 2, result.size 
    283   #  assert result.first.id > result.last.id 
    284   #end 
    285    
    286   def test_sort_with_limit 
    287     sorting = [ Ferret::Search::SortField.new(:id, :type => :string, :reverse => true) ] 
     276  def test_sort_class 
     277    sorting = Ferret::Search::Sort.new(Ferret::Search::SortField.new(:id, :reverse => true)) 
    288278    result = Content.find_by_contents('comment_count:2 OR comment_count:1', :sort => sorting) 
    289279    assert result.size > 2 
     280    assert result.first.id > result.last.id 
     281    result = Content.find_by_contents('comment_count:2 OR comment_count:1', :sort => sorting, :limit => 2) 
     282    assert_equal 2, result.size 
     283    assert result.first.id > result.last.id 
     284  end 
     285   
     286  def test_sort_with_limit 
     287    sorting = [ Ferret::Search::SortField.new(:id) ] 
     288    result = Content.find_by_contents('comment_count:2 OR comment_count:1', :sort => sorting) 
     289    assert result.size > 2 
     290    assert result.first.id < result.last.id 
     291    result = Content.find_by_contents('comment_count:2 OR comment_count:1', :sort => sorting, :limit => 2) 
     292    assert_equal 2, result.size 
     293    assert result.first.id < result.last.id 
     294 
     295    sorting = [ Ferret::Search::SortField.new(:id, :reverse => true) ] 
     296    result = Content.find_by_contents('comment_count:2 OR comment_count:1', :sort => sorting) 
     297    assert result.size > 2 
     298    assert result.first.id > result.last.id 
    290299    result = Content.find_by_contents('comment_count:2 OR comment_count:1', :sort => sorting, :limit => 2) 
    291300    assert_equal 2, result.size 

To edit pages or tickets please login with username/password: aaf/aaf