Commit 7bf71d8de76ecbbb4ac64988f0e8ca9de0facfdf
1 parent
1504e0b4
Exists in
master
and in
22 other branches
ActionItem4: search action in tags management tested
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@160 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
3 changed files
with
11 additions
and
3 deletions
Show diff stats
app/controllers/manage_tags_controller.rb
| @@ -73,6 +73,6 @@ class ManageTagsController < ApplicationController | @@ -73,6 +73,6 @@ class ManageTagsController < ApplicationController | ||
| 73 | 73 | ||
| 74 | # Full-text search for tags that have the query terms | 74 | # Full-text search for tags that have the query terms |
| 75 | def search | 75 | def search |
| 76 | - @tags_found = Tag.find_by_contents(params[:query][:term]) | 76 | + @tags_found = Tag.find_by_contents(params[:query]) |
| 77 | end | 77 | end |
| 78 | end | 78 | end |
app/views/manage_tags/_search_box.rhtml
| 1 | <div class="search_box"> | 1 | <div class="search_box"> |
| 2 | <% form_tag :action => 'search' do %> | 2 | <% form_tag :action => 'search' do %> |
| 3 | - <%= text_field 'query', 'term'%> | 3 | + <%= text_field_tag 'query' %> |
| 4 | <%= submit_tag _('Search') %> | 4 | <%= submit_tag _('Search') %> |
| 5 | <% end %> | 5 | <% end %> |
| 6 | </div> | 6 | </div> |
test/functional/manage_tags_controller_test.rb
| @@ -100,10 +100,18 @@ class ManageTagsControllerTest < Test::Unit::TestCase | @@ -100,10 +100,18 @@ class ManageTagsControllerTest < Test::Unit::TestCase | ||
| 100 | 100 | ||
| 101 | def test_approve | 101 | def test_approve |
| 102 | pending_tag = Tag.create(:name => 'pending_tag', :pending => true) | 102 | pending_tag = Tag.create(:name => 'pending_tag', :pending => true) |
| 103 | - assert pending_tag.pending? | ||
| 104 | post :approve, :id => pending_tag.id | 103 | post :approve, :id => pending_tag.id |
| 105 | assert_response :redirect | 104 | assert_response :redirect |
| 106 | assert_redirected_to :action => 'list' | 105 | assert_redirected_to :action => 'list' |
| 107 | assert ( not Tag.find_with_pendings(pending_tag.id).pending? ) | 106 | assert ( not Tag.find_with_pendings(pending_tag.id).pending? ) |
| 108 | end | 107 | end |
| 108 | + | ||
| 109 | + def test_search | ||
| 110 | + found_tag = Tag.create(:name => 'found_tag') | ||
| 111 | + lost_tag = Tag.create(:name => 'lost_tag') | ||
| 112 | + post :search, :query => 'found*' | ||
| 113 | + assert_not_nil assigns(:tags_found) | ||
| 114 | + assert assigns(:tags_found).include?(found_tag) | ||
| 115 | + assert (not assigns(:tags_found).include?(lost_tag)) | ||
| 116 | + end | ||
| 109 | end | 117 | end |