Commit 230ff308c1fb4729bb41dd9197a28011eb53f600
Committed by
Daniela Feitosa
1 parent
31d9e433
Exists in
master
and in
29 other branches
Removed feature to create and destroy roles
- It is allowed only editing roles (ActionItem1966)
Showing
4 changed files
with
0 additions
and
55 deletions
Show diff stats
app/controllers/admin/role_controller.rb
@@ -9,21 +9,6 @@ class RoleController < AdminController | @@ -9,21 +9,6 @@ class RoleController < AdminController | ||
9 | @role = environment.roles.find(params[:id]) | 9 | @role = environment.roles.find(params[:id]) |
10 | end | 10 | end |
11 | 11 | ||
12 | - def new | ||
13 | - @role = Role.new | ||
14 | - end | ||
15 | - | ||
16 | - def create | ||
17 | - @role = Role.new(params[:role]) | ||
18 | - @role.environment = environment | ||
19 | - if @role.save | ||
20 | - redirect_to :action => 'show', :id => @role | ||
21 | - else | ||
22 | - session[:notice] = _('Failed to create role') | ||
23 | - render :action => 'new' | ||
24 | - end | ||
25 | - end | ||
26 | - | ||
27 | def edit | 12 | def edit |
28 | @role = environment.roles.find(params[:id]) | 13 | @role = environment.roles.find(params[:id]) |
29 | end | 14 | end |
@@ -38,13 +23,4 @@ class RoleController < AdminController | @@ -38,13 +23,4 @@ class RoleController < AdminController | ||
38 | end | 23 | end |
39 | end | 24 | end |
40 | 25 | ||
41 | - def destroy | ||
42 | - @role = environment.roles.find(params[:id]) | ||
43 | - if @role.destroy | ||
44 | - redirect_to :action => 'index' | ||
45 | - else | ||
46 | - session[:notice] = _('Failed to edit role') | ||
47 | - redirect_to :action => 'index' | ||
48 | - end | ||
49 | - end | ||
50 | end | 26 | end |
app/views/role/index.rhtml
@@ -12,13 +12,11 @@ | @@ -12,13 +12,11 @@ | ||
12 | </td> | 12 | </td> |
13 | <td> | 13 | <td> |
14 | <%= button_without_text :edit, _('Edit'), :action => 'edit', :id => role %> | 14 | <%= button_without_text :edit, _('Edit'), :action => 'edit', :id => role %> |
15 | - <%= button_without_text :delete, _('Destroy'), :action => 'destroy', :id => role %> | ||
16 | </td> | 15 | </td> |
17 | </tr> | 16 | </tr> |
18 | <% end %> | 17 | <% end %> |
19 | </table> | 18 | </table> |
20 | 19 | ||
21 | <% button_bar do %> | 20 | <% button_bar do %> |
22 | - <%= button :new, _('New role'), :action => 'new' %> | ||
23 | <%= button :back, _('Back'), :controller => 'admin_panel' %> | 21 | <%= button :back, _('Back'), :controller => 'admin_panel' %> |
24 | <% end %> | 22 | <% end %> |
app/views/role/new.rhtml
@@ -1,6 +0,0 @@ | @@ -1,6 +0,0 @@ | ||
1 | -<h2> <%= _('New Role') %> </h2> | ||
2 | - | ||
3 | -<% ActiveRecord::Base::PERMISSIONS.keys.each do |perm_class| %> | ||
4 | - <h3> <%= gettext(perm_class) %> </h3> | ||
5 | - <%= render :partial => 'form', :locals => { :mode => :new, :role => @role, :permissions => ActiveRecord::Base::PERMISSIONS[perm_class] } %> | ||
6 | -<% end %> |
test/functional/role_controller_test.rb
@@ -38,22 +38,6 @@ class RoleControllerTest < Test::Unit::TestCase | @@ -38,22 +38,6 @@ class RoleControllerTest < Test::Unit::TestCase | ||
38 | assert_equal @role.id, assigns(:role).id | 38 | assert_equal @role.id, assigns(:role).id |
39 | end | 39 | end |
40 | 40 | ||
41 | - def test_should_create_with_valid_paramters | ||
42 | - Role.any_instance.stubs(:valid?).returns(true) | ||
43 | - post 'create' | ||
44 | - assert !assigns(:role).new_record? | ||
45 | - assert_nil session[:notice] | ||
46 | - assert_response :redirect | ||
47 | - end | ||
48 | - | ||
49 | - def test_should_not_create_with_invalid_paramters | ||
50 | - Role.any_instance.stubs(:valid?).returns(false) | ||
51 | - post 'create' | ||
52 | - assert assigns(:role).new_record? | ||
53 | - assert_not_nil session[:notice] | ||
54 | - assert_response :success | ||
55 | - end | ||
56 | - | ||
57 | def test_can_edit | 41 | def test_can_edit |
58 | get 'edit', :id => @role.id | 42 | get 'edit', :id => @role.id |
59 | assert_not_nil assigns(:role) | 43 | assert_not_nil assigns(:role) |
@@ -76,13 +60,6 @@ class RoleControllerTest < Test::Unit::TestCase | @@ -76,13 +60,6 @@ class RoleControllerTest < Test::Unit::TestCase | ||
76 | assert_not_nil session[:notice] | 60 | assert_not_nil session[:notice] |
77 | end | 61 | end |
78 | 62 | ||
79 | - def test_should_destroy | ||
80 | - assert_difference Role, :count, -1 do | ||
81 | - post 'destroy', :id => @role.id | ||
82 | - assert_not_nil assigns(:role) | ||
83 | - end | ||
84 | - end | ||
85 | - | ||
86 | should 'not crash when editing role with no permissions' do | 63 | should 'not crash when editing role with no permissions' do |
87 | role = Role.create!(:name => 'test_role', :environment => Environment.default) | 64 | role = Role.create!(:name => 'test_role', :environment => Environment.default) |
88 | 65 |