Commit a4675300f0cbaa05a6553e044067224476d0a51c
1 parent
31d88a94
Exists in
master
and in
29 other branches
ActionItem862: removing unused code
Showing
3 changed files
with
0 additions
and
145 deletions
Show diff stats
app/controllers/my_profile/enterprise_editor_controller.rb
@@ -1,44 +0,0 @@ | @@ -1,44 +0,0 @@ | ||
1 | -class EnterpriseEditorController < MyProfileController | ||
2 | - protect 'edit_profile', :profile, :user, :except => :destroy | ||
3 | - protect 'destroy_profile', :profile, :only => :destroy | ||
4 | - | ||
5 | - requires_profile_class(Enterprise) | ||
6 | - before_filter :enterprise | ||
7 | - | ||
8 | - # Show details about an enterprise | ||
9 | - def index | ||
10 | - end | ||
11 | - | ||
12 | - # Provides an interface to editing the enterprise details | ||
13 | - def edit | ||
14 | - @validation_entities = Organization.find(:all) - [@enterprise] | ||
15 | - end | ||
16 | - | ||
17 | - # Saves the changes made in an enterprise | ||
18 | - def update | ||
19 | - if @enterprise.update_attributes(params[:enterprise]) | ||
20 | - redirect_to :action => 'index' | ||
21 | - else | ||
22 | - flash[:notice] = _('Could not update the enterprise') | ||
23 | - @validation_entities = Organization.find(:all) - [@enterprise] | ||
24 | - render :action => 'edit' | ||
25 | - end | ||
26 | - end | ||
27 | - | ||
28 | - # Elimitates the enterprise of the system | ||
29 | - def destroy | ||
30 | - #raise "bli" | ||
31 | - if @enterprise.destroy | ||
32 | - flash[:notice] = _('Enterprise sucessfully erased from the system') | ||
33 | - redirect_to :controller => 'profile_editor', :action => 'index', :profile => current_user.login | ||
34 | - else | ||
35 | - redirect_to :action => 'index' | ||
36 | - end | ||
37 | - end | ||
38 | - | ||
39 | - protected | ||
40 | - | ||
41 | - def enterprise | ||
42 | - @enterprise = @profile | ||
43 | - end | ||
44 | -end |
app/helpers/enterprise_editor_helper.rb
test/functional/enterprise_editor_controller_test.rb
@@ -1,99 +0,0 @@ | @@ -1,99 +0,0 @@ | ||
1 | -require File.dirname(__FILE__) + '/../test_helper' | ||
2 | -require 'enterprise_editor_controller' | ||
3 | - | ||
4 | -# Re-raise errors caught by the controller. | ||
5 | -class EnterpriseEditorController; def rescue_action(e) raise e end; end | ||
6 | - | ||
7 | -class EnterpriseEditorControllerTest < Test::Unit::TestCase | ||
8 | - def setup | ||
9 | - @controller = EnterpriseEditorController.new | ||
10 | - @request = ActionController::TestRequest.new | ||
11 | - @request.stubs(:ssl?).returns(true) | ||
12 | - @response = ActionController::TestResponse.new | ||
13 | - end | ||
14 | - | ||
15 | - def test_local_files_reference | ||
16 | - user = create_user('test_user').person | ||
17 | - assert_local_files_reference :get, :index, :profile => user.identifier | ||
18 | - end | ||
19 | - | ||
20 | - def test_valid_xhtml | ||
21 | - assert_valid_xhtml | ||
22 | - end | ||
23 | - | ||
24 | - should 'not see index if do not logged in' do | ||
25 | - ent1 = Enterprise.create!(:identifier => 'test_enterprise1', :name => 'Test enteprise1') | ||
26 | - get 'index', :profile => 'test_enterprise1' | ||
27 | - | ||
28 | - assert_response 403 | ||
29 | - assert_template 'access_denied.rhtml' | ||
30 | - end | ||
31 | - | ||
32 | - should 'not see index if do not have permission to edit profile' do | ||
33 | - user = create_user('test_user') | ||
34 | - ent = Enterprise.create!(:identifier => 'test_enterprise', :name => 'Test enteprise') | ||
35 | - login_as :test_user | ||
36 | - | ||
37 | - get 'index', :profile => 'test_enterprise' | ||
38 | - | ||
39 | - assert_response 403 | ||
40 | - assert @controller.send(:profile) | ||
41 | - assert_equal ent.identifier, @controller.send(:profile).identifier | ||
42 | - assert_template 'access_denied.rhtml' | ||
43 | - end | ||
44 | - | ||
45 | - should 'see index if have permission' do | ||
46 | - ent = Enterprise.create!(:identifier => 'test_enterprise', :name => 'Test enterprise') | ||
47 | - user = create_user('test_user').person | ||
48 | - role = Role.create!(:name => 'test_role', :permissions => ['edit_profile']) | ||
49 | - assert user.add_role(role, ent) | ||
50 | - assert user.has_permission?('edit_profile', ent) | ||
51 | - login_as :test_user | ||
52 | - | ||
53 | - assert_equal ent, Profile.find_by_identifier('test_enterprise') | ||
54 | - | ||
55 | - get 'index', :profile => 'test_enterprise' | ||
56 | - | ||
57 | - assert_response :success | ||
58 | - assert_equal ent, @controller.send(:profile) | ||
59 | - assert_equal user, @controller.send(:user) | ||
60 | - assert_template 'index' | ||
61 | - end | ||
62 | - | ||
63 | - should 'show the edit form' do | ||
64 | - ent = Enterprise.create!(:identifier => 'test_enterprise', :name => 'Test enterprise') | ||
65 | - user = create_user_with_permission('test_user', 'edit_profile', ent) | ||
66 | - login_as :test_user | ||
67 | - | ||
68 | - get 'edit', :profile => 'test_enterprise' | ||
69 | - | ||
70 | - assert_response :success | ||
71 | - assert_equal ent, @controller.send(:profile) | ||
72 | - assert_template 'edit' | ||
73 | - end | ||
74 | - | ||
75 | - should 'update' do | ||
76 | - ent = Enterprise.create!(:identifier => 'test_enterprise', :name => 'Test enterprise') | ||
77 | - user = create_user_with_permission('test_user', 'edit_profile', ent) | ||
78 | - login_as :test_user | ||
79 | - | ||
80 | - post 'update', :profile => 'test_enterprise', :enterprise => {:acronym => 'bla'} | ||
81 | - | ||
82 | - assert_response :redirect | ||
83 | - assert_redirected_to :action => 'index' | ||
84 | - ent.reload | ||
85 | - assert_equal 'bla', ent.acronym | ||
86 | - end | ||
87 | - | ||
88 | - should 'destroy' do | ||
89 | - ent = Enterprise.create!(:identifier => 'test_enterprise', :name => 'Test enterprise') | ||
90 | - user = create_user_with_permission('test_user', 'destroy_profile', ent) | ||
91 | - login_as :test_user | ||
92 | - | ||
93 | - post 'destroy', :profile => 'test_enterprise' | ||
94 | - | ||
95 | - assert_response :redirect | ||
96 | - assert_redirected_to :controller => 'profile_editor', :profile => 'test_user' | ||
97 | - end | ||
98 | - | ||
99 | -end |