diff --git a/app/controllers/profile_admin/membership_editor_controller.rb b/app/controllers/profile_admin/membership_editor_controller.rb index 7046767..dd60cd3 100644 --- a/app/controllers/profile_admin/membership_editor_controller.rb +++ b/app/controllers/profile_admin/membership_editor_controller.rb @@ -1,12 +1,14 @@ class MembershipEditorController < ProfileAdminController + before_filter :logon + def index @memberships = current_user.person.memberships end def new_enterprise @enterprise = Enterprise.new() - @vitual_communities = Environment.find(:all) + @virtual_communities = Environment.find(:all) @validation_entities = Organization.find(:all) end @@ -29,4 +31,10 @@ class MembershipEditorController < ProfileAdminController def search @tagged_enterprises = Enterprise.search(params[:query]) end + + protected + + def logon + redirect_to :controller => :account unless logged_in? + end end diff --git a/app/views/membership_editor/_enterprise.rhtml b/app/views/membership_editor/_enterprise.rhtml new file mode 100644 index 0000000..1c32c0d --- /dev/null +++ b/app/views/membership_editor/_enterprise.rhtml @@ -0,0 +1,2 @@ +<%= link_to enterprise.name, '/' + enterprise.identifier %> + diff --git a/app/views/membership_editor/index.rhtml b/app/views/membership_editor/index.rhtml index 1b4346b..a15e73b 100644 --- a/app/views/membership_editor/index.rhtml +++ b/app/views/membership_editor/index.rhtml @@ -1,5 +1,9 @@
<%= link_to _('Manage members'), :controller => 'profile_members' %>
-<%= link_to_cms _('Menage content'), profile.identifier %>
+<%= link_to _('Menage content'), :controller => 'cms' %>
<% if @profile.class == Enterprise %><%= link_to _('Edit enterprise info'), :controller => 'enterprise_editor'%>
diff --git a/test/fixtures/role_assignments.yml b/test/fixtures/role_assignments.yml index 36fc30c..aaadc79 100644 --- a/test/fixtures/role_assignments.yml +++ b/test/fixtures/role_assignments.yml @@ -2,7 +2,7 @@ one: id: 1 person_id: 4 - role_id: 1 + role_id: 2 resource_id: 5 resource_type: 'Profile' two: diff --git a/test/functional/admin_panel_controller_test.rb b/test/functional/admin_panel_controller_test.rb index 88f28c2..805d718 100644 --- a/test/functional/admin_panel_controller_test.rb +++ b/test/functional/admin_panel_controller_test.rb @@ -17,8 +17,9 @@ class AdminPanelControllerTest < Test::Unit::TestCase def test_index get :index assert_template 'index' - assert_tag :tag => 'a', :attributes => { :href => /manage_tags/ } + assert_tag :tag => 'a', :attributes => { :href => /categories/ } assert_tag :tag => 'a', :attributes => { :href => /edit_template/ } assert_tag :tag => 'a', :attributes => { :href => /features/ } + assert_tag :tag => 'a', :attributes => { :href => /role/ } end end diff --git a/test/functional/membership_editor_controller_test.rb b/test/functional/membership_editor_controller_test.rb index bb409b2..cac5f65 100644 --- a/test/functional/membership_editor_controller_test.rb +++ b/test/functional/membership_editor_controller_test.rb @@ -9,10 +9,27 @@ class MembershipEditorControllerTest < Test::Unit::TestCase @controller = MembershipEditorController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new + login_as('ze') end + all_fixtures - # Replace this with your real tests. - def test_truth - assert true + should 'list the memberships of the person' do + get :index, :profile => 'ze' + assert assigns(:memberships) + assert_kind_of Array, assigns(:memberships) + end + + should 'propmt for new enterprise data' do + get :new_enterprise, :profile => 'ze' + assert assigns(:virtual_communities) + assert_kind_of Array, assigns(:virtual_communities) + assert assigns(:validation_entities) + assert_kind_of Array, assigns(:validation_entities) + end + + should 'create a new enterprise' do + post :create_enterprise, :profile => 'ze', :enterprise => {:name => 'New Ent', :identifier => 'new_net'} + assert assigns(:enterprise) + assert_kind_of Enterprise, assigns(:enterprise) end end diff --git a/test/integration/activate_enterprise_test.rb b/test/integration/activate_enterprise_test.rb deleted file mode 100644 index 6494db1..0000000 --- a/test/integration/activate_enterprise_test.rb +++ /dev/null @@ -1,25 +0,0 @@ -require "#{File.dirname(__FILE__)}/../test_helper" - -class ActivateEnterpriseTest < ActionController::IntegrationTest - all_fixtures - - def test_activate_approved_enterprise - login('ze', 'test') - - get '/myprofile/ze/enterprise' - assert_response :redirect - - follow_redirect! - assert_response :success - assert_tag :tag => 'a', :attributes => {:href => '/myprofile/ze/enterprise/activate/5'} - - post '/myprofile/ze/enterprise/activate/5' - assert_response :redirect - - follow_redirect! - assert_response :redirect - - follow_redirect! - assert_response :success - end -end diff --git a/test/integration/edit_enterprise_test.rb b/test/integration/edit_enterprise_test.rb index 9b91647..a55f3c2 100644 --- a/test/integration/edit_enterprise_test.rb +++ b/test/integration/edit_enterprise_test.rb @@ -3,30 +3,29 @@ require "#{File.dirname(__FILE__)}/../test_helper" class EditEnterpriseTest < ActionController::IntegrationTest all_fixtures def test_edit_an_enterprise - get '/myprofile/ze/enterprise' - assert_response :redirect + get '/myprofile/colivre/enterprise_editor' + assert_response :success login('ze', 'test') - get '/myprofile/ze/enterprise' - assert_response :redirect + get '/myprofile/colivre/profile_editor' + assert_response :success + assert_tag :tag => 'a', :attributes => { :href => '/myprofile/colivre/enterprise_editor'} - follow_redirect! + get '/myprofile/colivre/enterprise_editor' assert_response :success - assert_tag :tag => 'a', :attributes => { :href => '/myprofile/ze/enterprise/edit/5'} + assert_tag :tag => 'a', :attributes => {:href => '/myprofile/colivre/enterprise_editor/edit/5'} - get '/myprofile/ze/enterprise/edit/5' + get '/myprofile/colivre/enterprise_editor/edit/5' assert_response :success assert_tag :tag => 'input', :attributes => {:name => 'enterprise[name]'} - post '/myprofile/ze/enterprise/update/5', :enterprise => {'name' => 'new_name' } + post '/myprofile/colivre/enterprise_editor/update/5', :enterprise => {'name' => 'new_name'} assert_response :redirect follow_redirect! - assert_response :redirect - - follow_redirect! - assert_equal '/myprofile/ze/enterprise/show/5', path + assert_response :success + assert_equal '/myprofile/colivre/enterprise_editor', path end end diff --git a/test/integration/register_enterprise_test.rb b/test/integration/register_enterprise_test.rb index 93bd434..f0d4565 100644 --- a/test/integration/register_enterprise_test.rb +++ b/test/integration/register_enterprise_test.rb @@ -4,30 +4,24 @@ class RegisterEnterpriseTest < ActionController::IntegrationTest all_fixtures def test_register_new_enterprise - get '/myprofile/ze/enterprise' + get '/myprofile/ze/membership_editor' assert_response :redirect login('ze','test') - get '/myprofile/ze/enterprise' - assert_response :redirect - - follow_redirect! + get '/myprofile/ze/membership_editor' assert_response :success - assert_tag :tag => 'a', :attributes => {:href => '/myprofile/ze/enterprise/register_form'} + assert_tag :tag => 'a', :attributes => {:href => '/myprofile/ze/membership_editor/new_enterprise'} - get '/myprofile/ze/enterprise/register_form' + get '/myprofile/ze/membership_editor/new_enterprise' assert_response :success assert_tag :tag => 'input', :attributes => {:name => 'enterprise[name]'} assert_tag :tag => 'input', :attributes => {:name => 'enterprise[identifier]'} - post '/myprofile/ze/enterprise/register', :enterprise => {'name' => 'new_enterprise', 'identifier' => 'enterprise_new'} + post '/myprofile/ze/membership_editor/create_enterprise', :enterprise => {'name' => 'new_enterprise', 'identifier' => 'enterprise_new'} assert_response :redirect follow_redirect! - assert_response :redirect - - follow_redirect! assert_response :success end end diff --git a/test/integration/search_enterprise_test.rb b/test/integration/search_enterprise_test.rb index fd17349..115b811 100644 --- a/test/integration/search_enterprise_test.rb +++ b/test/integration/search_enterprise_test.rb @@ -5,14 +5,11 @@ class SearchEnterpriseTest < ActionController::IntegrationTest def test_search_by_name_or_tag login('ze', 'test') - get '/myprofile/ze/enterprise' - assert_response :redirect - - follow_redirect! + get '/myprofile/ze/membership_editor' assert_response :success assert_tag :tag => 'input', :attributes => {'name', 'query'} - get '/myprofile/ze/enterprise/search', :query => 'bla' + get '/myprofile/ze/membership_editor/search', :query => 'bla' assert_response :success end end -- libgit2 0.21.2