-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4a1342e
commit a0ec497
Showing
10 changed files
with
73 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,4 @@ cat import.sql | rails db -p | |
|
||
rails db:migrate | ||
|
||
rake searchkick:reindex_all | ||
rake admin:reindex_all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
namespace :admin do | ||
desc "Reindex all models" | ||
task reindex_all: :environment do | ||
User.reindex | ||
Request.reindex | ||
Item.reindex | ||
Course.reindex | ||
Location.reindex | ||
end | ||
|
||
desc "List invalid users" | ||
task invalid_user_records: :environment do | ||
User.all.each do |u| | ||
if !u.valid? | ||
puts "#{u.id},#{u.username},#{u.univ_id},#{u.email},#{u.role}" | ||
end | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,6 @@ | |
require 'test_helper' | ||
|
||
class SessionsControllerTest < ActionDispatch::IntegrationTest | ||
setup do | ||
@cas_header = 'HTTP_PYORK_USER' | ||
@cas_alt_header = 'HTTP_PYORK_CYIN' | ||
end | ||
|
||
should 'not throw authorization not performed error when using the controller' do | ||
assert_nothing_raised do | ||
|
@@ -17,7 +13,7 @@ class SessionsControllerTest < ActionDispatch::IntegrationTest | |
should 'create a new session information if user logs in' do | ||
user = create(:user, uid: 'test', admin: true, role: User::MANAGER_ROLE) | ||
|
||
get login_url, headers: { @cas_header.to_s => user.uid } | ||
log_user_in(user) | ||
|
||
assert_equal user.id, session[:user_id] | ||
assert_redirected_to root_url | ||
|
@@ -26,23 +22,23 @@ class SessionsControllerTest < ActionDispatch::IntegrationTest | |
|
||
should 'test redirection to a dashboard if the staff is logged in' do | ||
staff = create(:user, uid: '123123123', admin: true, role: User::STAFF_ROLE) | ||
get login_url, headers: { @cas_header.to_s => staff.uid } | ||
log_user_in(staff) | ||
|
||
assert_equal staff.id, session[:user_id] | ||
assert_redirected_to root_url | ||
end | ||
|
||
should 'test redirection to a requests_user_url if the regulard user is logged in' do | ||
user = create(:user, uid: '123123123', admin: false) | ||
get login_url, headers: { @cas_header.to_s => user.uid } | ||
log_user_in(user) | ||
|
||
assert_equal user.id, session[:user_id] | ||
assert_redirected_to requests_user_url(user) | ||
end | ||
|
||
should 'show error 401 if user is not active' do | ||
user = create(:user, uid: '123123123', admin: false, active: false) | ||
get login_url, headers: { @cas_header.to_s => user.uid } | ||
log_user_in(user) | ||
assert_equal 401, response.status | ||
assert_not_nil flash[:alert] | ||
assert_equal 'User not active.', flash[:alert] | ||
|
@@ -51,7 +47,11 @@ class SessionsControllerTest < ActionDispatch::IntegrationTest | |
should "NEW USER, redirect to new user signup if user doesn't exist, no email should be sent yet" do | ||
ActionMailer::Base.deliveries.clear | ||
get logout_url | ||
get login_url, headers: { @cas_header.to_s => 'something_or_other', 'HTTP_PYORK_TYPE' => User::FACULTY } | ||
get login_url, headers: { | ||
'HTTP_PYORK_USER' => 'something_or_other', 'HTTP_PYORK_EMAIL' => '[email protected]', | ||
'HTTP_PYORK_CYIN' => '999999999', 'HTTP_PYORK_TYPE' => User::FACULTY, | ||
'HTTP_PYORK_SURNAME' => 'doe', 'HTTP_PYORK_FIRSTNAME' => 'john' | ||
} | ||
assert ActionMailer::Base.deliveries.empty?, "Should be empty, since we didn't get any details about user" | ||
assert_not_nil session[:user_id], 'Make sure user is logged in' | ||
|
||
|
@@ -62,7 +62,7 @@ class SessionsControllerTest < ActionDispatch::IntegrationTest | |
get logout_url | ||
|
||
assert_nil session[:user_id] | ||
assert_redirected_to Warden::PpyAuthStrategy::LOGOUT_URL | ||
assert_redirected_to Warden::PpyAuthStrategy::PPY_LOGOUT_URL | ||
end | ||
|
||
context 'logged in actions' do | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,19 +14,20 @@ class UserTest < ActiveSupport::TestCase | |
should 'not create an invalid user' do | ||
# common validations | ||
assert !build(:user, email: nil).valid?, 'Should have email' | ||
assert !build(:user, email: 'whwoow').valid?, 'Email should follow proper format' | ||
assert !build(:user, uid: nil).valid?, 'Should have uid' | ||
assert !build(:user, name: nil).valid?, 'Should have a name' | ||
assert !build(:user, user_type: nil).valid?, 'Should have user type' | ||
assert !build(:user, role: nil).valid?, 'Staff must have a role set' | ||
assert !build(:user, username: nil).valid?, 'Should have a username' | ||
|
||
# staff specific validations | ||
assert !build(:user, admin: true, location: nil).valid?, 'Staff must have a location set' | ||
assert !build(:user, email: 'whwoow').valid?, 'Email should follow proper format' | ||
|
||
# ensure uid is unique | ||
# uniqueness | ||
create(:user, uid: 'woot') | ||
assert !build(:user, uid: 'woot').valid?, 'UID must be unique' | ||
create(:user, username: 'woot2') | ||
assert !build(:user, username: 'woot2').valid?, 'username must be unique' | ||
create(:user, email: '[email protected]') | ||
assert !build(:user, email: '[email protected]').valid?, 'email must be unique' | ||
end | ||
|
||
should 'have staff and users scopes' do | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters