diff --git a/app/controllers/my_profile/enterprise_editor_controller.rb b/app/controllers/my_profile/enterprise_editor_controller.rb deleted file mode 100644 index acf1e65..0000000 --- a/app/controllers/my_profile/enterprise_editor_controller.rb +++ /dev/null @@ -1,44 +0,0 @@ -class EnterpriseEditorController < MyProfileController - protect 'edit_profile', :profile, :user, :except => :destroy - protect 'destroy_profile', :profile, :only => :destroy - - requires_profile_class(Enterprise) - before_filter :enterprise - - # Show details about an enterprise - def index - end - - # Provides an interface to editing the enterprise details - def edit - @validation_entities = Organization.find(:all) - [@enterprise] - end - - # Saves the changes made in an enterprise - def update - if @enterprise.update_attributes(params[:enterprise]) - redirect_to :action => 'index' - else - flash[:notice] = _('Could not update the enterprise') - @validation_entities = Organization.find(:all) - [@enterprise] - render :action => 'edit' - end - end - - # Elimitates the enterprise of the system - def destroy - #raise "bli" - if @enterprise.destroy - flash[:notice] = _('Enterprise sucessfully erased from the system') - redirect_to :controller => 'profile_editor', :action => 'index', :profile => current_user.login - else - redirect_to :action => 'index' - end - end - - protected - - def enterprise - @enterprise = @profile - end -end diff --git a/app/helpers/enterprise_editor_helper.rb b/app/helpers/enterprise_editor_helper.rb deleted file mode 100644 index 606cf04..0000000 --- a/app/helpers/enterprise_editor_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module EnterpriseEditorHelper -end diff --git a/test/functional/enterprise_editor_controller_test.rb b/test/functional/enterprise_editor_controller_test.rb deleted file mode 100644 index 3afdaa1..0000000 --- a/test/functional/enterprise_editor_controller_test.rb +++ /dev/null @@ -1,99 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' -require 'enterprise_editor_controller' - -# Re-raise errors caught by the controller. -class EnterpriseEditorController; def rescue_action(e) raise e end; end - -class EnterpriseEditorControllerTest < Test::Unit::TestCase - def setup - @controller = EnterpriseEditorController.new - @request = ActionController::TestRequest.new - @request.stubs(:ssl?).returns(true) - @response = ActionController::TestResponse.new - end - - def test_local_files_reference - user = create_user('test_user').person - assert_local_files_reference :get, :index, :profile => user.identifier - end - - def test_valid_xhtml - assert_valid_xhtml - end - - should 'not see index if do not logged in' do - ent1 = Enterprise.create!(:identifier => 'test_enterprise1', :name => 'Test enteprise1') - get 'index', :profile => 'test_enterprise1' - - assert_response 403 - assert_template 'access_denied.rhtml' - end - - should 'not see index if do not have permission to edit profile' do - user = create_user('test_user') - ent = Enterprise.create!(:identifier => 'test_enterprise', :name => 'Test enteprise') - login_as :test_user - - get 'index', :profile => 'test_enterprise' - - assert_response 403 - assert @controller.send(:profile) - assert_equal ent.identifier, @controller.send(:profile).identifier - assert_template 'access_denied.rhtml' - end - - should 'see index if have permission' do - ent = Enterprise.create!(:identifier => 'test_enterprise', :name => 'Test enterprise') - user = create_user('test_user').person - role = Role.create!(:name => 'test_role', :permissions => ['edit_profile']) - assert user.add_role(role, ent) - assert user.has_permission?('edit_profile', ent) - login_as :test_user - - assert_equal ent, Profile.find_by_identifier('test_enterprise') - - get 'index', :profile => 'test_enterprise' - - assert_response :success - assert_equal ent, @controller.send(:profile) - assert_equal user, @controller.send(:user) - assert_template 'index' - end - - should 'show the edit form' do - ent = Enterprise.create!(:identifier => 'test_enterprise', :name => 'Test enterprise') - user = create_user_with_permission('test_user', 'edit_profile', ent) - login_as :test_user - - get 'edit', :profile => 'test_enterprise' - - assert_response :success - assert_equal ent, @controller.send(:profile) - assert_template 'edit' - end - - should 'update' do - ent = Enterprise.create!(:identifier => 'test_enterprise', :name => 'Test enterprise') - user = create_user_with_permission('test_user', 'edit_profile', ent) - login_as :test_user - - post 'update', :profile => 'test_enterprise', :enterprise => {:acronym => 'bla'} - - assert_response :redirect - assert_redirected_to :action => 'index' - ent.reload - assert_equal 'bla', ent.acronym - end - - should 'destroy' do - ent = Enterprise.create!(:identifier => 'test_enterprise', :name => 'Test enterprise') - user = create_user_with_permission('test_user', 'destroy_profile', ent) - login_as :test_user - - post 'destroy', :profile => 'test_enterprise' - - assert_response :redirect - assert_redirected_to :controller => 'profile_editor', :profile => 'test_user' - end - -end -- libgit2 0.21.2