Commit 309e733aade7df9151dd0efe8f68c3b953e0b2ad
1 parent
110196ca
Exists in
master
and in
22 other branches
ActionItem65: corrected all test that was not passing
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@585 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
11 changed files
with
57 additions
and
60 deletions
Show diff stats
app/controllers/profile_admin/membership_editor_controller.rb
| 1 | 1 | class MembershipEditorController < ProfileAdminController |
| 2 | 2 | |
| 3 | + before_filter :logon | |
| 4 | + | |
| 3 | 5 | def index |
| 4 | 6 | @memberships = current_user.person.memberships |
| 5 | 7 | end |
| 6 | 8 | |
| 7 | 9 | def new_enterprise |
| 8 | 10 | @enterprise = Enterprise.new() |
| 9 | - @vitual_communities = Environment.find(:all) | |
| 11 | + @virtual_communities = Environment.find(:all) | |
| 10 | 12 | @validation_entities = Organization.find(:all) |
| 11 | 13 | end |
| 12 | 14 | |
| ... | ... | @@ -29,4 +31,10 @@ class MembershipEditorController < ProfileAdminController |
| 29 | 31 | def search |
| 30 | 32 | @tagged_enterprises = Enterprise.search(params[:query]) |
| 31 | 33 | end |
| 34 | + | |
| 35 | + protected | |
| 36 | + | |
| 37 | + def logon | |
| 38 | + redirect_to :controller => :account unless logged_in? | |
| 39 | + end | |
| 32 | 40 | end | ... | ... |
app/views/membership_editor/index.rhtml
app/views/profile_editor/index.rhtml
| ... | ... | @@ -6,7 +6,7 @@ |
| 6 | 6 | |
| 7 | 7 | <p> <%= link_to _('Manage members'), :controller => 'profile_members' %> </p> |
| 8 | 8 | |
| 9 | -<p> <%= link_to_cms _('Menage content'), profile.identifier %> </p> | |
| 9 | +<p> <%= link_to _('Menage content'), :controller => 'cms' %> </p> | |
| 10 | 10 | |
| 11 | 11 | <% if @profile.class == Enterprise %> |
| 12 | 12 | <p> <%= link_to _('Edit enterprise info'), :controller => 'enterprise_editor'%> </p> | ... | ... |
test/fixtures/role_assignments.yml
test/functional/admin_panel_controller_test.rb
| ... | ... | @@ -17,8 +17,9 @@ class AdminPanelControllerTest < Test::Unit::TestCase |
| 17 | 17 | def test_index |
| 18 | 18 | get :index |
| 19 | 19 | assert_template 'index' |
| 20 | - assert_tag :tag => 'a', :attributes => { :href => /manage_tags/ } | |
| 20 | + assert_tag :tag => 'a', :attributes => { :href => /categories/ } | |
| 21 | 21 | assert_tag :tag => 'a', :attributes => { :href => /edit_template/ } |
| 22 | 22 | assert_tag :tag => 'a', :attributes => { :href => /features/ } |
| 23 | + assert_tag :tag => 'a', :attributes => { :href => /role/ } | |
| 23 | 24 | end |
| 24 | 25 | end | ... | ... |
test/functional/membership_editor_controller_test.rb
| ... | ... | @@ -9,10 +9,27 @@ class MembershipEditorControllerTest < Test::Unit::TestCase |
| 9 | 9 | @controller = MembershipEditorController.new |
| 10 | 10 | @request = ActionController::TestRequest.new |
| 11 | 11 | @response = ActionController::TestResponse.new |
| 12 | + login_as('ze') | |
| 12 | 13 | end |
| 14 | + all_fixtures | |
| 13 | 15 | |
| 14 | - # Replace this with your real tests. | |
| 15 | - def test_truth | |
| 16 | - assert true | |
| 16 | + should 'list the memberships of the person' do | |
| 17 | + get :index, :profile => 'ze' | |
| 18 | + assert assigns(:memberships) | |
| 19 | + assert_kind_of Array, assigns(:memberships) | |
| 20 | + end | |
| 21 | + | |
| 22 | + should 'propmt for new enterprise data' do | |
| 23 | + get :new_enterprise, :profile => 'ze' | |
| 24 | + assert assigns(:virtual_communities) | |
| 25 | + assert_kind_of Array, assigns(:virtual_communities) | |
| 26 | + assert assigns(:validation_entities) | |
| 27 | + assert_kind_of Array, assigns(:validation_entities) | |
| 28 | + end | |
| 29 | + | |
| 30 | + should 'create a new enterprise' do | |
| 31 | + post :create_enterprise, :profile => 'ze', :enterprise => {:name => 'New Ent', :identifier => 'new_net'} | |
| 32 | + assert assigns(:enterprise) | |
| 33 | + assert_kind_of Enterprise, assigns(:enterprise) | |
| 17 | 34 | end |
| 18 | 35 | end | ... | ... |
test/integration/activate_enterprise_test.rb
| ... | ... | @@ -1,25 +0,0 @@ |
| 1 | -require "#{File.dirname(__FILE__)}/../test_helper" | |
| 2 | - | |
| 3 | -class ActivateEnterpriseTest < ActionController::IntegrationTest | |
| 4 | - all_fixtures | |
| 5 | - | |
| 6 | - def test_activate_approved_enterprise | |
| 7 | - login('ze', 'test') | |
| 8 | - | |
| 9 | - get '/myprofile/ze/enterprise' | |
| 10 | - assert_response :redirect | |
| 11 | - | |
| 12 | - follow_redirect! | |
| 13 | - assert_response :success | |
| 14 | - assert_tag :tag => 'a', :attributes => {:href => '/myprofile/ze/enterprise/activate/5'} | |
| 15 | - | |
| 16 | - post '/myprofile/ze/enterprise/activate/5' | |
| 17 | - assert_response :redirect | |
| 18 | - | |
| 19 | - follow_redirect! | |
| 20 | - assert_response :redirect | |
| 21 | - | |
| 22 | - follow_redirect! | |
| 23 | - assert_response :success | |
| 24 | - end | |
| 25 | -end |
test/integration/edit_enterprise_test.rb
| ... | ... | @@ -3,30 +3,29 @@ require "#{File.dirname(__FILE__)}/../test_helper" |
| 3 | 3 | class EditEnterpriseTest < ActionController::IntegrationTest |
| 4 | 4 | all_fixtures |
| 5 | 5 | def test_edit_an_enterprise |
| 6 | - get '/myprofile/ze/enterprise' | |
| 7 | - assert_response :redirect | |
| 6 | + get '/myprofile/colivre/enterprise_editor' | |
| 7 | + assert_response :success | |
| 8 | 8 | |
| 9 | 9 | login('ze', 'test') |
| 10 | 10 | |
| 11 | - get '/myprofile/ze/enterprise' | |
| 12 | - assert_response :redirect | |
| 11 | + get '/myprofile/colivre/profile_editor' | |
| 12 | + assert_response :success | |
| 13 | + assert_tag :tag => 'a', :attributes => { :href => '/myprofile/colivre/enterprise_editor'} | |
| 13 | 14 | |
| 14 | - follow_redirect! | |
| 15 | + get '/myprofile/colivre/enterprise_editor' | |
| 15 | 16 | assert_response :success |
| 16 | - assert_tag :tag => 'a', :attributes => { :href => '/myprofile/ze/enterprise/edit/5'} | |
| 17 | + assert_tag :tag => 'a', :attributes => {:href => '/myprofile/colivre/enterprise_editor/edit/5'} | |
| 17 | 18 | |
| 18 | - get '/myprofile/ze/enterprise/edit/5' | |
| 19 | + get '/myprofile/colivre/enterprise_editor/edit/5' | |
| 19 | 20 | assert_response :success |
| 20 | 21 | assert_tag :tag => 'input', :attributes => {:name => 'enterprise[name]'} |
| 21 | 22 | |
| 22 | - post '/myprofile/ze/enterprise/update/5', :enterprise => {'name' => 'new_name' } | |
| 23 | + post '/myprofile/colivre/enterprise_editor/update/5', :enterprise => {'name' => 'new_name'} | |
| 23 | 24 | assert_response :redirect |
| 24 | 25 | |
| 25 | 26 | follow_redirect! |
| 26 | - assert_response :redirect | |
| 27 | - | |
| 28 | - follow_redirect! | |
| 29 | - assert_equal '/myprofile/ze/enterprise/show/5', path | |
| 27 | + assert_response :success | |
| 28 | + assert_equal '/myprofile/colivre/enterprise_editor', path | |
| 30 | 29 | |
| 31 | 30 | end |
| 32 | 31 | end | ... | ... |
test/integration/register_enterprise_test.rb
| ... | ... | @@ -4,30 +4,24 @@ class RegisterEnterpriseTest < ActionController::IntegrationTest |
| 4 | 4 | all_fixtures |
| 5 | 5 | |
| 6 | 6 | def test_register_new_enterprise |
| 7 | - get '/myprofile/ze/enterprise' | |
| 7 | + get '/myprofile/ze/membership_editor' | |
| 8 | 8 | assert_response :redirect |
| 9 | 9 | |
| 10 | 10 | login('ze','test') |
| 11 | 11 | |
| 12 | - get '/myprofile/ze/enterprise' | |
| 13 | - assert_response :redirect | |
| 14 | - | |
| 15 | - follow_redirect! | |
| 12 | + get '/myprofile/ze/membership_editor' | |
| 16 | 13 | assert_response :success |
| 17 | - assert_tag :tag => 'a', :attributes => {:href => '/myprofile/ze/enterprise/register_form'} | |
| 14 | + assert_tag :tag => 'a', :attributes => {:href => '/myprofile/ze/membership_editor/new_enterprise'} | |
| 18 | 15 | |
| 19 | - get '/myprofile/ze/enterprise/register_form' | |
| 16 | + get '/myprofile/ze/membership_editor/new_enterprise' | |
| 20 | 17 | assert_response :success |
| 21 | 18 | assert_tag :tag => 'input', :attributes => {:name => 'enterprise[name]'} |
| 22 | 19 | assert_tag :tag => 'input', :attributes => {:name => 'enterprise[identifier]'} |
| 23 | 20 | |
| 24 | - post '/myprofile/ze/enterprise/register', :enterprise => {'name' => 'new_enterprise', 'identifier' => 'enterprise_new'} | |
| 21 | + post '/myprofile/ze/membership_editor/create_enterprise', :enterprise => {'name' => 'new_enterprise', 'identifier' => 'enterprise_new'} | |
| 25 | 22 | assert_response :redirect |
| 26 | 23 | |
| 27 | 24 | follow_redirect! |
| 28 | - assert_response :redirect | |
| 29 | - | |
| 30 | - follow_redirect! | |
| 31 | 25 | assert_response :success |
| 32 | 26 | end |
| 33 | 27 | end | ... | ... |
test/integration/search_enterprise_test.rb
| ... | ... | @@ -5,14 +5,11 @@ class SearchEnterpriseTest < ActionController::IntegrationTest |
| 5 | 5 | |
| 6 | 6 | def test_search_by_name_or_tag |
| 7 | 7 | login('ze', 'test') |
| 8 | - get '/myprofile/ze/enterprise' | |
| 9 | - assert_response :redirect | |
| 10 | - | |
| 11 | - follow_redirect! | |
| 8 | + get '/myprofile/ze/membership_editor' | |
| 12 | 9 | assert_response :success |
| 13 | 10 | assert_tag :tag => 'input', :attributes => {'name', 'query'} |
| 14 | 11 | |
| 15 | - get '/myprofile/ze/enterprise/search', :query => 'bla' | |
| 12 | + get '/myprofile/ze/membership_editor/search', :query => 'bla' | |
| 16 | 13 | assert_response :success |
| 17 | 14 | end |
| 18 | 15 | end | ... | ... |