Commit 71b98ac5f53730ae103b7cd86438d6a8473d06a5
1 parent
e6aebf76
Exists in
master
and in
22 other branches
ActionItem6: Integration tests added
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@354 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
6 changed files
with
97 additions
and
1 deletions
Show diff stats
app/controllers/enterprise_controller.rb
app/models/profile.rb
| ... | ... | @@ -0,0 +1,32 @@ |
| 1 | +require "#{File.dirname(__FILE__)}/../test_helper" | |
| 2 | + | |
| 3 | +class EditEnterpriseTest < ActionController::IntegrationTest | |
| 4 | + all_fixtures | |
| 5 | + def test_edit_an_enterprise | |
| 6 | + get '/admin/enterprise' | |
| 7 | + assert_response :redirect | |
| 8 | + | |
| 9 | + login('ze', 'test') | |
| 10 | + | |
| 11 | + get '/admin/enterprise' | |
| 12 | + assert_response :redirect | |
| 13 | + | |
| 14 | + follow_redirect! | |
| 15 | + assert_response :success | |
| 16 | + assert_tag :tag => 'a', :attributes => {:href => '/admin/enterprise/edit/5'} | |
| 17 | + | |
| 18 | + get '/admin/enterprise/edit/5' | |
| 19 | + assert_response :success | |
| 20 | + assert_tag :tag => 'input', :attributes => {:name => 'enterprise[name]'} | |
| 21 | + | |
| 22 | + post '/admin/enterprise/update/5', :enterprise => {'name' => 'new_name' } | |
| 23 | + assert_response :redirect | |
| 24 | + | |
| 25 | + follow_redirect! | |
| 26 | + assert_response :redirect | |
| 27 | + | |
| 28 | + follow_redirect! | |
| 29 | + assert_equal '/admin/enterprise/show/5', path | |
| 30 | + | |
| 31 | + end | |
| 32 | +end | ... | ... |
| ... | ... | @@ -0,0 +1,33 @@ |
| 1 | +require "#{File.dirname(__FILE__)}/../test_helper" | |
| 2 | + | |
| 3 | +class RegisterEnterpriseTest < ActionController::IntegrationTest | |
| 4 | + all_fixtures | |
| 5 | + | |
| 6 | + def test_register_new_enterprise | |
| 7 | + get '/admin/enterprise' | |
| 8 | + assert_response :redirect | |
| 9 | + | |
| 10 | + login('ze','test') | |
| 11 | + | |
| 12 | + get '/admin/enterprise' | |
| 13 | + assert_response :redirect | |
| 14 | + | |
| 15 | + follow_redirect! | |
| 16 | + assert_response :success | |
| 17 | + assert_tag :tag => 'a', :attributes => {:href => '/admin/enterprise/register_form'} | |
| 18 | + | |
| 19 | + get '/admin/enterprise/register_form' | |
| 20 | + assert_response :success | |
| 21 | + assert_tag :tag => 'input', :attributes => {:name => 'enterprise[name]'} | |
| 22 | + assert_tag :tag => 'input', :attributes => {:name => 'enterprise[identifier]'} | |
| 23 | + | |
| 24 | + post '/admin/enterprise/register', :enterprise => {'name' => 'new_enterprise', 'identifier' => 'enterprise_new'} | |
| 25 | + assert_response :redirect | |
| 26 | + | |
| 27 | + follow_redirect! | |
| 28 | + assert_response :redirect | |
| 29 | + | |
| 30 | + follow_redirect! | |
| 31 | + assert_response :success | |
| 32 | + end | |
| 33 | +end | ... | ... |
| ... | ... | @@ -0,0 +1,18 @@ |
| 1 | +require "#{File.dirname(__FILE__)}/../test_helper" | |
| 2 | + | |
| 3 | +class SearchEnterpriseTest < ActionController::IntegrationTest | |
| 4 | + all_fixtures | |
| 5 | + | |
| 6 | + def test_search_by_name_or_tag | |
| 7 | + login('ze', 'test') | |
| 8 | + get '/admin/enterprise' | |
| 9 | + assert_response :redirect | |
| 10 | + | |
| 11 | + follow_redirect! | |
| 12 | + assert_response :success | |
| 13 | + assert_tag :tag => 'input', :attributes => {'name', 'query'} | |
| 14 | + | |
| 15 | + get '/admin/enterprise/search', :query => 'bla' | |
| 16 | + assert_response :success | |
| 17 | + end | |
| 18 | +end | ... | ... |
test/unit/profile_test.rb
| ... | ... | @@ -76,4 +76,13 @@ class ProfileTest < Test::Unit::TestCase |
| 76 | 76 | |
| 77 | 77 | assert pe.profiles.include?(pr) |
| 78 | 78 | end |
| 79 | + | |
| 80 | + def test_search | |
| 81 | + p = Profile.create(:name => 'wanted', :identifier => 'wanted') | |
| 82 | + p.update_attribute(:tag_list, 'bla') | |
| 83 | + | |
| 84 | + assert Profile.search('wanted').include?(p) | |
| 85 | + assert Profile.search('bla').include?(p) | |
| 86 | + assert ! Profile.search('not_wanted').include?(p) | |
| 87 | + end | |
| 79 | 88 | end | ... | ... |