public
Fork of halorgium/mephisto
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/technoweenie/mephisto.git
Click here to lend your support to: mephisto and make a donation at www.pledgie.com !
Ignore drafts and articles published in the future when searching.

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@1972 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Fri Sep 01 12:22:39 -0700 2006
commit  194a4fb25944b30f9bdb42fabfda1c2cd1c227ab
tree    1462918bae976012d93445ec246124b46c0e41b1
parent  9f06066806c2295d36a3c198936ead11fe44af73
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 * SVN *
0
 
0
+* Ignore drafts and articles published in the future when searching.
0
+
0
 * sanitize posted comments
0
 
0
 * Fix bug where atom feed content from textile was double encoded
...
19
20
21
22
 
23
24
25
...
19
20
21
 
22
23
24
25
0
@@ -19,7 +19,7 @@ class MephistoController < ApplicationController
0
   end
0
 
0
   def search
0
- conditions = ['published_at <= :now AND title LIKE :q OR excerpt LIKE :q OR body LIKE :q',
0
+ conditions = ['(published_at IS NOT NULL AND published_at <= :now) AND (title LIKE :q OR excerpt LIKE :q OR body LIKE :q)',
0
                      { :now => Time.now.utc, :q => "%#{params[:q]}%" }]
0
     search_count = site.articles.count(conditions)
0
     @article_pages = Paginator.new self, search_count, site.articles_per_page, params[:page]
...
23
24
25
26
 
27
28
29
...
23
24
25
 
26
27
28
29
0
@@ -23,7 +23,7 @@
0
         ] %>
0
       </select>
0
       <select name="section" id="sectionlist">
0
- <option value="0">&mdash;Select a section&mdash;</option>
0
+ <option value="0">&mdash;All Sections&mdash;</option>
0
         <%= options_from_collection_for_select @sections, :id, :name, params[:section].to_i %>
0
       </select>
0
     </li>
...
26
27
28
29
 
30
31
 
32
33
34
...
26
27
28
 
29
30
 
31
32
33
34
0
@@ -26,9 +26,9 @@ site_map_about:
0
   article_id: 7
0
   section_id: 2
0
   position: 3
0
-unpublished_home:
0
+future_home:
0
   id: 6
0
- article_id: 4
0
+ article_id: 5
0
   section_id: 1
0
   position: 1
0
 cupcake_welcome_home:
...
19
20
21
22
 
23
24
25
...
19
20
21
 
22
23
24
25
0
@@ -19,7 +19,7 @@ class Admin::SectionsControllerTest < Test::Unit::TestCase
0
     assert_equal sites(:first), assigns(:site)
0
     assert_equal sections(:home), assigns(:home)
0
     assert_equal 2, assigns(:sections).length, "Sections: #{assigns(:sections).inspect}"
0
- assert_equal 2, assigns(:article_count)['1']
0
+ assert_equal 3, assigns(:article_count)['1']
0
     assert_equal 3, assigns(:article_count)['2']
0
   end
0
 
...
139
140
141
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
143
144
...
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
0
@@ -139,6 +139,22 @@ class MephistoControllerTest < Test::Unit::TestCase
0
     assert_template_type :search
0
   end
0
 
0
+ def test_should_search_and_not_find_draft
0
+ get :search, :q => 'draft'
0
+ assert_equal [], assigns(:articles)
0
+ assert_preferred_template :search
0
+ assert_layout_template :layout
0
+ assert_template_type :search
0
+ end
0
+
0
+ def test_should_search_and_not_find_future
0
+ get :search, :q => 'future'
0
+ assert_equal [], assigns(:articles)
0
+ assert_preferred_template :search
0
+ assert_layout_template :layout
0
+ assert_template_type :search
0
+ end
0
+
0
   def test_should_show_entry
0
     date = 3.days.ago
0
     get :show, :year => date.year, :month => date.month, :day => date.day, :permalink => 'welcome-to-mephisto'

Comments

    No one has commented yet.