Commit d0cd60465334f7bb141ae5a54b398477484e71dd
Committed by
Gust
1 parent
2915c278
Exists in
master
and in
29 other branches
Addded cucumber test
-Added tests for ban user -Added also tests for activate/deactivate users -Added also tests for set admin role (ActionItem3021) Signed-off-by: Alex Campelo <campelo.al1@gmail.com> Signed-off-by: Gustavo Jaruga <darksshades@gmail.com>
Showing
4 changed files
with
63 additions
and
16 deletions
Show diff stats
app/controllers/admin/users_controller.rb
| @@ -42,17 +42,19 @@ class UsersController < AdminController | @@ -42,17 +42,19 @@ class UsersController < AdminController | ||
| 42 | def deactivate | 42 | def deactivate |
| 43 | person = environment.people.find(params[:id]) | 43 | person = environment.people.find(params[:id]) |
| 44 | person.user.deactivate | 44 | person.user.deactivate |
| 45 | - puts "++"*80, person | ||
| 46 | - puts "++"*80, person.user | ||
| 47 | - puts "++"*80, person.user.activated? | ||
| 48 | redirect_to :action => :index, :q => params[:q], :filter => params[:filter] | 45 | redirect_to :action => :index, :q => params[:q], :filter => params[:filter] |
| 49 | end | 46 | end |
| 50 | 47 | ||
| 51 | - | 48 | + |
| 52 | def destroy_user | 49 | def destroy_user |
| 53 | - person = environment.people.find(params[:id]) | ||
| 54 | - person.destroy | ||
| 55 | - session[:notice] = _('The profile was deleted.') | 50 | + if request.post? |
| 51 | + person = environment.people.find(params[:id]) | ||
| 52 | + if person.destroy | ||
| 53 | + session[:notice] = _('The profile was deleted.') | ||
| 54 | + else | ||
| 55 | + session[:notice] = _('Could not delete profile') | ||
| 56 | + end | ||
| 57 | + end | ||
| 56 | redirect_to :action => :index, :q => params[:q], :filter => params[:filter] | 58 | redirect_to :action => :index, :q => params[:q], :filter => params[:filter] |
| 57 | end | 59 | end |
| 58 | 60 | ||
| @@ -98,7 +100,7 @@ class UsersController < AdminController | @@ -98,7 +100,7 @@ class UsersController < AdminController | ||
| 98 | end | 100 | end |
| 99 | end | 101 | end |
| 100 | 102 | ||
| 101 | - private | 103 | + private |
| 102 | 104 | ||
| 103 | def per_page | 105 | def per_page |
| 104 | 10 | 106 | 10 |
app/views/users/_users_list.rhtml
| @@ -19,18 +19,16 @@ | @@ -19,18 +19,16 @@ | ||
| 19 | <td class='actions'> | 19 | <td class='actions'> |
| 20 | <div class="members-buttons-cell"> | 20 | <div class="members-buttons-cell"> |
| 21 | <% if p.is_admin? %> | 21 | <% if p.is_admin? %> |
| 22 | - <%= button_without_text :'reset-admin-role', _('Reset admin role'), {:action => 'reset_admin_role', :id => p, :q => @q}, :filter => @filter, :confirm => "delete_article_message(@article)" %> | 22 | + <%= button_without_text :'reset-admin-role', _('Reset admin role'), {:action => 'reset_admin_role', :id => p, :q => @q}, :filter => @filter, :confirm => _("Do you want to reset this user as administrator?") %> |
| 23 | <% else %> | 23 | <% else %> |
| 24 | - <%= button_without_text :'set-admin-role', _('Set admin role'), {:action => 'set_admin_role', :id => p, :q => @q}, :filter => @filter, :confirm => "delete_article_message(@article)" %> | 24 | + <%= button_without_text :'set-admin-role', _('Set admin role'), {:action => 'set_admin_role', :id => p, :q => @q}, :filter => @filter, :confirm => _("Do you want to set this user as administrator?") %> |
| 25 | <% end %> | 25 | <% end %> |
| 26 | <% if !p.user.activated? %> | 26 | <% if !p.user.activated? %> |
| 27 | - <%= button_without_text :'activate-user', _('Activate user'), {:action => 'activate', :id => p, :q => @q}, :filter => @filter, :confirm => "delete_article_message(@article)" %> | 27 | + <%= button_without_text :'activate-user', _('Activate user'), {:action => 'activate', :id => p, :q => @q}, :filter => @filter, :confirm => _("Do you want to activate this user?") %> |
| 28 | <% else %> | 28 | <% else %> |
| 29 | - <%= button_without_text :'deactivate-user', _('Deactivate user'), {:action => 'deactivate', :id => p, :q => @q}, :filter => @filter, :confirm => "delete_article_message(@article)" %> | 29 | + <%= button_without_text :'deactivate-user', _('Deactivate user'), {:action => 'deactivate', :id => p, :q => @q}, :filter => @filter, :confirm => _("Do you want to deactivate this user?") %> |
| 30 | <% end %> | 30 | <% end %> |
| 31 | - | ||
| 32 | - <%= button_without_text :'delete', _('Ban'), {:action => :destroy_user, :id => p, :q => @q}, :filter => @filter, :confirm => "delete_article_message(@article)" %> | ||
| 33 | - | 31 | + <%= button_without_text :'delete', _('Remove'), {:action => :destroy_user, :id => p, :q => @q}, :method => :post, :filter => @filter, :confirm => _("Do you want to remove this user?") %> |
| 34 | </div> | 32 | </div> |
| 35 | </td> | 33 | </td> |
| 36 | </tr> | 34 | </tr> |
| @@ -0,0 +1,47 @@ | @@ -0,0 +1,47 @@ | ||
| 1 | +Feature: manage users | ||
| 2 | + As an environment administrator | ||
| 3 | + I want to manage users | ||
| 4 | + In order to remove, activate, deactivate users, and set admin roles. | ||
| 5 | + | ||
| 6 | +Background: | ||
| 7 | + Given the following users | ||
| 8 | + | login | name | | ||
| 9 | + | joaosilva | Joao Silva | | ||
| 10 | + | paulosantos | Paulo Santos | | ||
| 11 | + Given I am logged in as admin | ||
| 12 | + Given I go to /admin/users | ||
| 13 | + | ||
| 14 | + @selenium | ||
| 15 | + Scenario: deactive user | ||
| 16 | + When I follow "Deactivate user" within "tr[title='Joao Silva']" | ||
| 17 | + And I confirm the "Do you want to deactivate this user?" dialog | ||
| 18 | + Then I should see "Activate user" within "tr[title='Joao Silva']" | ||
| 19 | + | ||
| 20 | + @selenium | ||
| 21 | + Scenario: activate user | ||
| 22 | + Given I follow "Deactivate user" within "tr[title='Paulo Santos']" | ||
| 23 | + Given I confirm the "Do you want to deactivate this user?" dialog | ||
| 24 | + When I follow "Activate user" within "tr[title='Paulo Santos']" | ||
| 25 | + And I confirm the "Do you want to activate this user?" dialog | ||
| 26 | + Then I should see "Deactivate user" within "tr[title='Paulo Santos']" | ||
| 27 | + | ||
| 28 | + @selenium | ||
| 29 | + Scenario: ban user | ||
| 30 | + When I follow "Remove" within "tr[title='Joao Silva']" | ||
| 31 | + And I confirm the "Do you want to remove this user?" dialog | ||
| 32 | + And I go to /admin/users | ||
| 33 | + Then I should not see "Joao Silva" | ||
| 34 | + | ||
| 35 | + @selenium | ||
| 36 | + Scenario: admin user | ||
| 37 | + When I follow "Set admin role" within "tr[title='Joao Silva']" | ||
| 38 | + And I confirm the "Do you want to set this user as administrator?" dialog | ||
| 39 | + Then I should see "Reset admin role" within "tr[title='Joao Silva']" | ||
| 40 | + | ||
| 41 | + @selenium | ||
| 42 | + Scenario: unadmin user | ||
| 43 | + Given I follow "Set admin role" within "tr[title='Paulo Santos']" | ||
| 44 | + And I confirm the "Do you want to set this user as administrator?" dialog | ||
| 45 | + When I follow "Reset admin role" within "tr[title='Paulo Santos']" | ||
| 46 | + And I confirm the "Do you want to reset this user as administrator?" dialog | ||
| 47 | + Then I should see "Set admin role" within "tr[title='Paulo Santos']" | ||
| 0 | \ No newline at end of file | 48 | \ No newline at end of file |
public/stylesheets/application.css
| @@ -4198,7 +4198,7 @@ h1#agenda-title { | @@ -4198,7 +4198,7 @@ h1#agenda-title { | ||
| 4198 | } | 4198 | } |
| 4199 | 4199 | ||
| 4200 | .actions .members-buttons-cell { | 4200 | .actions .members-buttons-cell { |
| 4201 | -width : 100px | 4201 | + width : 100px |
| 4202 | } | 4202 | } |
| 4203 | 4203 | ||
| 4204 | .controller-profile_members .msie6 .button-bar a { | 4204 | .controller-profile_members .msie6 .button-bar a { |