[groonga-commit:4224] ranguba/ranguba [master] [test] categorize.

null+ranguba at clear-code.com null+ranguba at clear-code.com
Sun Jan 15 03:10:17 EST 2012


Kouhei Sutou	2012-01-15 17:10:17 +0900 (Sun, 15 Jan 2012)

  New Revision: 99c60b71a00042aa49824667244401c39794fc69

  Log:
    [test] categorize.

  Modified files:
    test/integration/search_test.rb

  Modified: test/integration/search_test.rb (+122 -129)
===================================================================
--- test/integration/search_test.rb    2012-01-15 16:36:51 +0900 (9aef015)
+++ test/integration/search_test.rb    2012-01-15 17:10:17 +0900 (083fc96)
@@ -43,23 +43,23 @@ class SearchTest < ActionDispatch::IntegrationTest
 
   class ValidConditionTest < self
     def test_query
-      assert_visit "/search/query/HTML"
-      assert_found :total_count => 1,
+      assert_visit("/search/query/HTML")
+      assert_found(:total_count => 1,
                    :entries_count => 1,
                    :topic_path => [["query", "HTML"]],
                    :drilldown => {:type => ["html"],
                                   :category => ["test"]},
-                   :pagination => "1/1"
+                   :pagination => "1/1")
     end
 
     def test_query_string
       visit("/search?search_request[type]=html&search_request[query]=HTML")
       assert_equal("/search/type/html/query/HTML", current_full_path)
-      assert_found :total_count => 1,
+      assert_found(:total_count => 1,
                    :entries_count => 1,
                    :topic_path => [["type", "html"], ["query", "HTML"]],
                    :drilldown => {:category => ["test"]},
-                   :pagination => "1/1"
+                   :pagination => "1/1")
     end
   end
 
@@ -85,6 +85,7 @@ class SearchTest < ActionDispatch::IntegrationTest
     end
 
     def test_one_page
+      assert_visit("/search/")
       search("HTML entry")
       assert_found(:total_count => 1,
                    :entries_count => 1,
@@ -123,7 +124,7 @@ class SearchTest < ActionDispatch::IntegrationTest
 
   class QueryTest < self
     def test_not_found
-      assert_visit( "/search/")
+      assert_visit("/search/")
       within("div.search_form") do
         fill_in("query", :with => "nonexistent")
         click_link_or_button("Search")
@@ -132,6 +133,73 @@ class SearchTest < ActionDispatch::IntegrationTest
       assert_equal("/search/query/nonexistent", current_path)
       assert_not_found
     end
+
+    def test_drilldown
+      assert_visit("/search/type/html")
+
+      within("div.search_form") do
+        fill_in "query", :with => "entry"
+        click_link_or_button "Search"
+      end
+
+      assert_found(:total_count => 1,
+                   :entries_count => 1,
+                   :topic_path => [["type", "html"],
+                                   ["query", "entry"]],
+                   :drilldown => {:category => ["test"]},
+                   :pagination => "1/1")
+    end
+
+    def test_multi_bytes
+      assert_visit("/search/")
+
+      within("div.search_form") do
+        fill_in "query", :with => "一太郎のドキュメント"
+        click_link_or_button "Search"
+      end
+
+      encoded = CGI.escape("一太郎のドキュメント")
+      assert_equal("/search/query/#{encoded}", current_path)
+      assert_found(:total_count => 1,
+                   :entries_count => 1,
+                   :topic_path => [["query", "一太郎のドキュメント"]],
+                   :drilldown => {:type => ["jxw"],
+                                  :category => ["test"]},
+                   :pagination => "1/1")
+    end
+
+    def test_slash
+      assert_visit("/search/")
+      within("div.search_form") do
+        fill_in("query", :with => "text/html")
+        click_link_or_button("Search")
+      end
+
+      assert_equal("/search/query/text%2Fhtml", current_path)
+      assert_found(:total_count => 1,
+                   :entries_count => 1,
+                   :topic_path => [["query", "text/html"]],
+                   :drilldown => {:type => ["html"],
+                                  :category => ["test"]},
+                   :pagination => "1/1")
+    end
+
+    def test_question
+      assert_visit("/search/")
+      within("div.search_form") do
+        fill_in("query", :with => "unknown type?")
+        click_link_or_button("Search")
+      end
+
+      assert_equal("/search/query/unknown+type%3F", current_path)
+      assert_found(:total_count => 1,
+                   :entries_count => 1,
+                   :topic_path => [["query", "unknown"],
+                                   ["query", "type?"]],
+                   :drilldown => {:type => ["unknown"],
+                                  :category => ["test"]},
+                   :pagination => "1/1")
+    end
   end
 
   class TopicPathTest < self
@@ -221,6 +289,7 @@ class SearchTest < ActionDispatch::IntegrationTest
     end
 
     def test_after_search
+      assert_visit("/search/")
       search("entry")
 
       drilldown("xml (1)")
@@ -234,6 +303,7 @@ class SearchTest < ActionDispatch::IntegrationTest
     end
 
     def test_twice
+      assert_visit("/search/")
       search("entry")
 
       drilldown("HTML (1)")
@@ -255,137 +325,61 @@ class SearchTest < ActionDispatch::IntegrationTest
                    :pagination => "1/1")
     end
 
-    private
-    def drilldown(item_label)
-      within(".search_request") do
-        within(".drilldown_groups") do
-          click_link_or_button(item_label)
-        end
-      end
-    end
-  end
-
-  def test_drilldown_twice_with_multiple_queries
-    search("HTML entry")
-    click_link_or_button "HTML (1)"
-    assert_equal "/search/query/HTML+entry/type/html", current_path
-    click_link_or_button "test (1)"
-    assert_equal "/search/query/HTML+entry/type/html/category/test", current_path
-    assert_found :total_count => 1,
-                 :entries_count => 1,
-                 :topic_path => [["query", "HTML"],
-                                 ["query", "entry"],
-                                 ["type", "html"],
-                                 ["category", "test"]],
-                 :pagination => "1/1"
-  end
-
-  def test_search_result_drilldown_after_search
-    search("entry")
-    item = find("li.search_result_drilldown_category_entry")
-    item.find("a").click
-    assert_equal "/search/query/entry/category/test", current_path
-    assert_found :total_count => @test_category_entries_count,
-                 :entries_count => ENTRIES_PER_PAGE,
-                 :topic_path => [["query", "entry"],
-                                 ["category", "test"]],
-                 :drilldown => {:type => @types},
-                 :pagination => "1/2"
-  end
+    def test_multiple_queries
+      assert_visit("/search/")
+      search("HTML entry")
 
-  def test_search_after_drilldown
-    test_drilldown
+      drilldown("HTML (1)")
+      assert_equal("/search/query/HTML+entry/type/html", current_path)
 
-    within("div.search_form") do
-      fill_in "query", :with => "entry"
-      click_link_or_button "Search"
+      drilldown("test (1)")
+      assert_equal("/search/query/HTML+entry/type/html/category/test",
+                   current_path)
+      assert_found(:total_count => 1,
+                   :entries_count => 1,
+                   :topic_path => [["query", "HTML"],
+                                   ["query", "entry"],
+                                   ["type", "html"],
+                                   ["category", "test"]],
+                   :pagination => "1/1")
     end
 
-    assert_found :total_count => 1,
-                 :entries_count => 1,
-                 :topic_path => [["type", "xml"],
-                                 ["query", "entry"]],
-                 :drilldown => {:category => ["test"]},
-                 :pagination => "1/1"
-  end
-
-  def test_search_with_multibytes_query
-    assert_visit "/search/"
-    within("div.search_form") do
-      fill_in "query", :with => "一太郎のドキュメント"
-      click_link_or_button "Search"
-    end
-
-    encoded = CGI.escape("一太郎のドキュメント")
-    assert_equal "/search/query/#{encoded}", current_path
-    assert_found :total_count => 1,
-                 :entries_count => 1,
-                 :topic_path => [["query", "一太郎のドキュメント"]],
-                 :drilldown => {:type => ["jxw"],
-                                :category => ["test"]},
-                 :pagination => "1/1"
-  end
+    def test_slash_in_context
+      assert_visit("/search/query/text%2Fhtml")
 
-  def test_search_with_query_including_slash
-    assert_visit "/search/"
-    within("div.search_form") do
-      fill_in "query", :with => "text/html"
-      click_link_or_button "Search"
+      drilldown("test (1)")
+      assert_equal("/search/query/text%2Fhtml/category/test", current_path)
+      assert_found(:total_count => 1,
+                   :entries_count => 1,
+                   :topic_path => [["query", "text/html"],
+                                   ["category", "test"]],
+                   :drilldown => {:type => ["html"]},
+                   :pagination => "1/1")
     end
 
-    assert_equal "/search/query/text%2Fhtml", current_path
-    assert_found :total_count => 1,
-                 :entries_count => 1,
-                 :topic_path => [["query", "text/html"]],
-                 :drilldown => {:type => ["html"],
-                                :category => ["test"]},
-                 :pagination => "1/1"
-  end
-
-  def test_drilldown_after_search_including_slash
-    test_search_with_query_including_slash
-
-    item = find("li.search_result_drilldown_category_entry")
-    item.find("a").click
-    assert_equal "/search/query/text%2Fhtml/category/test", current_path
-    assert_found :total_count => 1,
-                 :entries_count => 1,
-                 :topic_path => [["query", "text/html"],
-                                 ["category", "test"]],
-                 :drilldown => {:type => ["html"]},
-                 :pagination => "1/1"
-  end
+    def test_drilldown_after_search_including_question
+      assert_visit("/search/")
+      search("unknown type?")
 
-  def test_search_with_query_including_question
-    assert_visit "/search/"
-    within("div.search_form") do
-      fill_in "query", :with => "unknown type?"
-      click_link_or_button "Search"
-    end
-
-    assert_equal "/search/query/unknown+type%3F", current_path
-    assert_found :total_count => 1,
-                 :entries_count => 1,
-                 :topic_path => [["query", "unknown"],
-                                 ["query", "type?"]],
-                 :drilldown => {:type => ["unknown"],
-                                :category => ["test"]},
-                 :pagination => "1/1"
-  end
+      drilldown("test (1)")
+      assert_equal("/search/query/unknown+type%3F/category/test", current_path)
+      assert_found(:total_count => 1,
+                   :entries_count => 1,
+                   :topic_path => [["query", "unknown"],
+                                   ["query", "type?"],
+                                   ["category", "test"]],
+                   :drilldown => {:type => ["unknown"]},
+                   :pagination => "1/1")
+    end
 
-  def test_drilldown_after_search_including_question
-    test_search_with_query_including_question
-
-    item = find("li.search_result_drilldown_category_entry")
-    item.find("a").click
-    assert_equal "/search/query/unknown+type%3F/category/test", current_path
-    assert_found :total_count => 1,
-                 :entries_count => 1,
-                 :topic_path => [["query", "unknown"],
-                                 ["query", "type?"],
-                                 ["category", "test"]],
-                 :drilldown => {:type => ["unknown"]},
-                 :pagination => "1/1"
+    private
+    def drilldown(item_label)
+      within(".search_request") do
+        within(".drilldown_groups") do
+          click_link_or_button(item_label)
+        end
+      end
+    end
   end
 
   private
@@ -394,7 +388,6 @@ class SearchTest < ActionDispatch::IntegrationTest
   end
 
   def search(query)
-    assert_visit("/search/")
     within("div.search_form") do
       fill_in("query", :with => query)
       click_link_or_button("Search")



More information about the groonga-commit mailing list