Skip to content

Commit

Permalink
Shipcy banned users (publiclab#7181)
Browse files Browse the repository at this point in the history
* Update admin_controller.rb

* modified useremail function to include banned users

* Update modified useremail function to include banned users

* Update modified useremail function to include banned users

* Update modified useremail function to include banned users

* Update modified useremail function to include banned users

* Update app/controllers/modified useremail function to include banned users

Co-Authored-By: Sparks <[email protected]>

* Update modified useremail function to include banned users

* rename admin_controller.rb back

* Update admin_controller_test.rb

* Update codecov.yml

Co-authored-by: Shipra Choudhary <[email protected]>
Co-authored-by: Sparks <[email protected]>
Co-authored-by: Jeffrey Warren <[email protected]>
  • Loading branch information
4 people committed Jan 10, 2020
1 parent 08ab5c0 commit 6ae4850
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 13 deletions.
30 changes: 18 additions & 12 deletions app/controllers/admin_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,26 @@ def reset_user_password
end
end

def useremail
if logged_in_as(['admin', 'moderator'])
if params[:address]
# address was submitted. find the username(s) and return.
@address = params[:address]
@users = User.where(email: params[:address])
.where(status: [1, 4])
end
else
# unauthorized. instead of return ugly 403, just send somewhere else
redirect_to '/dashboard'
end
def useremail
if logged_in_as(['admin', 'moderator'])
if params[:address]
# address was submitted. find the username(s) and return.
@address = params[:address]
if params[:include_banned]
@users = User.where(email: params[:address])
.where('created_at > (?)', DateTime.new(2015)) # since 2015, whether banned or not
else
@users = User.where(email: params[:address])
.where(status: [1, 4])
end
end
else
# unauthorized. instead of return ugly 403, just send somewhere else
redirect_to '/dashboard'
end
end


def spam
if logged_in_as(['admin', 'moderator'])
@nodes = Node.paginate(page: params[:page])
Expand Down
4 changes: 3 additions & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ coverage:
project:
default:
threshold: 1%
patch: on
patch:
default:
threshold: 50%

ignore:
- app/assets/stylesheets/
17 changes: 17 additions & 0 deletions test/functional/admin_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -662,4 +662,21 @@ def teardown
assert_response :success
assert_not_nil assigns(:comments)
end

test 'admin user should be able to view page to search users by email' do
UserSession.create(users(:admin))

get :useremail

assert_response :success
end

test 'admin user should be able to search users by email' do
UserSession.create(users(:admin))

get :useremail, params: { address: '[email protected]', include_banned: 'true' }

assert_response :success
assert_not_nil assigns(:users)
end
end

0 comments on commit 6ae4850

Please sign in to comment.