Commit f4ebf2abff5639cec4818b677163acf2891614dc
1 parent
3e453e44
Exists in
staging
and in
42 other branches
fixing functional tests of users controller
Showing
4 changed files
with
14 additions
and
55 deletions
Show diff stats
app/controllers/admin/users_controller.rb
| @@ -31,26 +31,26 @@ class UsersController < AdminController | @@ -31,26 +31,26 @@ class UsersController < AdminController | ||
| 31 | end | 31 | end |
| 32 | 32 | ||
| 33 | def set_admin_role | 33 | def set_admin_role |
| 34 | - @person = environment.people.find(params[:id]) | ||
| 35 | - environment.add_admin(@person) | 34 | + person = environment.people.find(params[:id]) |
| 35 | + environment.add_admin(person) | ||
| 36 | redirect_to :action => :index, :q => params[:q], :filter => params[:filter] | 36 | redirect_to :action => :index, :q => params[:q], :filter => params[:filter] |
| 37 | end | 37 | end |
| 38 | 38 | ||
| 39 | def reset_admin_role | 39 | def reset_admin_role |
| 40 | - @person = environment.people.find(params[:id]) | ||
| 41 | - environment.remove_admin(@person) | 40 | + person = environment.people.find(params[:id]) |
| 41 | + environment.remove_admin(person) | ||
| 42 | redirect_to :action => :index, :q => params[:q], :filter => params[:filter] | 42 | redirect_to :action => :index, :q => params[:q], :filter => params[:filter] |
| 43 | end | 43 | end |
| 44 | 44 | ||
| 45 | def activate | 45 | def activate |
| 46 | - @person = environment.people.find(params[:id]) | ||
| 47 | - @person.user.activate | 46 | + person = environment.people.find(params[:id]) |
| 47 | + person.user.activate | ||
| 48 | redirect_to :action => :index, :q => params[:q], :filter => params[:filter] | 48 | redirect_to :action => :index, :q => params[:q], :filter => params[:filter] |
| 49 | end | 49 | end |
| 50 | 50 | ||
| 51 | def deactivate | 51 | def deactivate |
| 52 | - @person = environment.people.find(params[:id]) | ||
| 53 | - @person.user.deactivate | 52 | + person = environment.people.find(params[:id]) |
| 53 | + person.user.deactivate | ||
| 54 | redirect_to :action => :index, :q => params[:q], :filter => params[:filter] | 54 | redirect_to :action => :index, :q => params[:q], :filter => params[:filter] |
| 55 | end | 55 | end |
| 56 | 56 | ||
| @@ -58,8 +58,8 @@ class UsersController < AdminController | @@ -58,8 +58,8 @@ class UsersController < AdminController | ||
| 58 | respond_to do |format| | 58 | respond_to do |format| |
| 59 | format.html | 59 | format.html |
| 60 | format.xml do | 60 | format.xml do |
| 61 | - @users = User.find(:all, :conditions => {:environment_id => environment.id}, :include => [:person]) | ||
| 62 | - send_data @users.to_xml( | 61 | + users = User.find(:all, :conditions => {:environment_id => environment.id}, :include => [:person]) |
| 62 | + send_data users.to_xml( | ||
| 63 | :skip_types => true, | 63 | :skip_types => true, |
| 64 | :only => %w[email login created_at updated_at], | 64 | :only => %w[email login created_at updated_at], |
| 65 | :include => { :person => {:only => %w[name updated_at created_at address birth_date contact_phone identifier lat lng] } }), | 65 | :include => { :person => {:only => %w[name updated_at created_at address birth_date contact_phone identifier lat lng] } }), |
app/controllers/admin/xxx-environment_users_controller.rb
| @@ -1,44 +0,0 @@ | @@ -1,44 +0,0 @@ | ||
| 1 | -class EnvironmentUsersController < AdminController | ||
| 2 | - | ||
| 3 | - protect 'manage_environment_users', :environment | ||
| 4 | - | ||
| 5 | - def per_page | ||
| 6 | - 10 | ||
| 7 | - end | ||
| 8 | - | ||
| 9 | - def index | ||
| 10 | - @q = params[:q] | ||
| 11 | - if @q.blank? | ||
| 12 | - @collection = environment.people.no_templates(environment).paginate( | ||
| 13 | - :per_page => per_page, | ||
| 14 | - :page => params[:npage] | ||
| 15 | - ) | ||
| 16 | - else | ||
| 17 | - @collection = find_by_contents(:people, environment.people.no_templates(environment), @q, {:per_page => per_page, :page => params[:npage]})[:results] | ||
| 18 | - end | ||
| 19 | - end | ||
| 20 | - | ||
| 21 | - def set_admin_role | ||
| 22 | - @person = environment.people.find(params[:id]) | ||
| 23 | - environment.add_admin(@person) | ||
| 24 | - redirect_to :action => :index, :q => params[:q] | ||
| 25 | - end | ||
| 26 | - | ||
| 27 | - def reset_admin_role | ||
| 28 | - @person = environment.people.find(params[:id]) | ||
| 29 | - environment.remove_admin(@person) | ||
| 30 | - redirect_to :action => :index, :q => params[:q] | ||
| 31 | - end | ||
| 32 | - | ||
| 33 | - def activate | ||
| 34 | - @person = environment.people.find(params[:id]) | ||
| 35 | - @person.user.activate | ||
| 36 | - redirect_to :action => :index, :q => params[:q] | ||
| 37 | - end | ||
| 38 | - | ||
| 39 | - def deactivate | ||
| 40 | - @person = environment.people.find(params[:id]) | ||
| 41 | - @person.user.deactivate | ||
| 42 | - redirect_to :action => :index, :q => params[:q] | ||
| 43 | - end | ||
| 44 | -end |
app/views/users/_users_list.rhtml
| @@ -30,4 +30,4 @@ | @@ -30,4 +30,4 @@ | ||
| 30 | <% end %> | 30 | <% end %> |
| 31 | </table> | 31 | </table> |
| 32 | 32 | ||
| 33 | -<%= pagination_links @collection, {:param_name => 'npage', :page_links => true} %> | ||
| 34 | \ No newline at end of file | 33 | \ No newline at end of file |
| 34 | +<%= pagination_links @collection, {:param_name => 'npage', :page_links => true} %> |
test/functional/users_controller_test.rb
| @@ -11,6 +11,9 @@ class UsersControllerTest < ActionController::TestCase | @@ -11,6 +11,9 @@ class UsersControllerTest < ActionController::TestCase | ||
| 11 | @request = ActionController::TestRequest.new | 11 | @request = ActionController::TestRequest.new |
| 12 | @response = ActionController::TestResponse.new | 12 | @response = ActionController::TestResponse.new |
| 13 | 13 | ||
| 14 | + | ||
| 15 | + Environment.delete_all | ||
| 16 | + Environment.create(:name => 'some env', :is_default => true) | ||
| 14 | admin_user = create_user_with_permission('adminuser', 'manage_environment_users', Environment.default) | 17 | admin_user = create_user_with_permission('adminuser', 'manage_environment_users', Environment.default) |
| 15 | login_as('adminuser') | 18 | login_as('adminuser') |
| 16 | end | 19 | end |