Commit f4ebf2abff5639cec4818b677163acf2891614dc
1 parent
3e453e44
Exists in
master
and in
29 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 | 31 | end |
32 | 32 | |
33 | 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 | 36 | redirect_to :action => :index, :q => params[:q], :filter => params[:filter] |
37 | 37 | end |
38 | 38 | |
39 | 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 | 42 | redirect_to :action => :index, :q => params[:q], :filter => params[:filter] |
43 | 43 | end |
44 | 44 | |
45 | 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 | 48 | redirect_to :action => :index, :q => params[:q], :filter => params[:filter] |
49 | 49 | end |
50 | 50 | |
51 | 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 | 54 | redirect_to :action => :index, :q => params[:q], :filter => params[:filter] |
55 | 55 | end |
56 | 56 | |
... | ... | @@ -58,8 +58,8 @@ class UsersController < AdminController |
58 | 58 | respond_to do |format| |
59 | 59 | format.html |
60 | 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 | 63 | :skip_types => true, |
64 | 64 | :only => %w[email login created_at updated_at], |
65 | 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 | -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
test/functional/users_controller_test.rb
... | ... | @@ -11,6 +11,9 @@ class UsersControllerTest < ActionController::TestCase |
11 | 11 | @request = ActionController::TestRequest.new |
12 | 12 | @response = ActionController::TestResponse.new |
13 | 13 | |
14 | + | |
15 | + Environment.delete_all | |
16 | + Environment.create(:name => 'some env', :is_default => true) | |
14 | 17 | admin_user = create_user_with_permission('adminuser', 'manage_environment_users', Environment.default) |
15 | 18 | login_as('adminuser') |
16 | 19 | end | ... | ... |