diff --git a/.travis.yml b/.travis.yml index abda708fe78..af85ede5ad9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -58,7 +58,7 @@ after_script: - ls -lah coverage/ - cd $HOME - git config --global user.email "zhu6@ncsu.edu" - - git config --global user.name "Winbobob" + - git config --global user.username "Winbobob" - git clone --quiet https://$TOKEN@github.com/expertiza/$REPORT_REPO_NAME.git - cd $REPORT_REPO_NAME - if [ ! -d "./$TRAVIS_PULL_REQUEST" ]; then mkdir $TRAVIS_PULL_REQUEST; fi diff --git a/app/controllers/account_request_controller.rb b/app/controllers/account_request_controller.rb index 396dbe1ac79..88755b98f3e 100644 --- a/app/controllers/account_request_controller.rb +++ b/app/controllers/account_request_controller.rb @@ -37,7 +37,7 @@ def create_approved_user if requested_user.status.nil? flash[:error] = 'Please Approve or Reject before submitting' elsif requested_user.update_attributes(requested_user_params) - flash[:success] = "The user \"#{requested_user.name}\" has been successfully updated." + flash[:success] = "The user \"#{requested_user.username}\" has been successfully updated." end # If the users request is approved, they are stored as a user in the database if requested_user.status == 'Approved' @@ -47,7 +47,7 @@ def create_approved_user elsif requested_user.status == 'Rejected' # If the user request has been rejected, a flash message is shown and redirected to review page if requested_user.update_columns(status: is_approved) - flash[:success] = "The user \"#{requested_user.name}\" has been Rejected." + flash[:success] = "The user \"#{requested_user.username}\" has been Rejected." # redirect_to action: 'list_pending_requested' # return else @@ -61,7 +61,7 @@ def create_approved_user # Creates a new user if their request is approved def user_new(requested_user) new_user = User.new - new_user.name = requested_user.name + new_user.username = requested_user.username new_user.role_id = requested_user.role_id new_user.institution_id = requested_user.institution_id new_user.fullname = requested_user.fullname @@ -75,7 +75,7 @@ def user_new(requested_user) prepared_mail = MailerHelper.send_mail_to_user(new_user, 'Your Expertiza account and password have been created.', 'user_welcome', password) prepared_mail.deliver_now flash[:success] = "A new password has been sent to new user's e-mail address." - undo_link("The user \"#{requested_user.name}\" has been successfully created. ") + undo_link("The user \"#{requested_user.username}\" has been successfully created. ") else foreign end @@ -108,7 +108,7 @@ def list_pending_requested def create_requested_user_record requested_user = AccountRequest.new(requested_user_params) # An object is created with respect to AccountRequest model inorder to populate the users information when account is requested - (user_exists = User.find_by(name: requested_user.name)) || User.find_by(name: requested_user.email) + (user_exists = User.find_by(username: requested_user.username)) || User.find_by(username: requested_user.email) requested_user_saved = save_requested_user(requested_user, params) # Stores a boolean value with respect to whether the user data is saved or not if !user_exists && requested_user_saved @@ -122,7 +122,7 @@ def create_requested_user_record flash[:error] = requested_user.errors.full_messages.to_sentence # If saving in the AccountRequests model has failed end - ExpertizaLogger.error LoggerMessage.new(controller_name, requested_user.name, flash[:error], request) + ExpertizaLogger.error LoggerMessage.new(controller_name, requested_user.username, flash[:error], request) redirect_to controller: 'account_request', action: 'new', role: 'Student' # if the first if clause fails, redirect back to the account requests page! end @@ -152,8 +152,8 @@ def notify_supers_new_request(requested_user) prepared_mail.deliver end # Notifying an email to the administrator regarding the new user request! - ExpertizaLogger.info LoggerMessage.new(controller_name, requested_user.name, 'The account you are requesting has been created successfully.', request) - flash[:success] = "User signup for \"#{requested_user.name}\" has been successfully requested." + ExpertizaLogger.info LoggerMessage.new(controller_name, requested_user.username, 'The account you are requesting has been created successfully.', request) + flash[:success] = "User signup for \"#{requested_user.username}\" has been successfully requested." # Print out the acknowledgement message to the user and redirect to /instructors/home page when successful end @@ -163,7 +163,7 @@ def roles_for_request_sign_up end def requested_user_params - params.require(:user).permit(:name, :role_id, :fullname, :institution_id, :email) + params.require(:user).permit(:username, :role_id, :fullname, :institution_id, :email) .merge(self_introduction: params[:requested_user][:self_introduction]) end end diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 780bd00d2a3..e38d96443cb 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -22,7 +22,7 @@ def show_super_administrator end def list_administrators - @users = User.admins.order(:name).where('parent_id = ?', current_user.id).paginate(page: params[:page], per_page: 50) + @users = User.admins.order(:username).where('parent_id = ?', current_user.id).paginate(page: params[:page], per_page: 50) end def show_administrator @@ -31,7 +31,7 @@ def show_administrator end def list_instructors - @users = User.instructors.order(:name).where('parent_id = ?', current_user.id).paginate(page: params[:page], per_page: 50) + @users = User.instructors.order(:username).where('parent_id = ?', current_user.id).paginate(page: params[:page], per_page: 50) end def show_instructor diff --git a/app/controllers/advertise_for_partner_controller.rb b/app/controllers/advertise_for_partner_controller.rb index 5c98196e5c3..a05960a4944 100644 --- a/app/controllers/advertise_for_partner_controller.rb +++ b/app/controllers/advertise_for_partner_controller.rb @@ -28,7 +28,7 @@ def create team = AssignmentTeam.find_by(id: params[:id]) team.update_attributes(advertise_for_partner: true, comments_for_advertisement: params[:comments_for_advertisement]) participant = AssignmentParticipant.find_by(parent_id: team.assignment.id, user_id: session[:user].id) - ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your advertisement has been successfully created.', request) + ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].username, 'Your advertisement has been successfully created.', request) redirect_to view_student_teams_path student_id: participant.id end @@ -41,11 +41,11 @@ def update @team.update_attributes(comments_for_advertisement: params[:comments_for_advertisement]) participant = AssignmentParticipant.find_by(parent_id: @team.assignment.id, user_id: session[:user].id) rescue StandardError - ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].name, 'An error occurred and your advertisement was not updated.', request) + ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].username, 'An error occurred and your advertisement was not updated.', request) flash[:error] = 'An error occurred and your advertisement was not updated!' render action: 'edit' else - ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your advertisement has been successfully updated.', request) + ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].username, 'Your advertisement has been successfully updated.', request) flash[:success] = 'Your advertisement was successfully updated!' redirect_to view_student_teams_path student_id: participant.id end @@ -55,11 +55,11 @@ def remove team.update_attributes(advertise_for_partner: false, comments_for_advertisement: nil) participant = AssignmentParticipant.find_by(parent_id: team.assignment.id, user_id: session[:user].id) rescue StandardError - ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].name, 'An error occurred and your advertisement was not removed', request) + ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].username, 'An error occurred and your advertisement was not removed', request) flash[:error] = 'An error occurred and your advertisement was not removed!' redirect_back fallback_location: root_path else - ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your advertisement has been successfully removed.', request) + ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].username, 'Your advertisement has been successfully removed.', request) flash[:success] = 'Your advertisement was successfully removed!' redirect_to view_student_teams_path student_id: participant.id end diff --git a/app/controllers/assignments_controller.rb b/app/controllers/assignments_controller.rb index 33e3da8bd30..dda82d289f9 100644 --- a/app/controllers/assignments_controller.rb +++ b/app/controllers/assignments_controller.rb @@ -150,10 +150,10 @@ def delete # FixB : Instrucor will be able to delete any assignment belonging to his/her courses. if (user.role.name == 'Instructor') || ((user.role.name == 'Teaching Assistant') && (user.id == assignment_form.assignment.instructor_id)) assignment_form.delete(params[:force]) - ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, "Assignment #{assignment_form.assignment.id} was deleted.", request) + ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].username, "Assignment #{assignment_form.assignment.id} was deleted.", request) flash[:success] = 'The assignment was successfully deleted.' else - ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'You are not authorized to delete this assignment.', request) + ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].username, 'You are not authorized to delete this assignment.', request) flash[:error] = 'You are not authorized to delete this assignment.' end rescue StandardError => e @@ -410,7 +410,7 @@ def check_questionnaires_usage def unassigned_rubrics_warning if !list_unassigned_rubrics.empty? && request.original_fullpath == "/assignments/#{@assignment_form.assignment.id}/edit" rubrics_needed = needed_rubrics(list_unassigned_rubrics) - ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].name, "Rubrics missing for #{@assignment_form.assignment.name}.", request) + ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].username, "Rubrics missing for #{@assignment_form.assignment.name}.", request) if flash.now[:error] != 'Failed to save the assignment: ["Total weight of rubrics should add up to either 0 or 100%"]' flash.now[:error] = 'You did not specify all the necessary rubrics. You need ' + rubrics_needed + " of assignment #{@assignment_form.assignment.name} before saving the assignment. You can assign rubrics" \ @@ -445,7 +445,7 @@ def update_assignment_badges # flash notice if the time zone is not specified for an assignment's due date def user_timezone_specified - ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].name, 'Timezone not specified', request) if current_user.timezonepref.nil? + ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].username, 'Timezone not specified', request) if current_user.timezonepref.nil? flash.now[:error] = 'You have not specified your preferred timezone yet. Please do this before you set up the deadlines.' if current_user.timezonepref.nil? end @@ -457,11 +457,11 @@ def key_nonexistent_handler @assignment.course_id = params[:course_id] if @assignment.save - ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, "The assignment was successfully saved: #{@assignment.as_json}", request) + ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].username, "The assignment was successfully saved: #{@assignment.as_json}", request) flash[:note] = 'The assignment was successfully saved.' redirect_to list_tree_display_index_path else - ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].name, "Failed assignment: #{@assignment.errors.full_messages.join(' ')}", request) + ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].username, "Failed assignment: #{@assignment.errors.full_messages.join(' ')}", request) flash[:error] = "Failed to save the assignment: #{@assignment.errors.full_messages.join(' ')}" redirect_to edit_assignment_path @assignment.id end @@ -501,7 +501,7 @@ def update_feedback_attributes else flash[:error] = "Failed to save the assignment: #{@assignment_form.errors}" end - ExpertizaLogger.info LoggerMessage.new('', session[:user].name, "The assignment was saved: #{@assignment_form.as_json}", request) + ExpertizaLogger.info LoggerMessage.new('', session[:user].username, "The assignment was saved: #{@assignment_form.as_json}", request) end def query_participants_and_alert diff --git a/app/controllers/auth_controller.rb b/app/controllers/auth_controller.rb index 215d5d977f6..dfa0b8546a9 100644 --- a/app/controllers/auth_controller.rb +++ b/app/controllers/auth_controller.rb @@ -19,7 +19,7 @@ def login if request.get? AuthController.clear_session(session) else - user = User.find_by_login(params[:login][:name]) + user = User.find_by_login(params[:login][:username]) if user && user.valid_password?(params[:login][:password]) after_login(user) else @@ -34,7 +34,7 @@ def login def after_login(user) session[:user] = user session[:impersonate] = false - ExpertizaLogger.info LoggerMessage.new('', user.name, 'Login successful') + ExpertizaLogger.info LoggerMessage.new('', user.username, 'Login successful') AuthController.set_current_role(user.role_id, session) redirect_to controller: AuthHelper.get_home_controller(session[:user]), action: AuthHelper.get_home_action(session[:user]) diff --git a/app/controllers/bookmarks_controller.rb b/app/controllers/bookmarks_controller.rb index d0fd52621a0..dc0da766adb 100644 --- a/app/controllers/bookmarks_controller.rb +++ b/app/controllers/bookmarks_controller.rb @@ -32,10 +32,10 @@ def create params[:url] = params[:url].gsub!(%r{https://}, '') if params[:url].start_with?('https://') begin Bookmark.create(url: create_bookmark_params[:url], title: create_bookmark_params[:title], description: create_bookmark_params[:description], user_id: session[:user].id, topic_id: create_bookmark_params[:topic_id]) - ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your bookmark has been successfully created!', request) + ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].username, 'Your bookmark has been successfully created!', request) flash[:success] = 'Your bookmark has been successfully created!' rescue StandardError - ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, $ERROR_INFO, request) + ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].username, $ERROR_INFO, request) flash[:error] = $ERROR_INFO end redirect_to action: 'list', id: params[:topic_id] @@ -48,7 +48,7 @@ def edit def update @bookmark = Bookmark.find(params[:id]) @bookmark.update_attributes(url: update_bookmark_params[:bookmark][:url], title: update_bookmark_params[:bookmark][:title], description: update_bookmark_params[:bookmark][:description]) - ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your bookmark has been successfully updated!', request) + ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].username, 'Your bookmark has been successfully updated!', request) flash[:success] = 'Your bookmark has been successfully updated!' redirect_to action: 'list', id: @bookmark.topic_id end @@ -56,7 +56,7 @@ def update def destroy @bookmark = Bookmark.find(params[:id]) @bookmark.destroy - ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Your bookmark has been successfully deleted!', request) + ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].username, 'Your bookmark has been successfully deleted!', request) flash[:success] = 'Your bookmark has been successfully deleted!' redirect_to action: 'list', id: @bookmark.topic_id end diff --git a/app/controllers/conference_controller.rb b/app/controllers/conference_controller.rb index 80c69c6505a..4fbd8369ea9 100644 --- a/app/controllers/conference_controller.rb +++ b/app/controllers/conference_controller.rb @@ -51,10 +51,10 @@ def create def add_conference_user # check if user is already present with given username in system - existing_user = User.find_by(name: params[:user][:name]) + existing_user = User.find_by(username: params[:user][:username]) # if user exist then add user as participant to assignment else create account and then add as participant if existing_user.nil? - if !User.find_by(email: params[:user][:email]).nil? || (params[:user][:name].nil? || params[:user][:name].empty?) + if !User.find_by(email: params[:user][:email]).nil? || (params[:user][:username].nil? || params[:user][:username].empty?) flash[:error] = 'A user with username of this email already exists, Please provide a unique email to continue.' # redirect_to request.referrer return false diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index dafd7019f70..f0922d83d48 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -16,9 +16,9 @@ def action_allowed? end def auto_complete_for_user_name - search = params[:user][:name].to_s + search = params[:user][:username].to_s @users = User.where(role_id: 6) if search.present? - render inline: "<%= auto_complete_result @users, 'name' %>", layout: false + render inline: "<%= auto_complete_result @users, 'username' %>", layout: false end # Creates a new course @@ -121,18 +121,18 @@ def view_teaching_assistants # Adds a teaching assistant to a course def add_ta @course = Course.find(params[:course_id]) - @user = User.find_by(name: params[:user][:name]) + @user = User.find_by(username: params[:user][:username]) if @user.nil? - flash.now[:error] = 'The user inputted "' + params[:user][:name] + '" does not exist.' + flash.now[:error] = 'The user inputted "' + params[:user][:username] + '" does not exist.' elsif !TaMapping.where(ta_id: @user.id, course_id: @course.id).empty? - flash.now[:error] = 'The user inputted "' + params[:user][:name] + '" is already a TA for this course.' + flash.now[:error] = 'The user inputted "' + params[:user][:username] + '" is already a TA for this course.' else @ta_mapping = TaMapping.create(ta_id: @user.id, course_id: @course.id) @user.role = Role.find_by name: 'Teaching Assistant' @user.save @course = @ta_mapping - undo_link("The TA \"#{@user.name}\" has been successfully added.") + undo_link("The TA \"#{@user.username}\" has been successfully added.") end render action: 'add_ta.js.erb', layout: false end @@ -151,7 +151,7 @@ def remove_ta @ta_mapping.destroy @course = @ta_mapping - undo_link("The TA \"#{@ta.name}\" has been successfully removed.") + undo_link("The TA \"#{@ta.username}\" has been successfully removed.") render action: 'remove_ta.js.erb', layout: false end diff --git a/app/controllers/export_file_controller.rb b/app/controllers/export_file_controller.rb index 83bf7f368ca..0b56b08cf39 100644 --- a/app/controllers/export_file_controller.rb +++ b/app/controllers/export_file_controller.rb @@ -103,7 +103,7 @@ def export_advices end def export_tags - @user_ids = User.where('name IN (?)', params[:names]) + @user_ids = User.where('username IN (?)', params[:names]) @students = AnswerTag.select('answers.*, answer_tags.*').joins(:answer).where('answer_tags.answer_id = answers.id and answer_tags.user_id IN (?)', @user_ids.pluck(:id)) attributes = %w[user_id tag_prompt_deployment_id comments value] diff --git a/app/controllers/grades_controller.rb b/app/controllers/grades_controller.rb index 1da0687f6b9..3ba0bdd0ac6 100644 --- a/app/controllers/grades_controller.rb +++ b/app/controllers/grades_controller.rb @@ -160,9 +160,9 @@ def update unless format('%.2f', total_score) == params[:participant][:grade] participant.update_attribute(:grade, params[:participant][:grade]) message = if participant.grade.nil? - 'The computed score will be used for ' + participant.user.name + '.' + 'The computed score will be used for ' + participant.user.username + '.' else - 'A score of ' + params[:participant][:grade] + '% has been saved for ' + participant.user.name + '.' + 'A score of ' + params[:participant][:grade] + '% has been saved for ' + participant.user.username + '.' end end flash[:note] = message diff --git a/app/controllers/impersonate_controller.rb b/app/controllers/impersonate_controller.rb index f32f7cf909c..8dd3d5505f4 100644 --- a/app/controllers/impersonate_controller.rb +++ b/app/controllers/impersonate_controller.rb @@ -27,8 +27,8 @@ def action_allowed? # This function does not seem to work def auto_complete_for_user_name - @users = session[:user].get_available_users(params[:user][:name]) - render inline: "<%= auto_complete_result @users, 'name' %>", layout: false + @users = session[:user].get_available_users(params[:user][:username]) + render inline: "<%= auto_complete_result @users, 'username' %>", layout: false end # Called whenever we want to enter the impersonate mode in the application. @@ -56,11 +56,11 @@ def generate_session(user) def overwrite_session if params[:impersonate].nil? - user = real_user(params[:user][:name]) + user = real_user(params[:user][:username]) session[:super_user] = session[:user] if session[:super_user].nil? generate_session(user) - elsif !params[:impersonate][:name].empty? - user = real_user(params[:impersonate][:name]) + elsif !params[:impersonate][:username].empty? + user = real_user(params[:impersonate][:username]) generate_session(user) else session[:user] = session[:super_user] @@ -75,7 +75,7 @@ def overwrite_session # warn_for_special_chars takes the output from above method and flashes an error if there are any special characters(/\?<>|&$#) in the string def check_if_input_is_valid - if params[:user] && warn_for_special_chars(params[:user][:name], 'Username') + if params[:user] && warn_for_special_chars(params[:user][:username], 'Username') flash[:error] = 'Please enter valid user name' redirect_back fallback_location: root_path elsif params[:impersonate] && warn_for_special_chars(params[:impersonate][:name], 'Username') @@ -92,16 +92,16 @@ def check_if_input_is_valid def check_if_user_impersonateable if params[:impersonate].nil? - user = real_user(params[:user][:name]) + user = real_user(params[:user][:username]) unless @original_user.can_impersonate? user - @message = "You cannot impersonate '#{params[:user][:name]}'." + @message = "You cannot impersonate '#{params[:user][:username]}'." temp AuthController.clear_user_info(session, nil) else overwrite_session end else - unless params[:impersonate][:name].empty? + unless params[:impersonate][:username].empty? overwrite_session end end @@ -115,14 +115,14 @@ def impersonate begin @original_user = session[:super_user] || session[:user] if params[:impersonate].nil? - @message = "You cannot impersonate '#{params[:user][:name]}'." - @message = 'User name cannot be empty' if params[:user][:name].empty? - user = real_user(params[:user][:name]) + @message = "You cannot impersonate '#{params[:user][:username]}'." + @message = 'User name cannot be empty' if params[:user][:username].empty? + user = real_user(params[:user][:username]) check_if_user_impersonateable if user - elsif !params[:impersonate][:name].empty? + elsif !params[:impersonate][:username].empty? # Impersonate a new account - @message = "You cannot impersonate '#{params[:impersonate][:name]}'." - user = real_user(params[:impersonate][:name]) + @message = "You cannot impersonate '#{params[:impersonate][:username]}'." + user = real_user(params[:impersonate][:username]) check_if_user_impersonateable if user # Revert to original account when currently in the impersonated session elsif !session[:super_user].nil? @@ -143,11 +143,11 @@ def impersonate # This method checks if the user is in anonymized view and accordingly returns the user object associated with the parameter - def real_user(name) + def real_user(username) if User.anonymized_view?(session[:ip]) - user = User.real_user_from_anonymized_name(name) + user = User.real_user_from_anonymized_username(username) else - user = User.find_by(name: name) + user = User.find_by(username: username) end return user end diff --git a/app/controllers/import_file_controller.rb b/app/controllers/import_file_controller.rb index 0f70f5ca0a8..67e1a35af5e 100644 --- a/app/controllers/import_file_controller.rb +++ b/app/controllers/import_file_controller.rb @@ -53,10 +53,10 @@ def import end err_msg += '' if errors.empty? - ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'The file has been successfully imported.', request) + ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].username, 'The file has been successfully imported.', request) undo_link('The file has been successfully imported.') else - ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].name, err_msg, request) + ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].username, err_msg, request) flash[:error] = err_msg end redirect_to session[:return_to] diff --git a/app/controllers/invitations_controller.rb b/app/controllers/invitations_controller.rb index 1bbc1db7f66..b64401b3525 100644 --- a/app/controllers/invitations_controller.rb +++ b/app/controllers/invitations_controller.rb @@ -19,7 +19,7 @@ def create create_utility else ExpertizaLogger.error LoggerMessage.new('', @student.name, 'Student was already invited') - flash[:note] = "You have already sent an invitation to \"#{@user.name}\"." + flash[:note] = "You have already sent an invitation to \"#{@user.username}\"." end update_join_team_request @user, @student @@ -41,8 +41,8 @@ def update_join_team_request(user, student) end def auto_complete_for_user_name - search = params[:user][:name].to_s - @users = User.where('LOWER(name) LIKE ?', "%#{search}%") if search.present? + search = params[:user][:username].to_s + @users = User.where('LOWER(username) LIKE ?', "%#{search}%") if search.present? end def accept @@ -86,7 +86,7 @@ def create_utility def check_user_before_invitation # user is the student you are inviting to your team - @user = User.find_by(name: params[:user][:name].strip) + @user = User.find_by(username: params[:user][:username].strip) # User/Author has information about the participant @student = AssignmentParticipant.find(params[:student_id]) @assignment = Assignment.find(@student.parent_id) @@ -96,7 +96,7 @@ def check_user_before_invitation # check if the invited user is valid unless @user - flash[:error] = "The user \"#{params[:user][:name].strip}\" does not exist. Please make sure the name entered is correct." + flash[:error] = "The user \"#{params[:user][:username].strip}\" does not exist. Please make sure the username entered is correct." redirect_to view_student_teams_path student_id: @student.id return end @@ -110,7 +110,7 @@ def check_participant_before_invitation if @assignment.is_conference_assignment add_participant_coauthor else - flash[:error] = "The user \"#{params[:user][:name].strip}\" is not a participant in this assignment." + flash[:error] = "The user \"#{params[:user][:username].strip}\" is not a participant in this assignment." redirect_to view_student_teams_path student_id: @student.id return end @@ -134,7 +134,7 @@ def check_team_before_invitation return if team_member.empty? - flash[:error] = "The user \"#{@user.name}\" is already a member of the team." + flash[:error] = "The user \"#{@user.username}\" is already a member of the team." redirect_to view_student_teams_path student_id: @student.id end diff --git a/app/controllers/lottery_controller.rb b/app/controllers/lottery_controller.rb index 0deeceffbde..b239a594f81 100755 --- a/app/controllers/lottery_controller.rb +++ b/app/controllers/lottery_controller.rb @@ -22,14 +22,14 @@ def run_intelligent_assignment users_bidding_info = construct_users_bidding_info(assignment.sign_up_topics, teams) bidding_data = { users: users_bidding_info, max_team_size: assignment.max_team_size } - ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, "Bidding data for assignment #{assignment.name}: #{bidding_data}", request) + ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].username, "Bidding data for assignment #{assignment.name}: #{bidding_data}", request) begin url = WEBSERVICE_CONFIG['topic_bidding_webservice_url'] response = RestClient.post url, bidding_data.to_json, content_type: :json, accept: :json # Structure of teams variable: [[user_id1, user_id2], [user_id3, user_id4]] teams = JSON.parse(response)['teams'] - ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, "Team formation info for assignment #{assignment.name}: #{teams}", request) + ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].username, "Team formation info for assignment #{assignment.name}: #{teams}", request) create_new_teams_for_bidding_response(teams, assignment, users_bidding_info) assignment.remove_empty_teams match_new_teams_to_topics(assignment) diff --git a/app/controllers/lti_controller.rb b/app/controllers/lti_controller.rb index cd28c90add3..6741404904b 100644 --- a/app/controllers/lti_controller.rb +++ b/app/controllers/lti_controller.rb @@ -65,12 +65,12 @@ def valid_request_url?(url) def authenticate_and_login_user(username) begin # Gets the user if they exist in Expertiza, else null - user = User.find_by(name: username) + user = User.find_by(username: username) if user # Log the user in session[:user] = user # Store the entire user object, not just the username AuthController.set_current_role(user.role_id, session) - ExpertizaLogger.info LoggerMessage.new('', user.name, 'Login successful via LTI') + ExpertizaLogger.info LoggerMessage.new('', user.username, 'Login successful via LTI') redirect_to "#{ENV['EXPERTIZA_BASE_URL']}/student_task/list", notice: 'Logged in successfully via LTI' else redirect_to root_path, alert: 'User not found in Expertiza. Please register first.' diff --git a/app/controllers/participants_controller.rb b/app/controllers/participants_controller.rb index a1bca28a7fd..5dd06c988b5 100644 --- a/app/controllers/participants_controller.rb +++ b/app/controllers/participants_controller.rb @@ -39,17 +39,17 @@ def add #E2351 - add corresponding duty fill from permissions can_mentor = permissions[:can_mentor] if curr_object.is_a?(Assignment) - curr_object.add_participant(params[:user][:name], can_submit, can_review, can_take_quiz, can_mentor) + curr_object.add_participant(params[:user][:username], can_submit, can_review, can_take_quiz, can_mentor) elsif curr_object.is_a?(Course) - curr_object.add_participant(params[:user][:name]) + curr_object.add_participant(params[:user][:username]) end - user = User.find_by(name: params[:user][:name]) + user = User.find_by(username: params[:user][:username]) @model = params[:model] @participant = curr_object.participants.find_by(user_id: user.id) - flash.now[:note] = "The user #{params[:user][:name]} has successfully been added." + flash.now[:note] = "The user #{params[:user][:username]} has successfully been added." rescue StandardError url_for controller: 'users', action: 'new' - flash.now[:error] = "The user #{params[:user][:name]} does not exist or has already been added." + flash.now[:error] = "The user #{params[:user][:username]} does not exist or has already been added." end render action: 'add.js.erb', layout: false end @@ -79,7 +79,7 @@ def destroy parent_id = participant.parent_id begin participant.destroy - flash[:note] = undo_link("The user \"#{participant.user.name}\" has been successfully removed as a participant.") + flash[:note] = undo_link("The user \"#{participant.user.username}\" has been successfully removed as a participant.") rescue StandardError flash[:error] = 'This participant is on a team, or is assigned as a reviewer for someone’s work.' end @@ -158,13 +158,13 @@ def change_handle # Deletes participants from an assignment def delete contributor = AssignmentParticipant.find(params[:id]) - name = contributor.name + username = contributor.name assignment_id = contributor.assignment begin contributor.destroy - flash[:note] = "\"#{name}\" is no longer a participant in this assignment." + flash[:note] = "\"#{username}\" is no longer a participant in this assignment." rescue StandardError - flash[:error] = "\"#{name}\" was not removed from this assignment. Please ensure that \"#{name}\" is not a reviewer or metareviewer and try again." + flash[:error] = "\"#{username}\" was not removed from this assignment. Please ensure that \"#{username}\" is not a reviewer or metareviewer and try again." end redirect_to controller: 'review_mapping', action: 'list_mappings', id: assignment_id end @@ -204,7 +204,7 @@ def participant_params # Get the user info from the team user def get_user_info(team_user, assignment) user = {} - user[:name] = team_user.name + user[:username] = team_user.username user[:fullname] = team_user.fullname # set by default permission_granted = false diff --git a/app/controllers/password_retrieval_controller.rb b/app/controllers/password_retrieval_controller.rb index 1f6856d29a0..af3c07e348f 100644 --- a/app/controllers/password_retrieval_controller.rb +++ b/app/controllers/password_retrieval_controller.rb @@ -18,7 +18,7 @@ def send_password PasswordReset.save_token(user, token) url = request.base_url + url_format + token MailerHelper.send_mail_to_user(user, 'Expertiza password reset', 'send_password', url).deliver_now - ExpertizaLogger.info LoggerMessage.new(controller_name, user.name, 'A link to reset your password has been sent to users e-mail address.', request) + ExpertizaLogger.info LoggerMessage.new(controller_name, user.username, 'A link to reset your password has been sent to users e-mail address.', request) flash[:success] = 'A link to reset your password has been sent to your e-mail address.' redirect_to '/' else @@ -71,10 +71,10 @@ def update_password user.password_confirmation = params[:reset][:repassword] if user.save PasswordReset.where(user_email: user.email).delete_all - ExpertizaLogger.info LoggerMessage.new(controller_name, user.name, 'Password was reset for the user', request) + ExpertizaLogger.info LoggerMessage.new(controller_name, user.username, 'Password was reset for the user', request) flash[:success] = 'Password was successfully reset' else - ExpertizaLogger.error LoggerMessage.new(controller_name, user.name, 'Password reset operation failed for the user while saving record', request) + ExpertizaLogger.error LoggerMessage.new(controller_name, user.username, 'Password reset operation failed for the user while saving record', request) flash[:error] = 'Password cannot be updated. Please try again' end redirect_to '/' diff --git a/app/controllers/profile_controller.rb b/app/controllers/profile_controller.rb index c7053def3a4..4df0be244b0 100644 --- a/app/controllers/profile_controller.rb +++ b/app/controllers/profile_controller.rb @@ -18,12 +18,12 @@ def update aq.update_attribute('notification_limit', params[:assignment_questionnaire][:notification_limit]) end if @user.update_attributes(user_params) - ExpertizaLogger.info LoggerMessage.new(controller_name, @user.name, 'Your profile was successfully updated.', request) + ExpertizaLogger.info LoggerMessage.new(controller_name, @user.username, 'Your profile was successfully updated.', request) @user.etc_icons_on_homepage = params[:no_show_action] != 'not_show_actions' @user.save! flash[:success] = 'Your profile was successfully updated.' else - ExpertizaLogger.error LoggerMessage.new(controller_name, @user.name, 'An error occurred and your profile could not updated.', request) + ExpertizaLogger.error LoggerMessage.new(controller_name, @user.username, 'An error occurred and your profile could not updated.', request) flash[:error] = 'An error occurred and your profile could not updated.' end diff --git a/app/controllers/response_controller.rb b/app/controllers/response_controller.rb index 3d6829dfbd4..40550aecbbf 100644 --- a/app/controllers/response_controller.rb +++ b/app/controllers/response_controller.rb @@ -140,7 +140,7 @@ def update rescue StandardError msg = "Your response was not saved. Cause:189 #{$ERROR_INFO}" end - ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, "Your response was submitted: #{@response.is_submitted}", request) + ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].username, "Your response was submitted: #{@response.is_submitted}", request) redirect_to controller: 'response', action: 'save', id: @map.map_id, return: params.permit(:return)[:return], msg: msg, review: params.permit(:review)[:review], save_options: params.permit(:save_options)[:save_options] @@ -254,7 +254,7 @@ def save @map = ResponseMap.find(params[:id]) @return = params[:return] @map.save - ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Response was successfully saved') + ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].username, 'Response was successfully saved') redirect_to action: 'redirect', id: @map.map_id, return: params.permit(:return)[:return], msg: params.permit(:msg)[:msg], error_msg: params.permit(:error_msg)[:error_msg] end diff --git a/app/controllers/review_mapping_controller.rb b/app/controllers/review_mapping_controller.rb index 53c9c37cf2f..7de68007326 100755 --- a/app/controllers/review_mapping_controller.rb +++ b/app/controllers/review_mapping_controller.rb @@ -54,7 +54,7 @@ def select_metareviewer def add_reviewer assignment = Assignment.find(params[:id]) topic_id = params[:topic_id] - user_id = User.where(name: params[:user][:name]).first.id + user_id = User.where(username: params[:user][:username]).first.id # If instructor want to assign one student to review his/her own artifact, # it should be counted as "self-review" and we need to make /app/views/submitted_content/_selfreview.html.erb work. if TeamsUser.exists?(team_id: params[:contributor_id], user_id: user_id) @@ -198,7 +198,7 @@ def add_metareviewer regurl = url_for action: 'add_user_to_assignment', id: mapping.map_id, user_id: user.id reviewer = get_reviewer(user, mapping.assignment, regurl) unless MetareviewResponseMap.where(reviewed_object_id: mapping.map_id, reviewer_id: reviewer.id).first.nil? - raise 'The metareviewer "' + reviewer.user.name + '" is already assigned to this reviewer.' + raise 'The metareviewer "' + reviewer.user.username + '" is already assigned to this reviewer.' end MetareviewResponseMap.create(reviewed_object_id: mapping.map_id, @@ -224,7 +224,7 @@ def assign_metareviewer_dynamically def get_reviewer(user, assignment, reg_url) reviewer = AssignmentParticipant.where(user_id: user.id, parent_id: assignment.id).first - raise "\"#{user.name}\" is not a participant in the assignment. Please register this user to continue." if reviewer.nil? + raise "\"#{user.username}\" is not a participant in the assignment. Please register this user to continue." if reviewer.nil? reviewer.get_reviewer rescue StandardError => e diff --git a/app/controllers/sign_up_sheet_controller.rb b/app/controllers/sign_up_sheet_controller.rb index 73a6de1ce5d..bc6b7d91276 100755 --- a/app/controllers/sign_up_sheet_controller.rb +++ b/app/controllers/sign_up_sheet_controller.rb @@ -243,7 +243,7 @@ def sign_up def signup_as_instructor; end def signup_as_instructor_action - user = User.find_by(name: params[:username]) + user = User.find_by(username: params[:username]) if user.nil? # validate invalid user flash[:error] = 'That student does not exist!' else @@ -414,7 +414,7 @@ def show_team @results.each do |result| @team_members = '' TeamsUser.where(team_id: result[:team_id]).each do |teamuser| - @team_members += User.find(teamuser.user_id).name + ' ' + @team_members += User.find(teamuser.user_id).username + ' ' end end # @team_members = find_team_members(topic) diff --git a/app/controllers/student_teams_controller.rb b/app/controllers/student_teams_controller.rb index 4ce770c5b03..d1b274e91a3 100644 --- a/app/controllers/student_teams_controller.rb +++ b/app/controllers/student_teams_controller.rb @@ -72,7 +72,7 @@ def create if existing_teams.empty? if params[:team][:name].blank? flash[:notice] = 'The team name is empty.' - ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Team name missing while creating team', request) + ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].username, 'Team name missing while creating team', request) redirect_to view_student_teams_path student_id: student.id return end @@ -93,7 +93,7 @@ def create else flash[:notice] = 'That team name is already in use.' - ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].name, 'Team name being created was already in use', request) + ExpertizaLogger.error LoggerMessage.new(controller_name, session[:user].username, 'Team name being created was already in use', request) redirect_to view_student_teams_path student_id: student.id end end @@ -113,7 +113,7 @@ def update redirect_to view_student_teams_path student_id: params[:student_id] else flash[:notice] = 'That team name is already in use.' - ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'Team name being updated to was already in use', request) + ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].username, 'Team name being updated to was already in use', request) redirect_to view_student_teams_path student_id: params[:student_id] end @@ -145,7 +145,7 @@ def remove_team_user(team_user) team_user.destroy_all undo_link "The user \"#{team_user.name}\" has been successfully removed from the team." - ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'User removed a participant from the team', request) + ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].username, 'User removed a participant from the team', request) end def team_created_successfully(current_team = nil) @@ -154,7 +154,7 @@ def team_created_successfully(current_team = nil) else undo_link "The team \"#{team.name}\" has been successfully updated." end - ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].name, 'The team has been successfully created.', request) + ExpertizaLogger.info LoggerMessage.new(controller_name, session[:user].username, 'The team has been successfully created.', request) end # This method is used to show the Author Feedback Questionnaire of current assignment diff --git a/app/controllers/submitted_content_controller.rb b/app/controllers/submitted_content_controller.rb index b11252b808b..ebf8debbd15 100644 --- a/app/controllers/submitted_content_controller.rb +++ b/app/controllers/submitted_content_controller.rb @@ -258,7 +258,7 @@ def delete_selected_files team = participant.try(:team) SubmissionRecord.create(team_id: team.try(:id), content: filename, - user: participant.try(:name), + user: participant.try(:username), assignment_id: assignment.try(:id), operation: 'Remove File') ExpertizaLogger.info LoggerMessage.new(controller_name, @participant.name, 'The selected file has been deleted.', request) diff --git a/app/controllers/suggestion_controller.rb b/app/controllers/suggestion_controller.rb index e4954e11e59..24c15470543 100644 --- a/app/controllers/suggestion_controller.rb +++ b/app/controllers/suggestion_controller.rb @@ -13,7 +13,7 @@ def action_allowed? def add_comment @suggestion_comment = SuggestionComment.new(vote: params[:suggestion_comment][:vote], comments: params[:suggestion_comment][:comments]) @suggestion_comment.suggestion_id = params[:id] - @suggestion_comment.commenter = session[:user].name + @suggestion_comment.commenter = session[:user].username if @suggestion_comment.save flash[:notice] = 'Your comment has been successfully added.' else @@ -57,7 +57,7 @@ def update_suggestion def new @suggestion = Suggestion.new session[:assignment_id] = params[:id] - @suggestions = Suggestion.where(unityID: session[:user].name, assignment_id: params[:id]) + @suggestions = Suggestion.where(unityID: session[:user].username, assignment_id: params[:id]) @assignment = Assignment.find(params[:id]) end @@ -67,7 +67,7 @@ def create @assignment = Assignment.find(session[:assignment_id]) @suggestion.status = 'Initiated' @suggestion.unityID = if params[:suggestion_anonymous].nil? - session[:user].name + session[:user].username else '' end @@ -105,7 +105,7 @@ def send_email subject: "Suggested topic '#{@suggestion.title}' has been approved", body: { approved_topic_name: @suggestion.title, - proposer: proposer.name + proposer: proposer.username } ).deliver_now! end @@ -160,7 +160,7 @@ def suggestion_params def approve @suggestion = Suggestion.find(params[:id]) - @user_id = User.find_by(name: @suggestion.unityID).try(:id) + @user_id = User.find_by(username: @suggestion.unityID).try(:id) if @user_id @team_id = TeamsUser.team_id(@suggestion.assignment_id, @user_id) @topic_id = SignedUpTeam.topic_id(@suggestion.assignment_id, @user_id) diff --git a/app/controllers/teams_users_controller.rb b/app/controllers/teams_users_controller.rb index b0b71610617..99fd992335c 100644 --- a/app/controllers/teams_users_controller.rb +++ b/app/controllers/teams_users_controller.rb @@ -12,8 +12,8 @@ def action_allowed? def auto_complete_for_user_name team = Team.find(session[:team_id]) - @users = team.get_possible_team_members(params[:user][:name]) - render inline: "<%= auto_complete_result @users, 'name' %>", layout: false + @users = team.get_possible_team_members(params[:user][:username]) + render inline: "<%= auto_complete_result @users, 'username' %>", layout: false end # Example of duties: manager, designer, programmer, tester. Finds TeamsUser and save preferred Duty @@ -34,10 +34,10 @@ def new end def create - user = User.find_by(name: params[:user][:name].strip) + user = User.find_by(username: params[:user][:username].strip) unless user urlCreate = url_for controller: 'users', action: 'new' - flash[:error] = "\"#{params[:user][:name].strip}\" is not defined. Please create this user before continuing." + flash[:error] = "\"#{params[:user][:username].strip}\" is not defined. Please create this user before continuing." end team = Team.find(params[:id]) @@ -51,12 +51,12 @@ def create end if AssignmentParticipant.find_by(user_id: user.id, parent_id: assignment.id).nil? urlAssignmentParticipantList = url_for controller: 'participants', action: 'list', id: assignment.id, model: 'Assignment', authorization: 'participant' - flash[:error] = "\"#{user.name}\" is not a participant of the current assignment. Please add this user before continuing." + flash[:error] = "\"#{user.username}\" is not a participant of the current assignment. Please add this user before continuing." else begin add_member_return = team.add_member(user, team.parent_id) rescue - flash[:error] = "The user #{user.name} is already a member of the team #{team.name}" + flash[:error] = "The user #{user.username} is already a member of the team #{team.name}" redirect_back fallback_location: root_path return end @@ -71,19 +71,19 @@ def create end if CourseParticipant.find_by(user_id: user.id, parent_id: course.id).nil? urlCourseParticipantList = url_for controller: 'participants', action: 'list', id: course.id, model: 'Course', authorization: 'participant' - flash[:error] = "\"#{user.name}\" is not a participant of the current course. Please add this user before continuing." + flash[:error] = "\"#{user.username}\" is not a participant of the current course. Please add this user before continuing." else begin add_member_return = team.add_member(user, team.parent_id) rescue - flash[:error] = "The user #{user.name} is already a member of the team #{team.name}" + flash[:error] = "The user #{user.username} is already a member of the team #{team.name}" redirect_back fallback_location: root_path return end flash[:error] = 'This team already has the maximum number of members.' if add_member_return == false if add_member_return @teams_user = TeamsUser.last - undo_link("The team user \"#{user.name}\" has been successfully added to \"#{team.name}\".") + undo_link("The team user \"#{user.username}\" has been successfully added to \"#{team.name}\".") end end end @@ -97,7 +97,7 @@ def delete parent_id = Team.find(@teams_user.team_id).parent_id @user = User.find(@teams_user.user_id) @teams_user.destroy - undo_link("The team user \"#{@user.name}\" has been successfully removed. ") + undo_link("The team user \"#{@user.username}\" has been successfully removed. ") redirect_to controller: 'teams', action: 'list', id: parent_id end diff --git a/app/controllers/tree_display_controller.rb b/app/controllers/tree_display_controller.rb index e846927fd7d..d8fa3f56448 100644 --- a/app/controllers/tree_display_controller.rb +++ b/app/controllers/tree_display_controller.rb @@ -317,7 +317,7 @@ def serialize_folder_to_json(folder_type, node) 'private' => course_is_available?(node) ) json['instructor_id'] = node.get_instructor_id - json['instructor'] = node.get_instructor_id ? User.find(node.get_instructor_id).name(session[:ip]) : nil + json['instructor'] = node.get_instructor_id ? User.find(node.get_instructor_id).username(session[:ip]) : nil json['is_available'] = course_is_available?(node) serialize_assignment_to_json(node, json) if folder_type == 'Assignments' end @@ -339,7 +339,7 @@ def serialize_sub_folder_to_json(node) if (node.type == 'CourseNode') || (node.type == 'AssignmentNode') json['directory'] = node.get_directory json['instructor_id'] = node.get_instructor_id - json['instructor'] = node.get_instructor_id ? User.find(node.get_instructor_id).name(session[:ip]) : nil + json['instructor'] = node.get_instructor_id ? User.find(node.get_instructor_id).username(session[:ip]) : nil json['is_available'] = course_is_available?(node) serialize_assignment_to_json(node, json) if node.type == 'AssignmentNode' end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 0d93bccce43..791ec4f6282 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -42,8 +42,8 @@ def index def auto_complete_for_user_name user = session[:user] role = Role.find(user.role_id) - @users = User.where('name LIKE ? and (role_id in (?) or id = ?)', "#{params[:user][:name]}%", role.get_available_roles, user.id) - render inline: "<%= auto_complete_result @users, 'name' %>", layout: false + @users = User.where('username LIKE ? and (role_id in (?) or id = ?)', "#{params[:user][:username]}%", role.get_available_roles, user.id) + render inline: "<%= auto_complete_result @users, 'username' %>", layout: false end # for anonymized view for demo purposes @@ -67,7 +67,7 @@ def list if letter.present? && search_by.present? case search_by.to_i when 1 # Search by username - @paginated_users = paginate_list.where('name LIKE ?', "%#{letter}%") + @paginated_users = paginate_list.where('username LIKE ?', "%#{letter}%") when 2 # Search by fullname @paginated_users = paginate_list.where('fullname LIKE ?', "%#{letter}%") when 3 # Search by email @@ -82,9 +82,9 @@ def list # for displaying users which are being searched for editing purposes after checking whether current user is authorized to do so def show_if_authorized - @user = User.find_by(name: params[:user][:name]) + @user = User.find_by(username: params[:user][:username]) if @user.nil? - flash[:note] = params[:user][:name] + ' does not exist.' + flash[:note] = params[:user][:username] + ' does not exist.' redirect_to action: 'list' else role @@ -121,9 +121,9 @@ def new def create # if the user name already exists, register the user by email address - check = User.find_by(name: params[:user][:name]) + check = User.find_by(username: params[:user][:username]) if check - params[:user][:name] = params[:user][:email] + params[:user][:username] = params[:user][:email] flash[:note] = "That username already exists. Username has been set to the user's email address" end is_user = true @@ -140,7 +140,7 @@ def create # TAs and Students do not need a default. TAs inherit the default from the instructor, # Students do not have any checks for this information. AssignmentQuestionnaire.create(user_id: @user.id) if (@user.role.name == 'Instructor') || (@user.role.name == 'Administrator') - undo_link("The user \"#{@user.name}\" has been successfully created. ") + undo_link("The user \"#{@user.username}\" has been successfully created. ") redirect_to action: 'list' else foreign @@ -165,10 +165,10 @@ def update # update username, when the user cannot be deleted # rename occurs in 'show' page, not in 'edit' page # eg. /users/5408?name=5408 - @user.name += '_hidden' if request.original_fullpath == "/users/#{@user.id}?name=#{@user.id}" + @user.username += '_hidden' if request.original_fullpath == "/users/#{@user.id}?username=#{@user.id}" if @user.update_attributes(params[:user]) - flash[:success] = "The user \"#{@user.name}\" has been successfully updated." + flash[:success] = "The user \"#{@user.username}\" has been successfully updated." redirect_to @user else render action: 'edit' @@ -183,7 +183,7 @@ def destroy AssignmentQuestionnaire.where(user_id: @user.id).each(&:destroy) # Participant.delete(true) @user.destroy - flash[:note] = "The user \"#{@user.name}\" has been successfully deleted." + flash[:note] = "The user \"#{@user.username}\" has been successfully deleted." rescue StandardError flash[:error] = $ERROR_INFO end @@ -214,7 +214,7 @@ def foreign # add user etc_icons_on_homepage def user_params - params.require(:user).permit(:name, + params.require(:user).permit(:username, :crypted_password, :role_id, :password_salt, diff --git a/app/helpers/answer_helper.rb b/app/helpers/answer_helper.rb index 2a89ddc53bd..6c68a5c4a76 100644 --- a/app/helpers/answer_helper.rb +++ b/app/helpers/answer_helper.rb @@ -42,7 +42,7 @@ def self.log_response_info(response_ids) user = Participant.find(reviewer_id).user answers_per_user = Answer.find_by(response_id: response_id).comments # For each response_id, add its info to the dictionary - user_id_to_answers[response_id] = { email: user.email, answers: answers_per_user, name: user.name, assignment_name: assignment_name } unless user.nil? + user_id_to_answers[response_id] = { email: user.email, answers: answers_per_user, username: user.username, assignment_name: assignment_name } unless user.nil? end user_id_to_answers end diff --git a/app/helpers/conference_helper.rb b/app/helpers/conference_helper.rb index 049d245e320..3c422cc27fc 100644 --- a/app/helpers/conference_helper.rb +++ b/app/helpers/conference_helper.rb @@ -36,7 +36,7 @@ def get_redirect_url_link end def create_author - params[:user][:name] = params[:user][:email] unless !params[:user][:name].nil? && !params[:user][:name].empty? + params[:user][:username] = params[:user][:email] unless !params[:user][:username].nil? && !params[:user][:username].empty? is_author = true # Assign all user params for creating author using assign_user_params function @user = assign_user_params(is_author) @@ -53,7 +53,7 @@ def create_author end def create_coauthor - check = User.find_by(name: params[:user][:name]) + check = User.find_by(username: params[:user][:name]) params[:user][:name] = params[:user][:email] unless check.nil? User.skip_callback(:create, :after, :email_welcome) is_author = false @@ -66,7 +66,7 @@ def create_coauthor # password is regenerated so that we could provide it in a mail password = @user.reset_password # Mail to be sent to co-author once the user has been created. New partial is used as content for email is different from normal user - MailerHelper.send_mail_for_conference_user(@user, 'Your Expertiza account has been created.', 'user_conference_invitation', password, current_user.name).deliver + MailerHelper.send_mail_for_conference_user(@user, 'Your Expertiza account has been created.', 'user_conference_invitation', password, current_user.username).deliver @user end end @@ -90,7 +90,7 @@ def assign_user_params(is_author) @user = User.new(user_params) # Checks if its a co-author if !is_author - @user.email = params[:user][:name] + @user.email = params[:user][:username] # parent_id denotes who created the co-author @user.parent_id = session[:user].id # co-author role is same as student hence role_id =1 @@ -119,7 +119,7 @@ def assign_user_params(is_author) end def user_params - params.require(:user).permit(:name, + params.require(:user).permit(:username, :fullname, :role_id, :email, diff --git a/app/helpers/import_file_helper.rb b/app/helpers/import_file_helper.rb index c0b59049291..5991ff1abe4 100644 --- a/app/helpers/import_file_helper.rb +++ b/app/helpers/import_file_helper.rb @@ -4,7 +4,7 @@ module ImportFileHelper def self.define_attributes(row_hash) attributes = {} attributes['role_id'] = Role.student.id - attributes['name'] = row_hash[:username] + attributes['username'] = row_hash[:username] attributes['fullname'] = row_hash[:fullname] attributes['email'] = row_hash[:email] attributes['email_on_submission'] = 1 diff --git a/app/helpers/manage_team_helper.rb b/app/helpers/manage_team_helper.rb index e0ce5c093f6..5e84ca8906d 100644 --- a/app/helpers/manage_team_helper.rb +++ b/app/helpers/manage_team_helper.rb @@ -8,7 +8,7 @@ def create_team_users(user, team_id) unless user urlCreate = url_for controller: 'users', action: 'new' ExpertizaLogger.error LoggerMessage.new('ManageTeamHelper', '', 'User being added to the team does not exist!', request) - flash[:error] = "\"#{params[:user][:name].strip}\" is not defined. Please create this user before continuing." + flash[:error] = "\"#{params[:user][:username].strip}\" is not defined. Please create this user before continuing." end # find the team with 'team_id' form database and add new user to team team = Team.find(team_id) diff --git a/app/helpers/participants_helper.rb b/app/helpers/participants_helper.rb index 08494c55737..0b936095666 100644 --- a/app/helpers/participants_helper.rb +++ b/app/helpers/participants_helper.rb @@ -15,7 +15,7 @@ def self.upload_users(filename, session, params, home_page) def self.define_attributes(line_split, config) attributes = {} attributes['role_id'] = Role.find_by name: 'Student' - attributes['name'] = line_split[config['name'].to_i] + attributes['username'] = line_split[config['username'].to_i] attributes['fullname'] = config['fullname'] attributes['email'] = line_split[config['email'].to_i] attributes['password'] = (0...8).map { (65 + rand(26)).chr }.join @@ -26,7 +26,7 @@ def self.define_attributes(line_split, config) end def self.define_user(attrs, session, params, home_page) - user = User.find_by(name: attrs['name']) + user = User.find_by(username: attrs['username']) user = create_new_user(attrs, session) if user.nil? if !params[:course_id].nil? participant = add_user_to_course(params, user) @@ -64,7 +64,7 @@ def self.get_config File.open(cfgdir + 'roster_config', 'r') do |infile| while (line = infile.gets) store_item(line, 'dlm', config) - store_item(line, 'name', config) + store_item(line, 'username', config) store_item(line, 'fullname', config) store_item(line, 'email', config) end diff --git a/app/helpers/report_formatter_helper.rb b/app/helpers/report_formatter_helper.rb index bbfd6abcde7..6cae86ca869 100644 --- a/app/helpers/report_formatter_helper.rb +++ b/app/helpers/report_formatter_helper.rb @@ -91,21 +91,21 @@ def create_participant(parent_id, user_id) end def user_summary_report(line) - if @user_tagging_report[line.user.name].nil? + if @user_tagging_report[line.user.username].nil? # E2082 Adding extra field of interval array into data structure - @user_tagging_report[line.user.name] = VmUserAnswerTagging.new(line.user, line.percentage, line.no_tagged, line.no_not_tagged, line.no_tagable, line.tag_update_intervals) + @user_tagging_report[line.user.username] = VmUserAnswerTagging.new(line.user, line.percentage, line.no_tagged, line.no_not_tagged, line.no_tagable, line.tag_update_intervals) else - @user_tagging_report[line.user.name].no_tagged += line.no_tagged - @user_tagging_report[line.user.name].no_not_tagged += line.no_not_tagged - @user_tagging_report[line.user.name].no_tagable += line.no_tagable - @user_tagging_report[line.user.name].percentage = calculate_formatted_percentage(line) + @user_tagging_report[line.user.username].no_tagged += line.no_tagged + @user_tagging_report[line.user.username].no_not_tagged += line.no_not_tagged + @user_tagging_report[line.user.username].no_tagable += line.no_tagable + @user_tagging_report[line.user.username].percentage = calculate_formatted_percentage(line) end end def calculate_formatted_percentage(line) - number_tagged = @user_tagging_report[line.user.name].no_tagged.to_f - number_taggable = @user_tagging_report[line.user.name].no_tagable + number_tagged = @user_tagging_report[line.user.username].no_tagged.to_f + number_taggable = @user_tagging_report[line.user.username].no_tagable formatted_percentage = format('%.1f', (number_tagged / number_taggable) * 100) - @user_tagging_report[line.user.name].no_tagable.zero? ? '-' : formatted_percentage + @user_tagging_report[line.user.username].no_tagable.zero? ? '-' : formatted_percentage end end diff --git a/app/models/account_request.rb b/app/models/account_request.rb index 85e5a3a18dd..bd9ac143843 100644 --- a/app/models/account_request.rb +++ b/app/models/account_request.rb @@ -1,7 +1,7 @@ class AccountRequest < ApplicationRecord before_save { self.email = email.downcase } - before_save { name } - validates :name, presence: true, length: { maximum: 50, message: 'is too long' } + before_save { username } + validates :username, presence: true, length: { maximum: 50, message: 'is too long' } VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i.freeze validates :email, presence: true, length: { maximum: 255, message: 'is too long' }, format: { with: VALID_EMAIL_REGEX, message: 'format is wrong' }, diff --git a/app/models/assignment.rb b/app/models/assignment.rb index 8f9bed41aab..1b99425997c 100755 --- a/app/models/assignment.rb +++ b/app/models/assignment.rb @@ -177,10 +177,10 @@ def path end path_text = if !course_id.nil? && course_id > 0 - Rails.root.to_s + '/pg_data/' + FileHelper.clean_path(instructor[:name]) + '/' + + Rails.root.to_s + '/pg_data/' + FileHelper.clean_path(instructor[:username]) + '/' + FileHelper.clean_path(course.directory_path) + '/' else - Rails.root.to_s + '/pg_data/' + FileHelper.clean_path(instructor[:name]) + '/' + Rails.root.to_s + '/pg_data/' + FileHelper.clean_path(instructor[:username]) + '/' end path_text += FileHelper.clean_path(directory_path) path_text @@ -270,13 +270,13 @@ def badge? # manual addition # user_name - the user account name of the participant to add def add_participant(user_name, can_submit, can_review, can_take_quiz, can_mentor) - user = User.find_by(name: user_name) + user = User.find_by(username: user_name) if user.nil? - raise "The user account with the name #{user_name} does not exist. Please create the user first." end participant = AssignmentParticipant.find_by(parent_id: id, user_id: user.id) - raise "The user #{user.name} is already a participant." if participant + raise "The user #{user.username} is already a participant." if participant new_part = AssignmentParticipant.create(parent_id: id, user_id: user.id, @@ -444,7 +444,7 @@ def self.csv_row(detail_options, answer) reviewer = Participant.find(map.reviewer_id).user teams_csv << handle_nil(@reviewee.id) if detail_options['team_id'] == 'true' teams_csv << handle_nil(@reviewee.name) if detail_options['team_name'] == 'true' - teams_csv << handle_nil(reviewer.name) if detail_options['reviewer'] == 'true' + teams_csv << handle_nil(reviewer.username) if detail_options['reviewer'] == 'true' teams_csv << handle_nil(answer.question.txt) if detail_options['question'] == 'true' teams_csv << handle_nil(answer.question.id) if detail_options['question_id'] == 'true' teams_csv << handle_nil(answer.id) if detail_options['comment_id'] == 'true' @@ -483,7 +483,7 @@ def self.export_headers(parent_id) @assignment = Assignment.find(parent_id) fields = [] fields << 'Assignment Name: ' + @assignment.name.to_s - fields << 'Assignment Instructor: ' + User.find(@assignment.instructor_id).name.to_s + fields << 'Assignment Instructor: ' + User.find(@assignment.instructor_id).username.to_s fields end diff --git a/app/models/assignment_participant.rb b/app/models/assignment_participant.rb index f38245fb062..5a2605ea097 100644 --- a/app/models/assignment_participant.rb +++ b/app/models/assignment_participant.rb @@ -113,7 +113,7 @@ def team def self.import(row_hash, _row_header = nil, session, id) raise ArgumentError, 'No user id has been specified.' if row_hash.empty? - user = User.find_by(name: row_hash[:username]) + user = User.find_by(username: row_hash[:username]) # if user with provided name in csv file is not present then new user will be created. if user.nil? @@ -154,9 +154,9 @@ def verify_digital_signature(private_key) # define a handle for a new participant def set_handle self.handle = if user.handle.nil? || (user.handle == '') - user.name + user.username elsif AssignmentParticipant.exists?(parent_id: assignment.id, handle: user.handle) - user.name + user.username else user.handle end diff --git a/app/models/course.rb b/app/models/course.rb index 7ec1c39e452..c6454d8971a 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -23,7 +23,7 @@ def get_teams def path raise 'Path can not be created. The course must be associated with an instructor.' if instructor_id.nil? - Rails.root + '/pg_data/' + FileHelper.clean_path(User.find(instructor_id).name) + '/' + FileHelper.clean_path(directory_path) + '/' + Rails.root + '/pg_data/' + FileHelper.clean_path(User.find(instructor_id).username) + '/' + FileHelper.clean_path(directory_path) + '/' end def get_participants @@ -35,14 +35,14 @@ def get_participant(user_id) end def add_participant(user_name) - user = User.find_by(name: user_name) + user = User.find_by(username: user_name) if user.nil? raise 'No user account exists with the name ' + user_name + ". Please create the user first." end participant = CourseParticipant.where(parent_id: id, user_id: user.id).first if participant # If there is already a participant, raise an error. Otherwise, create it - raise "The user #{user.name} is already a participant." + raise "The user #{user.username} is already a participant." else CourseParticipant.create(parent_id: id, user_id: user.id, permission_granted: user.master_permission_granted) end @@ -56,7 +56,7 @@ def copy_participants(assignment_id) user = User.find(participant.user_id) begin - add_participant(user.name) + add_participant(user.username) rescue StandardError errors << $ERROR_INFO end diff --git a/app/models/course_participant.rb b/app/models/course_participant.rb index cc79aa778e0..31fc11c17b6 100644 --- a/app/models/course_participant.rb +++ b/app/models/course_participant.rb @@ -15,7 +15,7 @@ def copy(assignment_id) def self.import(row_hash, _row_header = nil, session, id) raise ArgumentError, 'No user id has been specified.' if row_hash.empty? - user = User.find_by(name: row_hash[:username]) + user = User.find_by(username: row_hash[:username]) if user.nil? raise ArgumentError, "The record containing #{row_hash[:username]} does not have enough items." if row_hash.length < 4 diff --git a/app/models/course_team.rb b/app/models/course_team.rb index 14e58c6c39d..7bac5d7245e 100644 --- a/app/models/course_team.rb +++ b/app/models/course_team.rb @@ -68,7 +68,7 @@ def self.export_fields(options) # Add member to the course team def add_member(user, _id = nil) - raise "The user \"#{user.name}\" is already a member of the team, \"#{name}\"" if user?(user) + raise "The user \"#{user.username}\" is already a member of the team, \"#{name}\"" if user?(user) t_user = TeamsUser.create(user_id: user.id, team_id: id) parent = TeamNode.find_by(node_object_id: id) diff --git a/app/models/mentor_management.rb b/app/models/mentor_management.rb index 54a71096463..0adfdf5a468 100644 --- a/app/models/mentor_management.rb +++ b/app/models/mentor_management.rb @@ -3,7 +3,7 @@ class MentorManagement # # 1) Find all assignment participants for the # assignment with id [assignment_id] whose - # duty is the same as [Particpant#DUTY_MENTOR]. + # duty is the same as [Participant#DUTY_MENTOR]. # 2) Count the number of teams those participants # are a part of, acting as a proxy for the # number of teams they mentor. diff --git a/app/models/mentored_team.rb b/app/models/mentored_team.rb index daccd65d37d..6363b53dce6 100644 --- a/app/models/mentored_team.rb +++ b/app/models/mentored_team.rb @@ -2,7 +2,7 @@ class MentoredTeam < AssignmentTeam # Class created during refactoring of E2351 # Overridden method to include the MentorManagement workflow def add_member(user, _assignment_id = nil) - raise "The user #{user.name} is already a member of the team #{name}" if user?(user) + raise "The user #{user.username} is already a member of the team #{name}" if user?(user) can_add_member = false unless full? @@ -11,7 +11,7 @@ def add_member(user, _assignment_id = nil) parent = TeamNode.find_by(node_object_id: id) TeamUserNode.create(parent_id: parent.id, node_object_id: t_user.id) add_participant(parent_id, user) - ExpertizaLogger.info LoggerMessage.new('Model:Team', user.name, "Added member to the team #{id}") + ExpertizaLogger.info LoggerMessage.new('Model:Team', user.username, "Added member to the team #{id}") end if can_add_member MentorManagement.assign_mentor(_assignment_id, id) diff --git a/app/models/metareview_response_map.rb b/app/models/metareview_response_map.rb index fdfb87e8dde..88f98f0e275 100644 --- a/app/models/metareview_response_map.rb +++ b/app/models/metareview_response_map.rb @@ -64,11 +64,11 @@ def self.import(row_hash, _session, id) contributor = AssignmentTeam.where(name: row_hash[:reviewee].to_s, parent_id: id).first raise ImportError, 'Contributor, ' + row_hash[:reviewee].to_s + ', was not found.' if contributor.nil? - ruser = User.find_by_name(row_hash[:reviewer].to_s.strip) + ruser = User.find_by_username(row_hash[:reviewer].to_s.strip) reviewee = AssignmentParticipant.where(user_id: ruser.id, parent_id: id).first raise ImportError, "Reviewee, #{row_hash[:reviewer]}, for contributor, #{contributor.name}, was not found." if reviewee.nil? - muser = User.find_by_name(row.to_s.strip) + muser = User.find_by_username(row.to_s.strip) reviewer = AssignmentParticipant.where(user_id: muser.id, parent_id: id) raise ImportError, "Metareviewer, #{row}, for contributor, #{contributor.name}, and reviewee, #{row_hash[:reviewer]}, was not found." if reviewer.nil? diff --git a/app/models/participant.rb b/app/models/participant.rb index cd282e096b7..1af7b893512 100644 --- a/app/models/participant.rb +++ b/app/models/participant.rb @@ -36,7 +36,7 @@ def responses end def name(ip_address = nil) - user.name(ip_address) + user.username(ip_address) end def fullname(ip_address = nil) @@ -102,7 +102,7 @@ def email(pw, home_page) body: { home_page: home_page, first_name: ApplicationHelper.get_user_first_name(user), - name: user.name, + name: user.username, password: pw, partial_name: 'register' } @@ -127,7 +127,7 @@ def authorization def self.sort_by_name(participants) users = [] participants.each { |p| users << p.user } - users.sort! { |a, b| a.name.downcase <=> b.name.downcase } # Sort the users based on the name + users.sort! { |a, b| a.username.downcase <=> b.username.downcase } # Sort the users based on the name participants.sort_by { |p| users.map(&:id).index(p.user_id) } end @@ -136,9 +136,9 @@ def self.export(csv, parent_id, options) where(parent_id: parent_id).find_each do |part| tcsv = [] user = part.user - tcsv.push(user.name, user.fullname, user.email) if options['personal_details'] == 'true' + tcsv.push(user.username, user.fullname, user.email) if options['personal_details'] == 'true' tcsv.push(user.role.name) if options['role'] == 'true' - tcsv.push(user.parent.name) if options['parent'] == 'true' + tcsv.push(user.parent.username) if options['parent'] == 'true' tcsv.push(user.email_on_submission, user.email_on_review, user.email_on_review_of_review) if options['email_options'] == 'true' tcsv.push(part.handle) if options['handle'] == 'true' csv << tcsv diff --git a/app/models/review_response_map.rb b/app/models/review_response_map.rb index 0ea43d9a0a7..b42e17ae9ad 100644 --- a/app/models/review_response_map.rb +++ b/app/models/review_response_map.rb @@ -45,7 +45,7 @@ def self.export(csv, parent_id, _options) def self.import(row_hash, _session, assignment_id) reviewee_user_name = row_hash[:reviewee].to_s - reviewee_user = User.find_by(name: reviewee_user_name) + reviewee_user = User.find_by(username: reviewee_user_name) raise ArgumentError, 'Cannot find reviewee user.' unless reviewee_user reviewee_participant = AssignmentParticipant.find_by(user_id: reviewee_user.id, parent_id: assignment_id) @@ -61,7 +61,7 @@ def self.import(row_hash, _session, assignment_id) end row_hash[:reviewers].each do |reviewer| reviewer_user_name = reviewer.to_s - reviewer_user = User.find_by(name: reviewer_user_name) + reviewer_user = User.find_by(username: reviewer_user_name) raise ArgumentError, 'Cannot find reviewer user.' unless reviewer_user next if reviewer_user_name.empty? diff --git a/app/models/sign_up_sheet.rb b/app/models/sign_up_sheet.rb index b245d7e0235..b6bf871fa23 100755 --- a/app/models/sign_up_sheet.rb +++ b/app/models/sign_up_sheet.rb @@ -89,7 +89,7 @@ def self.import(row_hash, session, _id = nil) while row_hash.length > params index = 'user_name_' + params.to_s - user = User.find_by(name: row_hash[index.to_sym].to_s) + user = User.find_by(username: row_hash[index.to_sym].to_s) raise ImportError, 'The user, ' + row_hash[index.to_sym].to_s.strip + ', was not found.' if user.nil? participant = AssignmentParticipant.where(parent_id: session[:assignment_id], user_id: user.id).first diff --git a/app/models/signed_up_team.rb b/app/models/signed_up_team.rb index 2a4564322b7..d59d05e2393 100755 --- a/app/models/signed_up_team.rb +++ b/app/models/signed_up_team.rb @@ -15,7 +15,7 @@ def self.find_team_participants(assignment_id, ip_address = nil) @participants.each_with_index do |participant, i| participant_names = User.joins('INNER JOIN teams_users ON users.id = teams_users.user_id') .joins('INNER JOIN teams ON teams.id = teams_users.team_id') - .select('users.name as u_name, teams.name as team_name') + .select('users.username as u_name, teams.name as team_name') .where('teams.id = ?', participant.team_id) team_name_added = false @@ -23,12 +23,12 @@ def self.find_team_participants(assignment_id, ip_address = nil) participant_names.each do |participant_name| if team_name_added - names += User.find_by(name: participant_name.u_name).name(ip_address) + ' ' - participant.user_name_placeholder += User.find_by(name: participant_name.u_name).name(ip_address) + ' ' + names += User.find_by(username: participant_name.u_name).name(ip_address) + ' ' + participant.user_name_placeholder += User.find_by(username: participant_name.u_name).name(ip_address) + ' ' else - names = '[' + participant_name.team_name + '] ' + User.find_by(name: participant_name.u_name).name(ip_address) + ' ' + names = '[' + participant_name.team_name + '] ' + User.find_by(username: participant_name.u_name).name(ip_address) + ' ' participant.team_name_placeholder = participant_name.team_name - participant.user_name_placeholder = User.find_by(name: participant_name.u_name).name(ip_address) + ' ' + participant.user_name_placeholder = User.find_by(username: participant_name.u_name).name(ip_address) + ' ' team_name_added = true end end diff --git a/app/models/student_task.rb b/app/models/student_task.rb index d6394a83792..650050cba4c 100644 --- a/app/models/student_task.rb +++ b/app/models/student_task.rb @@ -114,7 +114,7 @@ def self.teamed_students(user, ip_address = nil) teammates = [] course_id = Assignment.find_by(id: team.parent_id).course_id - team_participants = Team.find(team.id).participants.reject { |p| p.name == user.name } + team_participants = Team.find(team.id).participants.reject { |p| p.name == user.username } team_participants.each { |p| teammates << p.user.fullname(ip_address) } next if teammates.empty? diff --git a/app/models/team.rb b/app/models/team.rb index 908a63cec29..5f777f1f896 100755 --- a/app/models/team.rb +++ b/app/models/team.rb @@ -78,7 +78,8 @@ def full? # Add member to the team, changed to hash by E1776 def add_member(user, _assignment_id = nil) - raise "The user #{user.name} is already a member of the team #{name}" if user?(user) + username = user.respond_to?(:username) ? user.username : user.name + raise "The user #{username} is already a member of the team #{name}" if user?(user) can_add_member = false unless full? @@ -87,7 +88,7 @@ def add_member(user, _assignment_id = nil) parent = TeamNode.find_by(node_object_id: id) TeamUserNode.create(parent_id: parent.id, node_object_id: t_user.id) add_participant(parent_id, user) - ExpertizaLogger.info LoggerMessage.new('Model:Team', user.name, "Added member to the team #{id}") + ExpertizaLogger.info LoggerMessage.new('Model:Team', username, "Added member to the team #{id}") end can_add_member end @@ -191,7 +192,7 @@ def self.generate_team_name(_team_name_prefix = '') # Extract team members from the csv and push to DB, changed to hash by E1776 def import_team_members(row_hash) row_hash[:teammembers].each_with_index do |teammate, _index| - user = User.find_by(name: teammate.to_s) + user = User.find_by(username: teammate.to_s) if user.nil? raise ImportError, "The user '#{teammate}' was not found. Create this user?" else @@ -260,7 +261,7 @@ def self.export(csv, parent_id, options, teamtype) if options[:team_name] == 'false' team_members = TeamsUser.where(team_id: team.id) team_members.each do |user| - output.push(user.name) + output.push(user.user.username) end end csv << output diff --git a/app/models/teams_user.rb b/app/models/teams_user.rb index 1309120a34a..b96be67f72d 100644 --- a/app/models/teams_user.rb +++ b/app/models/teams_user.rb @@ -6,7 +6,7 @@ class TeamsUser < ApplicationRecord # attr_accessible :user_id, :team_id # unnecessary protected attributes def name(ip_address = nil) - name = user.name(ip_address) + name = user.username(ip_address) # E2115 Mentor Management # Indicate that someone is a Mentor in the UI. The view code is diff --git a/app/models/user.rb b/app/models/user.rb index 38e80f15b36..7d1bbae2eeb 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -19,9 +19,9 @@ class User < ApplicationRecord has_many :track_notifications, dependent: :destroy belongs_to :parent, class_name: 'User' belongs_to :role - validates :name, presence: true - validates :name, uniqueness: true - validates :name, format: { without: /\s/ } + validates :username, presence: true + validates :username, uniqueness: { case_sensitive: false } + validates :username, format: { without: /\s/ } validates :email, presence: { message: "can't be blank" } validates :email, format: { with: /\A[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\z/i, allow_blank: true } @@ -48,9 +48,9 @@ def list_mine(object_type, user_id) object_type.where(['instructor_id = ?', user_id]) end - def get_available_users(name) + def get_available_users(username) lesser_roles = role.get_parents - all_users = User.all(conditions: ['name LIKE ?', "#{name}%"], limit: 20) # higher limit, since we're filtering + all_users = User.all(conditions: ['username LIKE ?', "#{username}%"], limit: 20) # higher limit, since we're filtering visible_users = all_users.select { |user| lesser_roles.include? user.role } visible_users[0, 10] # the first 10 end @@ -107,13 +107,13 @@ def self.anonymized_view?(ip_address = nil) # from their anonymized names. The process of obtaining # real name is exactly opposite of what we'd do to get # anonymized name from their real name. - def self.real_user_from_anonymized_name(anonymized_name) - user = User.find_by(name: anonymized_name) + def self.real_user_from_anonymized_username(anonymized_username) + user = User.find_by(username: anonymized_username) user end - def name(ip_address = nil) - User.anonymized_view?(ip_address) ? role.name + ' ' + id.to_s : self[:name] + def username(ip_address = nil) + User.anonymized_view?(ip_address) ? role.name + ' ' + id.to_s : self[:username] end def fullname(ip_address = nil) @@ -164,7 +164,7 @@ def reset_password def self.import(row_hash, _row_header, session, _id = nil) raise ArgumentError, "Only #{row_hash.length} column(s) is(are) found. It must contain at least username, full name, email." if row_hash.length < 3 - user = User.find_by_name(row_hash[:username]) + user = User.find_by_username(row_hash[:username]) if user.nil? attributes = ImportFileHelper.define_attributes(row_hash) user = ImportFileHelper.create_new_user(attributes, session) @@ -195,7 +195,7 @@ def self.find_by_login(login) if user.nil? items = login.split('@') short_name = items[0] - user_list = User.where('name = ?', short_name) + user_list = User.where('username = ?', short_name) user = user_list.first if user_list.any? && user_list.length == 1 end user @@ -257,9 +257,9 @@ def self.export(csv, _parent_id, options) users = User.all users.each do |user| tcsv = [] - tcsv.push(user.name, user.fullname, user.email) if options['personal_details'] == 'true' + tcsv.push(user.username, user.fullname, user.email) if options['personal_details'] == 'true' tcsv.push(user.role.name) if options['role'] == 'true' - tcsv.push(user.parent.name) if options['parent'] == 'true' + tcsv.push(user.parent.username) if options['parent'] == 'true' tcsv.push(user.email_on_submission, user.email_on_review, user.email_on_review_of_review, user.copy_of_emails) if options['email_options'] == 'true' tcsv.push(user.etc_icons_on_homepage) if options['etc_icons_on_homepage'] == 'true' tcsv.push(user.handle) if options['handle'] == 'true' @@ -273,7 +273,7 @@ def creator def self.export_fields(options) fields = [] - fields.push('name', 'full name', 'email') if options['personal_details'] == 'true' + fields.push('username', 'full name', 'email') if options['personal_details'] == 'true' fields.push('role') if options['role'] == 'true' fields.push('parent') if options['parent'] == 'true' fields.push('email on submission', 'email on review', 'email on metareview', 'copy of emails') if options['email_options'] == 'true' @@ -286,7 +286,7 @@ def self.from_params(params) user = if params[:user_id] User.find(params[:user_id]) else - User.find_by name: params[:user][:name] + User.find_by username: params[:user][:username] end if user.nil? newuser = url_for controller: 'users', action: 'new' @@ -312,14 +312,14 @@ def teaching_assistant? end def self.search_users(role, user_id, letter, search_by) - key_word = { '1' => 'name', '2' => 'fullname', '3' => 'email' } + key_word = { '1' => 'username', '2' => 'fullname', '3' => 'email' } sql = "(role_id in (?) or id = ?) and #{key_word[search_by]} like ?" if key_word.include? search_by search_filter = '%' + letter + '%' - users = User.order('name').where(sql, role.get_available_roles, user_id, search_filter) + users = User.order('username').where(sql, role.get_available_roles, user_id, search_filter) else # default used when clicking on letters search_filter = letter + '%' - users = User.order('name').where('(role_id in (?) or id = ?) and name like ?', role.get_available_roles, user_id, search_filter) + users = User.order('username').where('(role_id in (?) or id = ?) and username like ?', role.get_available_roles, user_id, search_filter) end users end diff --git a/app/views/account_request/list_pending_requested.html.erb b/app/views/account_request/list_pending_requested.html.erb index 7f65e6fdfcb..bf2510b5d3b 100644 --- a/app/views/account_request/list_pending_requested.html.erb +++ b/app/views/account_request/list_pending_requested.html.erb @@ -19,7 +19,7 @@ <% @requested_users.each do |requested_user| %> - <%= requested_user.name %> + <%= requested_user.username %> <%= requested_user.fullname %> <%= mail_to requested_user.email, requested_user.email %> <%= Role.find_by(id: requested_user.role_id).try(:name) %> diff --git a/app/views/account_request/list_pending_requested_finalized.html.erb b/app/views/account_request/list_pending_requested_finalized.html.erb index 853e73da349..6b0fd73423d 100644 --- a/app/views/account_request/list_pending_requested_finalized.html.erb +++ b/app/views/account_request/list_pending_requested_finalized.html.erb @@ -9,7 +9,7 @@ <% @requested_users.each do |requested_user| %> <%= form_tag action: :create_approved_user, id: requested_user.id do %> - <%= requested_user.name %> + <%= requested_user.username %> <%= requested_user.fullname %> <%= mail_to requested_user.email, requested_user.email %> <%= Role.find_by(id: requested_user.role_id).try(:name) %> diff --git a/app/views/admin/_show.html.erb b/app/views/admin/_show.html.erb index 7e07daf0950..9cd8cf0272f 100644 --- a/app/views/admin/_show.html.erb +++ b/app/views/admin/_show.html.erb @@ -1,4 +1,4 @@ -

User: <%=h @user.name(session[:ip]) %>

+

User: <%=h @user.username(session[:ip]) %>

diff --git a/app/views/admin/list_administrators.html.erb b/app/views/admin/list_administrators.html.erb index 11f21ccb64a..5e8490bac56 100644 --- a/app/views/admin/list_administrators.html.erb +++ b/app/views/admin/list_administrators.html.erb @@ -1,14 +1,14 @@

Administrators

- + <% for user in @users %> - - + <% end -%>
NameFull nameE-mail addressParent
User nameFull nameE-mail addressParent
<%= link_to user.name(session[:ip]), :action => 'show_administrator', + <%= link_to user.username(session[:ip]), :action => 'show_administrator', :id => user.id %> <%= user.fullname(session[:ip]) %> <%= user.email(session[:ip]) %> <%= (User.find(user.parent_id)).name %> <%= (User.find(user.parent_id)).username %>
diff --git a/app/views/admin/list_instructors.html.erb b/app/views/admin/list_instructors.html.erb index 8a912bd544b..4e2a8451277 100644 --- a/app/views/admin/list_instructors.html.erb +++ b/app/views/admin/list_instructors.html.erb @@ -3,14 +3,14 @@ <%= will_paginate @users %> - + <% for user in @users%> - - + <% end -%>
NameFull NameEmail AddressParent
User nameFull NameEmail AddressParent
<%= link_to user.name(session[:ip]), :action => 'show_instructor', + <%= link_to user.username(session[:ip]), :action => 'show_instructor', :id => user.id %> <%= user.fullname(session[:ip]) %> <%= user.email(session[:ip]) %><%= (User.find(user.parent_id)).name %><%= (User.find(user.parent_id)).username %>
diff --git a/app/views/admin/list_super_administrators.html.erb b/app/views/admin/list_super_administrators.html.erb index f9a3bd40d69..50923f73825 100644 --- a/app/views/admin/list_super_administrators.html.erb +++ b/app/views/admin/list_super_administrators.html.erb @@ -1,10 +1,10 @@

Super-Administrators

- + <% for user in @users %> - diff --git a/app/views/advertise_for_partner/show.html.erb b/app/views/advertise_for_partner/show.html.erb index 30c5b87d736..7377a5f6916 100644 --- a/app/views/advertise_for_partner/show.html.erb +++ b/app/views/advertise_for_partner/show.html.erb @@ -18,7 +18,7 @@ <% for member in @student.team.participants %> - + <% if @student.assignment.questionnaires.find_by_type('TeammateReviewQuestionnaire') != nil and member.user.id != session[:user].id %> diff --git a/app/views/assessment360/all_students_all_reviews.html.erb b/app/views/assessment360/all_students_all_reviews.html.erb index c6822d8df13..4e03375a445 100644 --- a/app/views/assessment360/all_students_all_reviews.html.erb +++ b/app/views/assessment360/all_students_all_reviews.html.erb @@ -21,7 +21,7 @@ <% @course_participants.each do |cp|%> - + <% @assignments.each do |assignment|%> diff --git a/app/views/assessment360/course_student_grade_summary.html.erb b/app/views/assessment360/course_student_grade_summary.html.erb index e74f8e2034d..279d163f6c0 100644 --- a/app/views/assessment360/course_student_grade_summary.html.erb +++ b/app/views/assessment360/course_student_grade_summary.html.erb @@ -49,7 +49,7 @@ <% @course_participants.each do |cp|%> - + <% @assignments.each do |assignment|%> <% topic = format_topic(@topics[cp.id][assignment.id]) %> diff --git a/app/views/reports/_feedback_report.html.erb b/app/views/reports/_feedback_report.html.erb index a46ead170d3..0ff142358ee 100644 --- a/app/views/reports/_feedback_report.html.erb +++ b/app/views/reports/_feedback_report.html.erb @@ -90,7 +90,7 @@ <% if @frm.blank? %> @@ -104,7 +104,7 @@ <% feedback_response = Response.where(map_id: @frm.id).first %> @@ -115,7 +115,7 @@ @@ -165,7 +165,7 @@ @@ -179,7 +179,7 @@ @@ -190,7 +190,7 @@ <% else %> diff --git a/app/views/reports/_review_report.html.erb b/app/views/reports/_review_report.html.erb index d6ecafcfc77..1f913645f1e 100644 --- a/app/views/reports/_review_report.html.erb +++ b/app/views/reports/_review_report.html.erb @@ -68,7 +68,7 @@ diff --git a/app/views/reports/_self_review_report.html.erb b/app/views/reports/_self_review_report.html.erb index 2b6afc8a776..9ae1f6ffbc5 100644 --- a/app/views/reports/_self_review_report.html.erb +++ b/app/views/reports/_self_review_report.html.erb @@ -7,7 +7,7 @@ <% (@l % 2 == 0) ? @bgcolor = "#ffffff" : @bgcolor = "#DDDDBB" %> @@ -80,7 +80,7 @@ <%= 'N/A' %> <% else %> <% @reviewee = rm.reviewee.user %> - <%= link_to @reviewee.name(session[:ip]), impersonate_impersonate_path(:user => {:name => @reviewee.name}), :method => :post, :title => "Click here to impersonate this user" %> + <%= link_to @reviewee.name(session[:ip]), impersonate_impersonate_path(:user => {:username => @reviewee.name}), :method => :post, :title => "Click here to impersonate this user" %> (<%= @reviewee.fullname(session[:ip]) %>) <% end %> diff --git a/app/views/review_mapping/_list_review_mappings.html.erb b/app/views/review_mapping/_list_review_mappings.html.erb index 214c360de44..508184eb75f 100644 --- a/app/views/review_mapping/_list_review_mappings.html.erb +++ b/app/views/review_mapping/_list_review_mappings.html.erb @@ -59,13 +59,13 @@ <% if assignment.max_team_size < 2 %> - + <% if params[:model] == 'Assignment' %> <% end %> diff --git a/app/views/sign_up_sheet/show_team.html.erb b/app/views/sign_up_sheet/show_team.html.erb index e2000e5865d..f877c9f3f71 100644 --- a/app/views/sign_up_sheet/show_team.html.erb +++ b/app/views/sign_up_sheet/show_team.html.erb @@ -21,8 +21,8 @@ @join_team_requests = JoinTeamRequest.where(team_id: result[:team_id]) @join_team_requests.each do |join_team_request| if join_team_request.status=='P' - requesters_names << User.find(Participant.find(join_team_request.participant_id).user_id).name - requesters << {name: User.find(Participant.find(join_team_request.participant_id).user_id).name, request_id: join_team_request.id} + requesters_names << User.find(Participant.find(join_team_request.participant_id).user_id).username + requesters << {username: User.find(Participant.find(join_team_request.participant_id).user_id).username, request_id: join_team_request.id} end end %> @@ -30,7 +30,7 @@ <% team_members = [] TeamsUser.where(team_id: result[:team_id]).each{|teamuser| - team_members << User.find(teamuser.user_id).name + team_members << User.find(teamuser.user_id).username } if result[:advertise_for_partner]|| result[:advertise_for_partner] == 1 %> @@ -38,7 +38,7 @@ - <% if Participant.where(parent_id: result[:assignment_id], user_id: session[:user].id).first && !team_members.include?(session[:user].name) && !requesters_names.include?(session[:user].name) %> + <% if Participant.where(parent_id: result[:assignment_id], user_id: session[:user].id).first && !team_members.include?(session[:user].username) && !requesters_names.include?(session[:user].username) %> <% else %> - <% if team_members.include?(session[:user].name) %> + <% if team_members.include?(session[:user].username) %> <% else %> <% desired_id = -1 requesters.each do |requester| - if requester[:name] == session[:user].name + if requester[:name] == session[:user].username desired_id = requester[:request_id] end end diff --git a/app/views/student_teams/_invited_people.html.erb b/app/views/student_teams/_invited_people.html.erb index e055fa9e60b..15608fca0b2 100644 --- a/app/views/student_teams/_invited_people.html.erb +++ b/app/views/student_teams/_invited_people.html.erb @@ -1,6 +1,6 @@ - + <% if inv.reply_status == 'A' %> diff --git a/app/views/student_teams/_received_invitations.html.erb b/app/views/student_teams/_received_invitations.html.erb index 99f4db072ca..67a35eb638c 100644 --- a/app/views/student_teams/_received_invitations.html.erb +++ b/app/views/student_teams/_received_invitations.html.erb @@ -1,7 +1,7 @@ <% if inv.reply_status == 'W' %> - +
NameFull nameE-mail address
User nameFull nameE-mail address
<%= link_to user.name(session[:ip]), :action => 'show_super_administrator', + <%= link_to user.username(session[:ip]), :action => 'show_super_administrator', :id => user.id %> <%= user.fullname(session[:ip]) %> <%= user.email(session[:ip]) %>
<%= member.user.name(session[:ip]) %><%= member.user.username(session[:ip]) %> <%= member.user.fullname(session[:ip]) %> <%= member.user.email(session[:ip]) %>
<%= "#{cp.name(session[:ip])} (#{cp.fullname(session[:ip])})" %> <%= "#{cp.username(session[:ip])} (#{cp.fullname(session[:ip])})" %> <%= @teamed_count[cp.id] %><%= @meta_review[cp.id][assignment.id] unless @meta_review.nil? %>
<%= "#{cp.name(session[:ip])} (#{cp.fullname(session[:ip])})" %> <%= "#{cp.username(session[:ip])} (#{cp.fullname(session[:ip])})" %> diff --git a/app/views/assignments/edit/_calibration.html.erb b/app/views/assignments/edit/_calibration.html.erb index def870265ca..60ba9869045 100644 --- a/app/views/assignments/edit/_calibration.html.erb +++ b/app/views/assignments/edit/_calibration.html.erb @@ -5,7 +5,7 @@ '; } else if (round_no == null && duty_id != undefined) { - // E2147 : Add name of duty infront of the questionnaire type to select for which duty the questionnaire is being selected + // E2147 : Add name of duty in front of the questionnaire type to select for which duty the questionnaire is being selected html += ''; } else if (round_no!=null && duty_id == undefined) { diff --git a/app/views/assignments/list_submissions.html.erb b/app/views/assignments/list_submissions.html.erb index 81342e88533..5890f18b61b 100644 --- a/app/views/assignments/list_submissions.html.erb +++ b/app/views/assignments/list_submissions.html.erb @@ -13,7 +13,7 @@ <% headers["Team name"] = "14%" %> <% headers["Team member(s)"] = "18%" %> <% else %> - <% headers["Participant name"] = "18%" %> + <% headers["Participant User name"] = "18%" %> <% end %> <% headers["Submitted item(s)"] = nil %> @@ -34,7 +34,7 @@ <% pair_programming_enabled = false %> <% end %> <% else %> - + <% end %> @@ -66,10 +66,10 @@ <% end %> <% end %> - + diff --git a/app/views/auth/_login.html.erb b/app/views/auth/_login.html.erb index e7444d28e39..8d9f8b3f941 100644 --- a/app/views/auth/_login.html.erb +++ b/app/views/auth/_login.html.erb @@ -12,10 +12,10 @@ <%= form_for :impersonate, url: '/impersonate/impersonate' do |f| %>
- Participant name + Participant User name Action @@ -21,7 +21,7 @@ <% users_for_curr_team = "" %> <% teams_users.each do |teams_user| %> <% user = User.find(teams_user.user_id) %> - <% users_for_curr_team += user.name(session[:ip]) + ' (' + user.fullname(session[:ip]) + ')' + '
' %> + <% users_for_curr_team += user.username(session[:ip]) + ' (' + user.fullname(session[:ip]) + ')' + '
' %> <% participants = Array.new %> <% participants << Participant.where(["parent_id = ? AND user_id = ?", assignment.id, user.id]).first %> <% end %> diff --git a/app/views/assignments/edit/_rubrics.html.erb b/app/views/assignments/edit/_rubrics.html.erb index 9802f11c179..c94fbf7a92c 100644 --- a/app/views/assignments/edit/_rubrics.html.erb +++ b/app/views/assignments/edit/_rubrics.html.erb @@ -19,7 +19,7 @@ if (round_no == null && duty_id == undefined) { html += '
Participant nameParticipant User nameLinks <% users_for_curr_team.each do |user| %> - <%= link_to user.name(session[:ip]), impersonate_impersonate_path(:user => {:name => user.name(session[:ip])}), :method => :post %> + <%= link_to user.username(session[:ip]), impersonate_impersonate_path(:user => {:username => user.username(session[:ip])}), :method => :post %> (<%= user.fullname(session[:ip])%>)
<% end %>
- + - @@ -25,7 +25,7 @@ <%= form_tag :controller => 'auth', :action => 'logout' do %>
User: <%= current_user.name(session[:ip]) %>User: <%= current_user.username(session[:ip]) %>
<%= f.text_field :name, size: 12, +
<%= f.text_field :username, size: 12, title: "Enter a user account to impersonate", data: { onKeyUp: "UpdateButton();" } %>
<%= f.submit "Revert", id: "revert_button" %>
- + @@ -35,8 +35,8 @@ <% else %> - + id="<%= prefix %>" style="display:none; background-color: white;" <% end %>> - diff --git a/app/views/join_team_requests/_list_received.html.erb b/app/views/join_team_requests/_list_received.html.erb index 63145f74c13..14087301698 100644 --- a/app/views/join_team_requests/_list_received.html.erb +++ b/app/views/join_team_requests/_list_received.html.erb @@ -14,7 +14,7 @@ <% if is_admin %> - + <% end %> diff --git a/app/views/mailer/partials/_author_conference_invitation_html.html.erb b/app/views/mailer/partials/_author_conference_invitation_html.html.erb index 5bc12124225..50dd31fc368 100644 --- a/app/views/mailer/partials/_author_conference_invitation_html.html.erb +++ b/app/views/mailer/partials/_author_conference_invitation_html.html.erb @@ -8,6 +8,6 @@ Hi <%= @first_name %>,

-User Name: <%= @user.name %>
+User Name: <%= @user.username %>
E-mail address: <%= @user.email %>

New password: <%= @password %>
diff --git a/app/views/mailer/partials/_author_conference_invitation_plain.html.erb b/app/views/mailer/partials/_author_conference_invitation_plain.html.erb index 7e6348de421..ea5e87a79bf 100644 --- a/app/views/mailer/partials/_author_conference_invitation_plain.html.erb +++ b/app/views/mailer/partials/_author_conference_invitation_plain.html.erb @@ -4,7 +4,7 @@ Thank you for registering for [name of assignment]. To confirm your account, pl After you have set up a password, you will be able to log in and submit your work. We strongly recommend that you change the password the first time you access the application. Please update your profile. -User Name: <%= @user.name %> +User Name: <%= @user.username %> E-mail address: <%= @user.email %> New password: <%= @password %> diff --git a/app/views/mailer/partials/_user_conference_invitation_html.html.erb b/app/views/mailer/partials/_user_conference_invitation_html.html.erb index b176941be8d..3c3a2e3cf9e 100644 --- a/app/views/mailer/partials/_user_conference_invitation_html.html.erb +++ b/app/views/mailer/partials/_user_conference_invitation_html.html.erb @@ -9,6 +9,6 @@ Hi <%= @first_name %>,

-User Name: <%= @user.name %>
+User Name: <%= @user.username %>
E-mail address: <%= @user.email %>

New password: <%= @password %>
diff --git a/app/views/mailer/partials/_user_conference_invitation_plain.html.erb b/app/views/mailer/partials/_user_conference_invitation_plain.html.erb index 4f0a095fcc0..86a94a9bb67 100644 --- a/app/views/mailer/partials/_user_conference_invitation_plain.html.erb +++ b/app/views/mailer/partials/_user_conference_invitation_plain.html.erb @@ -5,7 +5,7 @@ To confirm your account, please click on this link http://expertiza.ncsu.edu After you have set up a password, you will be able to log in and access your co-author's work. We strongly recommend that you change the password the first time you access the application. Please update your profile. -User Name: <%= @user.name %> +User Name: <%= @user.username %> E-mail address: <%= @user.email %> New password: <%= @password %> diff --git a/app/views/mailer/partials/_user_welcome_html.html.erb b/app/views/mailer/partials/_user_welcome_html.html.erb index 30a813892d4..b1f774de0a8 100644 --- a/app/views/mailer/partials/_user_welcome_html.html.erb +++ b/app/views/mailer/partials/_user_welcome_html.html.erb @@ -5,6 +5,6 @@ Hi <%= @first_name %>,
We strongly recommend that you change the password the first time you access the application.

-User Name: <%= @user.name %>
+User Name: <%= @user.username %>
E-mail address:<%= @user.email %>

New password: <%= @password %>
diff --git a/app/views/mailer/partials/_user_welcome_plain.html.erb b/app/views/mailer/partials/_user_welcome_plain.html.erb index 4456bbd4ab0..351489c8420 100644 --- a/app/views/mailer/partials/_user_welcome_plain.html.erb +++ b/app/views/mailer/partials/_user_welcome_plain.html.erb @@ -4,7 +4,7 @@ Your Expertiza account has been created at http://expertiza.ncsu.edu . We strongly recommend that you change the password the first time you access the application. -User Name: <%= @user.name %> +User Name: <%= @user.username %> E-mail address:<%= @user.email %> New password: <%= @password %> diff --git a/app/views/mailer/request_user_message.html.erb b/app/views/mailer/request_user_message.html.erb index d361e024fa8..22b67a221ab 100644 --- a/app/views/mailer/request_user_message.html.erb +++ b/app/views/mailer/request_user_message.html.erb @@ -8,7 +8,7 @@ Hi <%= @first_name %>,

Below user requested to sign up. Review by going to Expertiza.

-Name: <%= @user.name %>
+Username: <%= @user.username %>


diff --git a/app/views/participants/_participant.html.erb b/app/views/participants/_participant.html.erb index e848939755a..139ca9b2849 100644 --- a/app/views/participants/_participant.html.erb +++ b/app/views/participants/_participant.html.erb @@ -1,10 +1,10 @@ <% userid << participant.user_id %> - + - + <% if @model == 'Assignment' && participant.assignment.badge? %> <% end %> diff --git a/app/views/participants/view_copyright_grants.html.erb b/app/views/participants/view_copyright_grants.html.erb index 92780febf6e..d13617bce3c 100644 --- a/app/views/participants/view_copyright_grants.html.erb +++ b/app/views/participants/view_copyright_grants.html.erb @@ -35,7 +35,7 @@ <% users.each do |user| %> - + - + diff --git a/app/views/profile/edit.html.erb b/app/views/profile/edit.html.erb index dc4ee37de9e..13dd4141bbf 100644 --- a/app/views/profile/edit.html.erb +++ b/app/views/profile/edit.html.erb @@ -4,7 +4,7 @@ <%= form_for @user, url: profile_index_path, method: :patch do |f| %>
User: <%= current_user.name(session[:ip]) %>User: <%= current_user.username(session[:ip]) %>
<%= submit_tag "Logout", id: 'logout-button' %>
<%= User.find(ta.ta_id).name(session[:ip]) %><%= User.find(ta.ta_id).username(session[:ip]) %> <%= link_to "Edit", {:action => 'show', :controller =>'users', :id => ta.ta_id} %> <%= link_to "Delete", { :action => 'remove_ta', :controller =>'courses', :id => ta.id, :course_id => ta.course_id }, method: :post, :remote => true, :class => 'remove_ta' %> diff --git a/app/views/grades/_participant.html.erb b/app/views/grades/_participant.html.erb index 85de92763dc..1d874cc6b27 100644 --- a/app/views/grades/_participant.html.erb +++ b/app/views/grades/_participant.html.erb @@ -14,7 +14,7 @@ %>
<%= link_to participant.name(session[:ip]), impersonate_impersonate_path(:user => {:name => User.find(participant.user_id).name}), :method => :post %> (<%= participant.fullname(session[:ip]) %>)
+
<%= link_to participant.name(session[:ip]), impersonate_impersonate_path(:user => {:username => User.find(participant.user_id).username}), :method => :post %> (<%= participant.fullname(session[:ip]) %>)
<% if (controller.action_name != "view_my_scores" and index == team_size - 1) or controller.action_name == "view_my_scores" %> <%=t ".show_submission"%> <% if @topic_id %> (<%= SignUpTopic.find(@topic_id).topic_identifier %>)<% end %> diff --git a/app/views/grades/_team.html.erb b/app/views/grades/_team.html.erb index 184e8867c72..91e1710056c 100644 --- a/app/views/grades/_team.html.erb +++ b/app/views/grades/_team.html.erb @@ -12,13 +12,13 @@ <%= tscore[:team].name(session[:ip]) + ' (' + SignUpTopic.find(topic_id).topic_identifier + ')' %> <% else %> <% if @assignment.max_team_size == 1 %> - <%= tscore[:team].users.first.name(session[:ip]) + ' (' + tscore[:team].users.first.fullname(session[:ip]) + ')' rescue '' %> + <%= tscore[:team].users.first.username(session[:ip]) + ' (' + tscore[:team].users.first.fullname(session[:ip]) + ')' rescue '' %> <% else %> <%= tscore[:team].name(session[:ip]) %> | <% for index in 0..tscore[:team].users.length - 2 %> - <%= tscore[:team].users[index].name(session[:ip]) %>, + <%= tscore[:team].users[index].username(session[:ip]) %>, <% end %> - <%= tscore[:team].users[tscore[:team].users.length - 1].name(session[:ip]) unless tscore[:team].users[tscore[:team].users.length - 1].nil?%> + <%= tscore[:team].users[tscore[:team].users.length - 1].username(session[:ip]) unless tscore[:team].users[tscore[:team].users.length - 1].nil?%> <% end %> <% end %>
- <%= User.find(Participant.find(join_team_request.participant_id).user_id).name %> + <%= User.find(Participant.find(join_team_request.participant_id).user_id).username %> <%= join_team_request.comments %> @@ -27,7 +27,7 @@ <%= hidden_field_tag 'team_id', team_id %> <%= hidden_field_tag 'student_id', teams_user_id %> <%= hidden_field_tag 'session[:dummy][:assignment_id]', Participant.find(join_team_request.participant_id).parent_id %> - <%= hidden_field_tag 'user[name]', User.find(Participant.find(join_team_request.participant_id).user_id).name %> + <%= hidden_field_tag 'user[username]', User.find(Participant.find(join_team_request.participant_id).user_id).username %> <%= hidden_field_tag 'participant_id', join_team_request.participant_id %> <% end %> diff --git a/app/views/late_policies/index.html.erb b/app/views/late_policies/index.html.erb index e40ff46dd35..8d2c19cc770 100644 --- a/app/views/late_policies/index.html.erb +++ b/app/views/late_policies/index.html.erb @@ -27,7 +27,7 @@ end <%= penalty_policy.penalty_unit %> <%= penalty_policy.max_penalty %><%= User.find(penalty_policy.instructor_id).name %><%= User.find(penalty_policy.instructor_id).username %><%= link_to 'Edit', :action => 'edit', :id => penalty_policy %> <%= link_to 'Delete', penalty_policy, :method => 'delete', confirm: 'Are you sure?' %>
<%= link_to participant.user.name(session[:ip]), impersonate_impersonate_path(:user => {:name => participant.user.name(session[:ip])}), :method => :post %><%= link_to participant.user.username(session[:ip]), impersonate_impersonate_path(:user => {:username => participant.user.username(session[:ip])}), :method => :post %> <%= link_to participant.user.fullname(session[:ip]), :controller=> 'users', :action => 'show', :id => participant.user_id %> <%= participant.user.email(session[:ip]) %> <%= participant.user.role.name %><%= (User.find(participant.user.parent_id)).name(session[:ip]) %><%= (User.find(participant.user.parent_id)).username(session[:ip]) %><%= get_awarded_badges(participant) %> <%=user[:name]%> <%=user[:username]%> <%=user[:fullname]%> <%=user[:pub_rights]%> diff --git a/app/views/popup/reviewer_details_popup.html.erb b/app/views/popup/reviewer_details_popup.html.erb index a83b7111a51..039df3a0e74 100644 --- a/app/views/popup/reviewer_details_popup.html.erb +++ b/app/views/popup/reviewer_details_popup.html.erb @@ -10,7 +10,7 @@
User id: <%= @user.name(session[:ip]) %> <%= @user.username(session[:ip]) %>
email:
- <%= render :partial => 'users/name' %> + <%= render :partial => 'users/username' %> <%= render :partial => 'users/password' %> <%= render :partial => 'users/email' %> diff --git a/app/views/reports/_answer_tagging_report.html.erb b/app/views/reports/_answer_tagging_report.html.erb index 46484416b69..f6b94bf069d 100644 --- a/app/views/reports/_answer_tagging_report.html.erb +++ b/app/views/reports/_answer_tagging_report.html.erb @@ -45,7 +45,7 @@ <% report_lines.each do |report_line| %> - + @@ -94,13 +94,13 @@ <% @user_tagging_report.each do |key, val| %> - + - + <% end %>
<%=t ".password_msg"%>
<%= report_line.user.name(session[:ip]) %><%= report_line.user.username(session[:ip]) %> <%= report_line.user.fullname(session[:ip]) %> <%= report_line.percentage.to_s %>% <%= report_line.no_tagged.to_s %>
<%= val.user.name(session[:ip]) %><%= val.user.username(session[:ip]) %> <%= val.user.fullname(session[:ip]) %> <%= val.percentage.to_s %>% <%= val.no_tagged.to_s %> <%= val.no_not_tagged.to_s %> <%= val.no_tagable %><%= check_box_tag 'names[]', val.user.name(session[:ip]), true %><%= check_box_tag 'names[]', val.user.username(session[:ip]), true %>
diff --git a/app/views/reports/_bookmark_rating_report.html.erb b/app/views/reports/_bookmark_rating_report.html.erb index 68fb61d6d04..c1993d5101b 100644 --- a/app/views/reports/_bookmark_rating_report.html.erb +++ b/app/views/reports/_bookmark_rating_report.html.erb @@ -38,8 +38,8 @@
style="color:#DD3300" align="left" colspan=1> - <% reviewed_by_user = User.find(@reviewee.user_id).name %> - <%= link_to reviewed_by_user, impersonate_impersonate_path(:user => {:name => reviewed_by_user}), :method => :post, :title => "Click here to impersonate this user" %> + <% reviewed_by_user = User.find(@reviewee.user_id).username %> + <%= link_to reviewed_by_user, impersonate_impersonate_path(:user => {:username => reviewed_by_user}), :method => :post, :title => "Click here to impersonate this user" %> - <%= link_to user_name = Participant.find(review_response.response_map.reviewer_id).user.name(session[:ip]), impersonate_impersonate_path(:user => {:name => user_name}), :method => :post, :title => "Click here to impersonate this user" %> + <%= link_to user_name = Participant.find(review_response.response_map.reviewer_id).user.username(session[:ip]), impersonate_impersonate_path(:user => {:username => user_name}), :method => :post, :title => "Click here to impersonate this user" %> (<%= Participant.find(review_response.response_map.reviewer_id).user.fullname(session[:ip]) %>) - <%= link_to user_name = Participant.find(review_response.response_map.reviewer_id).user.name(session[:ip]), impersonate_impersonate_path(:user => {:name => user_name}), :method => :post, :title => "Click here to impersonate this user" %> + <%= link_to user_name = Participant.find(review_response.response_map.reviewer_id).user.username(session[:ip]), impersonate_impersonate_path(:user => {:username => user_name}), :method => :post, :title => "Click here to impersonate this user" %> (<%= link_to @reviewee_name, :controller => 'popup', :action => 'author_feedback_popup', :response_id => feedback_response.id, :reviewee_id => @frm.reviewee_id, :source => 'author_feedback' %>) - <%= link_to user_name = Participant.find(review_response.response_map.reviewer_id).user.name(session[:ip]), impersonate_impersonate_path(:user => {:name => user_name}), :method => :post, :title => "Click here to impersonate this user" %> + <%= link_to user_name = Participant.find(review_response.response_map.reviewer_id).user.username(session[:ip]), impersonate_impersonate_path(:user => {:username => user_name}), :method => :post, :title => "Click here to impersonate this user" %> (<%= @reviewee_name %>) - <%= link_to user_name = Participant.find(review_response.response_map.reviewer_id).user.name(session[:ip]), impersonate_impersonate_path(:user => {:name => user_name}), :method => :post, :title => "Click here to impersonate this user" %> + <%= link_to user_name = Participant.find(review_response.response_map.reviewer_id).user.username(session[:ip]), impersonate_impersonate_path(:user => {:username => user_name}), :method => :post, :title => "Click here to impersonate this user" %> (<%= reviewee_name = Participant.find(review_response.response_map.reviewer_id).user.fullname(session[:ip]) %>) - <%= link_to user_name = Participant.find(review_response.response_map.reviewer_id).user.name(session[:ip]), impersonate_impersonate_path(:user => {:name => user_name}), :method => :post, :title => "Click here to impersonate this user"%> + <%= link_to user_name = Participant.find(review_response.response_map.reviewer_id).user.username(session[:ip]), impersonate_impersonate_path(:user => {:username => user_name}), :method => :post, :title => "Click here to impersonate this user"%> (<%= link_to @reviewee_name, :controller => 'popup', :action => 'author_feedback_popup', :response_id => feedback_response.id, :reviewee_id => @frm.reviewee_id, :source => 'author_feedback' %>) - <%= link_to user_name = Participant.find(review_response.response_map.reviewer_id).user.name(session[:ip]), impersonate_impersonate_path(:user => {:name => user_name}), :method => :post, :title => "Click here to impersonate this user" %> + <%= link_to user_name = Participant.find(review_response.response_map.reviewer_id).user.username(session[:ip]), impersonate_impersonate_path(:user => {:username => user_name}), :method => :post, :title => "Click here to impersonate this user" %> (<%= @reviewee_name %>) <%= index + 1 %>. - <%= link_to user.name(session[:ip]), impersonate_impersonate_path(:user => {:name => user.name(session[:ip])}), :method => :post, :class => "user_unityID" %> + <%= link_to user.username(session[:ip]), impersonate_impersonate_path(:user => {:username => user.username(session[:ip])}), :method => :post, :class => "user_unityID" %> (<%= user.fullname(session[:ip]) %>) align='left'> - <%= link_to @user_name = Participant.find(sr.reviewer_id).user.name(session[:ip]), impersonate_impersonate_path(:user => {:name => @user_name}), :method => :post, :title => "Click here to impersonate this user" %> + <%= link_to @user_name = Participant.find(sr.reviewer_id).user.username(session[:ip]), impersonate_impersonate_path(:user => {:username => @user_name}), :method => :post, :title => "Click here to impersonate this user" %> align='left'> diff --git a/app/views/reports/_teammate_review_report.html.erb b/app/views/reports/_teammate_review_report.html.erb index c525dd88376..0528a5c672d 100644 --- a/app/views/reports/_teammate_review_report.html.erb +++ b/app/views/reports/_teammate_review_report.html.erb @@ -66,7 +66,7 @@ <% @reviewee = rm.reviewee.user %> - <%= link_to @reviewee.name(session[:ip]), impersonate_impersonate_path(:user => {:name => @reviewee.name}), :method => :post, :title => "Click here to impersonate this user" %> + <%= link_to @reviewee.name(session[:ip]), impersonate_impersonate_path(:user => {:username => @reviewee.name}), :method => :post, :title => "Click here to impersonate this user" %> (<%= @reviewee.fullname(session[:ip]) %>) <% user_id = TeamsUser.where(team_id: contributor.id).first.user_id %> - <%= User.find(user_id).fullname(session[:ip]) %> (<%= User.find(user_id).name(session[:ip]) %>)
+ <%= User.find(user_id).fullname(session[:ip]) %> (<%= User.find(user_id).username(session[:ip]) %>)
<% else %> -
<%= contributor.name %>
+
<%= contributor.username %>
<% team_members = TeamsUser.where(team_id: contributor.id) %> <% team_members.each do |team_member| %> <%= User.find(team_member['user_id']).fullname(session[:ip]) %>  - (<%= User.find(team_member['user_id']).name(session[:ip]) %>)
+ (<%= User.find(team_member['user_id']).username(session[:ip]) %>)
<% end %> <% end %> diff --git a/app/views/review_mapping/select_metareviewer.html.haml b/app/views/review_mapping/select_metareviewer.html.haml index 03d0d678e94..965e6fde824 100644 --- a/app/views/review_mapping/select_metareviewer.html.haml +++ b/app/views/review_mapping/select_metareviewer.html.haml @@ -10,7 +10,7 @@ Assignment: #{@mapping.assignment.name} %br/ = form_tag({:action => 'add_metareviewer'}, {:method => 'post'}) do - Enter a user login: #{text_field_with_auto_complete :user, :name, {:size => 41}} + Enter a user login: #{text_field_with_auto_complete :user, :username, {:size => 41}} \#{hidden_field_tag('id', @mapping.map_id)} %input{:type => "submit", :value => "Add Metareviewer"}/ %br/ diff --git a/app/views/review_mapping/select_reviewer.html.haml b/app/views/review_mapping/select_reviewer.html.haml index 7be0eb02345..b0c215163de 100644 --- a/app/views/review_mapping/select_reviewer.html.haml +++ b/app/views/review_mapping/select_reviewer.html.haml @@ -1,10 +1,10 @@ %h1 Add Reviewer %h2 - Contributor: #{@contributor.name} + Contributor: #{@contributor.username} %h2 Assignment: #{@contributor.assignment.name} %br/ = form_tag :action => 'add_reviewer', :id => @contributor.parent_id do - Enter a user login: #{text_field_with_auto_complete :user, :name, {:size => 41}} + Enter a user login: #{text_field_with_auto_complete :user, :username, {:size => 41}} \#{hidden_field_tag('contributor_id', @contributor.id)} %input{:type => "submit", :value => "Add Reviewer"}/ \ No newline at end of file diff --git a/app/views/roles/show.html.erb b/app/views/roles/show.html.erb index b2999c04566..bfe9ed62790 100644 --- a/app/views/roles/show.html.erb +++ b/app/views/roles/show.html.erb @@ -12,7 +12,7 @@ <% if @users and @users.length > 0 -%>
    <% for user in @users do -%> -
  • <%= link_to user.name(session[:ip]), :controller => 'users', +
  • <%= link_to user.username(session[:ip]), :controller => 'users', :action => 'show', :id => user.id %>
  • <% end -%>
diff --git a/app/views/shared/_navigation.html.erb b/app/views/shared/_navigation.html.erb index 07b8b4fe2c9..8b98cee7ddf 100644 --- a/app/views/shared/_navigation.html.erb +++ b/app/views/shared/_navigation.html.erb @@ -59,7 +59,7 @@ <% end %>
  • - User: <%= current_user.name(session[:ip]) %> + User: <%= current_user.username(session[:ip]) %>
  • diff --git a/app/views/shared_scripts/_add_individual.html.erb b/app/views/shared_scripts/_add_individual.html.erb index 893d67f036f..37195b478c2 100644 --- a/app/views/shared_scripts/_add_individual.html.erb +++ b/app/views/shared_scripts/_add_individual.html.erb @@ -1,5 +1,5 @@ <%= form_tag form_action, :id => "part_add", :method => 'post', :class => "form-inline", :remote => remote do %> - Enter a user login: <%= text_field_with_auto_complete :user, :name, {:size => 20, :class => "form-control", :style => "width: 250px"} %> + Enter a user login: <%= text_field_with_auto_complete :user, :username, {:size => 20, :class => "form-control", :style => "width: 250px"} %> <%= hidden_field_tag(obj_type, obj_id) %> <%= hidden_field_tag('model', model) %> diff --git a/app/views/shared_scripts/_user_list.html.erb b/app/views/shared_scripts/_user_list.html.erb index 0a3ff3a3187..01d0657f695 100644 --- a/app/views/shared_scripts/_user_list.html.erb +++ b/app/views/shared_scripts/_user_list.html.erb @@ -16,7 +16,7 @@
  • Submit Review Take quizMentor<%= result[:name] %> <%= team_members.join(', ') %> <%= result[:comments_for_advertisement] %><%= link_to "Request invitation", :controller => 'join_team_requests', :action => 'new', :assignment_id=>result[:assignment_id], :topic_id=>result[:topic_id], @@ -47,13 +47,13 @@
    <%= inv.to_user.name(session[:ip]) %><%= inv.to_user.username(session[:ip]) %> <%= inv.to_user.fullname(session[:ip]) %> <%= inv.to_user.email(session[:ip]) %>
    <%= inv.from_user.name(session[:ip]) %><%= inv.from_user.username(session[:ip]) %> <% teams_users = TeamsUser.where(['user_id = ?', inv.from_id]) %> <% teams_users.each do |teams_user| %> diff --git a/app/views/student_teams/_send_invitations.html.erb b/app/views/student_teams/_send_invitations.html.erb index 726d8031f87..ce54d69f293 100644 --- a/app/views/student_teams/_send_invitations.html.erb +++ b/app/views/student_teams/_send_invitations.html.erb @@ -16,7 +16,7 @@ @@ -35,7 +35,7 @@ <% @users_on_waiting_list.each do |user|%> - + diff --git a/app/views/student_teams/_team_display.html.erb b/app/views/student_teams/_team_display.html.erb index 8aa37858823..914f81bb91c 100644 --- a/app/views/student_teams/_team_display.html.erb +++ b/app/views/student_teams/_team_display.html.erb @@ -15,7 +15,7 @@ <% @student.team.participants.each do |member| %> - + <%if @student.assignment.duty_based_assignment? %> <% team_user = member.team_user %> diff --git a/app/views/student_teams/mentor.html.erb b/app/views/student_teams/mentor.html.erb index 1b7660e6e1c..9a85193ecd2 100644 --- a/app/views/student_teams/mentor.html.erb +++ b/app/views/student_teams/mentor.html.erb @@ -31,7 +31,7 @@ <% team.participants.each do |member| %> <% unless MentorManagement.user_a_mentor?(member.user) %> - + <%if @student.assignment.duty_based_assignment? %> <% team_user = member.team_user %> diff --git a/app/views/student_teams/view.html.erb b/app/views/student_teams/view.html.erb index 4b75fa8d03a..e509a83893f 100644 --- a/app/views/student_teams/view.html.erb +++ b/app/views/student_teams/view.html.erb @@ -61,7 +61,7 @@ <% @student.team.participants.each do |member| %> - + <%if @student.assignment.duty_based_assignment? %> <% team_user = member.team_user %> @@ -141,7 +141,7 @@ <% @student.team.participants.each do |member| %> - + <% status = TeamsUser.find_by(user_id: member.user.id, team_id: member.team.id).pair_programming_status %> @@ -189,7 +189,7 @@ <% @send_invs.each do |inv| %> - + <% if inv.reply_status == 'A' %> @@ -226,7 +226,7 @@
    - <%=t ".enter_user"%><%= text_field_with_auto_complete :user, :name, {:size => 41} %> + <%=t ".enter_user"%><%= text_field_with_auto_complete :user, :username, {:size => 41} %>
      <%=user.name(session[:ip])%>     <%=user.username(session[:ip])%>     <%=user.fullname(session[:ip])%>     <%=user.email(session[:ip])%>  
    <%= member.user.name(session[:ip]) %><%= member.user.username(session[:ip]) %> <%= member.user.fullname(session[:ip]) %>
    <%= member.user.name(session[:ip]) %><%= member.user.username(session[:ip]) %> <%= member.user.fullname(session[:ip]) %>
    <%= member.user.name(session[:ip]) %><%= member.user.username(session[:ip]) %> <%= member.user.fullname(session[:ip]) %>
    <%= member.user.name(session[:ip]) %><%= member.user.username(session[:ip]) %> <%= member.user.fullname(session[:ip]) %> <%= member.user.email(session[:ip]) %>
    <%= inv.to_user.name(session[:ip]) %><%= inv.to_user.username(session[:ip]) %> <%= inv.to_user.fullname(session[:ip]) %> <%= inv.to_user.email(session[:ip]) %>
    @@ -245,7 +245,7 @@ <% @users_on_waiting_list.each do |user|%> - + @@ -266,7 +266,7 @@ <% @received_invs.each do |inv| %> <% if inv.reply_status == 'W' %> - +
    - <%=t ".enter_user"%><%= text_field_with_auto_complete :user, :name, {:size => 41} %> + <%=t ".enter_user"%><%= text_field_with_auto_complete :user, :username, {:size => 41} %>
      <%=user.name(session[:ip])%>     <%=user.username(session[:ip])%>     <%=user.fullname(session[:ip])%>     <%=user.email(session[:ip])%>  
    <%= inv.from_user.name(session[:ip]) %><%= inv.from_user.username(session[:ip]) %> <% teams_users = TeamsUser.where(['user_id = ?', inv.from_id]) %> <% teams_users.each do |teams_user| %> diff --git a/app/views/teams_users/_form.html.erb b/app/views/teams_users/_form.html.erb index c49ea6a78d4..b3f4b4c4b55 100644 --- a/app/views/teams_users/_form.html.erb +++ b/app/views/teams_users/_form.html.erb @@ -1,4 +1,4 @@ <%= hidden_field_tag 'id', @team.id %> -Enter user login: <%= text_field_with_auto_complete :user, :name, {:size => 41} %> +Enter user login: <%= text_field_with_auto_complete :user, :username, {:size => 41} %> <% end %> diff --git a/app/views/teams_users/_members.html.erb b/app/views/teams_users/_members.html.erb index 5483ecbc1ef..b92e0c3f08c 100644 --- a/app/views/teams_users/_members.html.erb +++ b/app/views/teams_users/_members.html.erb @@ -1,7 +1,7 @@
      <% @users.each do | user |-%>
    • -
      <%= user.name(session[:ip]).strip %>
      +
      <%= user.username(session[:ip]).strip %>
    • <% end -%>
    diff --git a/app/views/teams_users/new.html.erb b/app/views/teams_users/new.html.erb index 68dba216e35..e3118db89b2 100644 --- a/app/views/teams_users/new.html.erb +++ b/app/views/teams_users/new.html.erb @@ -3,7 +3,7 @@ <%= form_tag :action => 'create' do %> <%= hidden_field_tag 'id', @team.id %> - Enter user login: <%= text_field_with_auto_complete :user, :name, {:size => 41} %> + Enter user login: <%= text_field_with_auto_complete :user, :username, {:size => 41} %> <% end %> diff --git a/app/views/users/_user.html.erb b/app/views/users/_user.html.erb index 2029d73b1e5..a9d16e55254 100644 --- a/app/views/users/_user.html.erb +++ b/app/views/users/_user.html.erb @@ -5,7 +5,7 @@ <%= text_field 'user', 'name' %>

    <% new_user ||= false %> -<%= render :partial => 'users/name' %> +<%= render :partial => 'users/username' %> <%= render :partial => 'users/email' %> <% if @assignment.nil? %> <%= render :partial => 'users/password', :locals => { :new_user => new_user, :request_user => request_user } if edit%> diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index 56129fe0720..e93e84dd81a 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -2,7 +2,7 @@ <%= form_tag :action => 'update', :id => @user do %>


    - <%= collection_select 'user', 'role_id', @all_roles, :id, :name %>

    + <%= collection_select 'user', 'role_id', @all_roles, :id, :username %>

    <%= render :partial => 'user', :locals => { :request_user =>false, :edit => true} %> <%= submit_tag 'Edit' %> diff --git a/app/views/users/keys.html.erb b/app/views/users/keys.html.erb index 8669f9c842c..d4f8235bdb8 100644 --- a/app/views/users/keys.html.erb +++ b/app/views/users/keys.html.erb @@ -1,4 +1,4 @@ -

    User: <%=h @user.name(session[:ip]) %>

    +

    User: <%=h @user.username(session[:ip]) %>

    diff --git a/app/views/users/list.html.erb b/app/views/users/list.html.erb index 34925ecd67d..705f90762a6 100644 --- a/app/views/users/list.html.erb +++ b/app/views/users/list.html.erb @@ -2,7 +2,7 @@
    <%= form_tag :action => 'show_if_authorized' do %> - View user - enter exact login: <%= text_field_with_auto_complete :user, :name, {:size => 41} %> + View user - enter exact login: <%= text_field_with_auto_complete :user, :username, {:size => 41} %> <% end %> @@ -17,11 +17,11 @@
    - + <% @paginated_users.each do |user| %> - <% if (params[:show] != 'true' && !user.name(session[:ip]).include?("_hidden")) || params[:show] == 'true'%> + <% if (params[:show] != 'true' && !user.username(session[:ip]).include?("_hidden")) || params[:show] == 'true'%> - + diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb index 7ac4cf2d834..53ffdfa6212 100644 --- a/app/views/users/new.html.erb +++ b/app/views/users/new.html.erb @@ -2,7 +2,7 @@ <%= form_tag :action => 'create' do %>


    - <%= collection_select 'user', 'role_id', @all_roles, :id, :name, {:selected => @rolename.id} %>

    + <%= collection_select 'user', 'role_id', @all_roles, :id, :username, {:selected => @rolename.id} %>

    <%= render :partial => 'user', :locals => { :new_user => true , :request_user =>false , :edit => false} %> <%= submit_tag "Create" %> diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 4c5a301452d..9bb26b9b212 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -1,4 +1,4 @@ -

    User: <%=h @user.name(session[:ip]) %>

    +

    User: <%=h @user.username(session[:ip]) %>

    E-mail on ...
    NameFull NameEmail AddressRoleParentReviewSubmissionMeta-reviewDelete
    User NameFull NameEmail AddressRoleParentReviewSubmissionMeta-reviewDelete
    <%= link_to user.name(session[:ip]), impersonate_impersonate_path(:user => {:name => user.name(session[:ip])}), :method => :post %><%= link_to user.username(session[:ip]), impersonate_impersonate_path(:user => {:username => user.username(session[:ip])}), :method => :post %> <%= link_to user.fullname(session[:ip]), :controller=> 'users', :action => 'show', :id => user.id %> <%= user.email(session[:ip]) %> <%= link_to user.role.name, :controller => 'roles', :action => 'show', :id => user.role.id %>
    @@ -25,7 +25,7 @@ <% if @total_user_num > 1 %> <%= link_to 'Delete', {:action => 'destroy', :id => @user}, :confirm => "Do you want to delete this user?", :method => :delete if session[:user].can_impersonate? @user%> - <%= link_to 'rename', {:action => 'update', :name => @user},:method => :update, :id => 'rename', :style => 'color: #FFFFFF; margin-left: 80%;'%> + <%= link_to 'rename', {:action => 'update', :username => @user},:method => :update, :id => 'rename', :style => 'color: #FFFFFF; margin-left: 80%;'%> <% end %>

    diff --git a/app/views/versions/search.html.erb b/app/views/versions/search.html.erb index 3622aa0e6b6..77b64889f4f 100644 --- a/app/views/versions/search.html.erb +++ b/app/views/versions/search.html.erb @@ -9,9 +9,9 @@ diff --git a/config/deploy.rb b/config/deploy.rb index a06b650957a..c47a3a75c88 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -58,7 +58,7 @@ 'JAVA_HOME' => '/usr/jdk-11' # Default value for local_user is ENV['USER'] -# set :local_user, -> { `git config user.name`.chomp } +# set :local_user, -> { `git config user.username`.chomp } # Default value for keep_releases is 5 set :keep_releases, 10 diff --git a/danger b/danger new file mode 160000 index 00000000000..1ccfed23f80 --- /dev/null +++ b/danger @@ -0,0 +1 @@ +Subproject commit 1ccfed23f809a1e5c46e2533cfd7a3138f6cd821 diff --git a/db/data_migrations/scrub_database.rb b/db/data_migrations/scrub_database.rb index f7bd5e57737..12b3e1756a9 100644 --- a/db/data_migrations/scrub_database.rb +++ b/db/data_migrations/scrub_database.rb @@ -10,7 +10,7 @@ def self.run! fake_lastname = FakeNameGenerator.last_name num = rand(1..9) role = user.role.name.downcase.gsub(/[- ]/, '_') - user.name = role == 'student' ? "#{fake_name}_#{fake_lastname[0..3]}#{num}" : "#{role}_#{fake_name}__#{fake_lastname[0..3]}" + user.username = role == 'student' ? "#{fake_name}_#{fake_lastname[0..3]}#{num}" : "#{role}_#{fake_name}__#{fake_lastname[0..3]}" user.fullname = role == 'student' ? "#{fake_lastname}, #{fake_name}" : "#{fake_name}, #{role}" user.email = 'expertiza@mailinator.com' user.handle = 'handle' diff --git a/db/migrate/20241009142307_rename_name_and_fullname_in_users.rb b/db/migrate/20241009142307_rename_name_and_fullname_in_users.rb index bf3d88a36fc..8d22f973eb0 100644 --- a/db/migrate/20241009142307_rename_name_and_fullname_in_users.rb +++ b/db/migrate/20241009142307_rename_name_and_fullname_in_users.rb @@ -2,6 +2,6 @@ class RenameNameAndFullnameInUsers < ActiveRecord::Migration[5.1] def change # Renaming columns rename_column :users, :name, :username - rename_column :users, :fullname, :name + rename_column :account_requests, :name, :username end end \ No newline at end of file diff --git a/db/schema.rb b/db/schema.rb index 83a64cc8a04..7f2c00ba68a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -13,7 +13,7 @@ ActiveRecord::Schema.define(version: 20241009142307) do create_table "account_requests", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t| - t.string "name" + t.string "username" t.integer "role_id" t.string "fullname" t.string "institution_id" @@ -977,7 +977,7 @@ t.string "crypted_password", limit: 40, default: "", null: false t.integer "role_id", default: 0, null: false t.string "password_salt" - t.string "name" + t.string "fullname" t.string "email" t.integer "parent_id" t.boolean "private_by_default", default: false diff --git a/lib/scoring.rb b/lib/scoring.rb index e4eac5aa6c8..c0fc0f52a1d 100644 --- a/lib/scoring.rb +++ b/lib/scoring.rb @@ -86,7 +86,7 @@ def compute_total_score(assignment, scores) # Computes and returns the scores of assignment for participants and teams # Returns data in the format of # { - # :particpant => { + # :participant => { # : => participant_scores(participant, questions), # : => participant_scores(participant, questions) # }, @@ -126,7 +126,7 @@ def review_grades(assignment, questions) # Return scores that this participant has been given # Returns data in the format of # { - # :total_score => participant.grade ? particpant.grade : compute_total_score(assignment, scores) + # :total_score => participant.grade ? participant.grade : compute_total_score(assignment, scores) # :max_pts_available => topic.micropayment if assignment.topics? # :participant => participant, # :questionnaire_symbol1 => { diff --git a/spec/controllers/account_request_controller_spec.rb b/spec/controllers/account_request_controller_spec.rb index e640e95226b..5409d0d21a7 100644 --- a/spec/controllers/account_request_controller_spec.rb +++ b/spec/controllers/account_request_controller_spec.rb @@ -2,16 +2,16 @@ let(:admin) { build(:admin, id: 3) } let(:super_admin) { build(:superadmin) } let(:instructor) { build(:instructor, id: 2) } - let(:student1) { build(:student, id: 1, name: :lily) } + let(:student1) { build(:student, id: 1, username: :lily) } let(:student2) { build(:student) } let(:student3) { build(:student, id: 10, role_id: 1, parent_id: nil) } let(:student4) { build(:student, id: 20, role_id: 4) } let(:student5) { build(:student, role_id: 4, parent_id: 3) } - let(:student6) { build(:student, role_id: nil, name: :lilith) } + let(:student6) { build(:student, role_id: nil, username: :lilith) } let(:institution1) { build(:institution, id: 1) } let(:requested_user1) do - AccountRequest.new id: 4, name: 'requester1', role_id: 2, fullname: 're, requester1', + AccountRequest.new id: 4, username: 'requester1', role_id: 2, fullname: 're, requester1', institution_id: 1, email: 'requester1@test.com', status: nil, self_introduction: 'no one' end let(:superadmin) { build(:superadmin) } @@ -118,7 +118,7 @@ context '#create_requested_user_record' do request_params = { requested_user: { self_introduction: 'I am good' }, - user: { name: 'instructor6', + user: { username: 'instructor6', role_id: 2, fullname: '6, instructor', institution_id: 1, @@ -131,7 +131,7 @@ end it 'if user exists' do - allow(User).to receive(:find_by).with(name: 'instructor6').and_return(instructor) + allow(User).to receive(:find_by).with(username: 'instructor6').and_return(instructor) post :create_requested_user_record, params: request_params expect(flash[:error]).to eq 'The account you are requesting already exists in Expertiza.' diff --git a/spec/controllers/admin_controller_spec.rb b/spec/controllers/admin_controller_spec.rb index 1c5697a884a..2d05e764201 100644 --- a/spec/controllers/admin_controller_spec.rb +++ b/spec/controllers/admin_controller_spec.rb @@ -1,9 +1,9 @@ describe AdminController do - let(:admin1) { build(:admin, id: 3, role_id: 4, parent_id: 1, name: 'Administrator1') } - let(:admin2) { build(:admin, id: 4, role_id: 4, parent_id: 1, name: 'Administrator2') } + let(:admin1) { build(:admin, id: 3, role_id: 4, parent_id: 1, username: 'Administrator1') } + let(:admin2) { build(:admin, id: 4, role_id: 4, parent_id: 1, username: 'Administrator2') } let(:super_admin) { build(:superadmin, id: 1, role_id: 5) } - let(:instructor1) { build(:instructor, id: 10, role_id: 3, parent_id: 3, name: 'Instructor1') } - let(:instructor2) { build(:instructor, id: 11, role_id: 3, parent_id: 4, name: 'Instructor2') } + let(:instructor1) { build(:instructor, id: 10, role_id: 3, parent_id: 3, username: 'Instructor1') } + let(:instructor2) { build(:instructor, id: 11, role_id: 3, parent_id: 4, username: 'Instructor2') } let(:student1) { build(:student, id: 21, role_id: 1) } # create fake lists @@ -20,12 +20,12 @@ allow(User).to receive(:where).with(['role_id = ?', super_admin.role_id]).and_return([super_admin]) allow(User).to receive(:where).with(role_id: admin1.role).and_return(admin_list) - allow(admin_list).to receive(:order).with(:name).and_return(admin_list) + allow(admin_list).to receive(:order).with(:username).and_return(admin_list) allow(admin_list).to receive(:where).with('parent_id = ?', super_admin.id).and_return(admin_list) allow(admin_list).to receive(:paginate).with(page: '1', per_page: 50).and_return(admin_list) allow(User).to receive(:where).with(role_id: instructor1.role).and_return(instructor_list) - allow(instructor_list).to receive(:order).with(:name).and_return(instructor_list) + allow(instructor_list).to receive(:order).with(:username).and_return(instructor_list) allow(instructor_list).to receive(:where).with('parent_id = ?', admin1.id).and_return(instructor_list_pid3) allow(instructor_list_pid3).to receive(:paginate).with(page: '1', per_page: 50).and_return(instructor_list_pid3) end diff --git a/spec/controllers/advice_controller_spec.rb b/spec/controllers/advice_controller_spec.rb index 32c5c6f6a6b..a88430865a4 100644 --- a/spec/controllers/advice_controller_spec.rb +++ b/spec/controllers/advice_controller_spec.rb @@ -1,6 +1,6 @@ describe AdviceController do let(:super_admin) { build(:superadmin, id: 1, role_id: 5) } - let(:instructor1) { build(:instructor, id: 10, role_id: 3, parent_id: 3, name: 'Instructor1') } + let(:instructor1) { build(:instructor, id: 10, role_id: 3, parent_id: 3, username: 'Instructor1') } let(:student1) { build(:student, id: 21, role_id: 1) } describe '#action_allowed?' do diff --git a/spec/controllers/assessment360_controller_spec.rb b/spec/controllers/assessment360_controller_spec.rb index 740342df834..35a5995acdd 100644 --- a/spec/controllers/assessment360_controller_spec.rb +++ b/spec/controllers/assessment360_controller_spec.rb @@ -17,7 +17,7 @@ let(:assignment_list) { [assignment] } let(:due_date) { build(:assignment_due_date, deadline_type_id: 1) } let(:course_participant) { build(:course_participant, user_id: 1) } - let(:student1) { build(:student, id: 1, name: :lily) } + let(:student1) { build(:student, id: 1, username: :lily) } let(:assignment_with_participants) do build(:assignment, id: 1, diff --git a/spec/controllers/assignment_questionnaire_controller_spec.rb b/spec/controllers/assignment_questionnaire_controller_spec.rb index 074540ddb52..5c20bdc9d9d 100644 --- a/spec/controllers/assignment_questionnaire_controller_spec.rb +++ b/spec/controllers/assignment_questionnaire_controller_spec.rb @@ -1,6 +1,6 @@ describe AssignmentQuestionnaireController do let(:super_admin) { build(:superadmin, id: 1, role_id: 5) } - let(:instructor1) { build(:instructor, id: 10, role_id: 3, parent_id: 3, name: 'Instructor1') } + let(:instructor1) { build(:instructor, id: 10, role_id: 3, parent_id: 3, username: 'Instructor1') } let(:student1) { build(:student, id: 21, role_id: 1) } let(:assignment) { build(:assignment, id: 1) } @@ -51,7 +51,7 @@ course2 = create(:course) assignment2 = create(:assignment, course_id: course2.id, instructor_id: instructor1) ta1 = create(:teaching_assistant, id: 20) - ta2 = create(:teaching_assistant, id:40, name: 'test_ta_2') + ta2 = create(:teaching_assistant, id:40, username: 'test_ta_2') TaMapping.create(ta_id: ta1.id, course_id: course2.id) stub_current_user(ta2, ta2.role.name, ta2.role) diff --git a/spec/controllers/badges_controller_spec.rb b/spec/controllers/badges_controller_spec.rb index 001e8121054..e98e0072a60 100644 --- a/spec/controllers/badges_controller_spec.rb +++ b/spec/controllers/badges_controller_spec.rb @@ -1,7 +1,7 @@ describe BadgesController do let(:super_admin) { build(:superadmin, id: 1, role_id: 5) } let(:admin) { build(:admin, id: 3) } - let(:instructor1) { build(:instructor, id: 10, role_id: 3, parent_id: 3, name: 'Instructor1') } + let(:instructor1) { build(:instructor, id: 10, role_id: 3, parent_id: 3, username: 'Instructor1') } let(:student1) { build(:student, id: 21, role_id: 1) } let(:ta) { build(:teaching_assistant, id: 6) } let(:badge) {build(:badge, id:1, name: 'test', description: 'test desc', image_name: 'test.png')} diff --git a/spec/controllers/conference_controller_spec.rb b/spec/controllers/conference_controller_spec.rb index 475809e0b4f..b334258c6a0 100644 --- a/spec/controllers/conference_controller_spec.rb +++ b/spec/controllers/conference_controller_spec.rb @@ -3,8 +3,8 @@ let(:super_admin) { build(:superadmin) } let(:instructor) { build(:instructor, id: 2) } let(:instructor1) { build(:instructor, id: 2, timezonepref: 'Eastern Time (US & Canada)') } - let(:student1) { build(:student, id: 1, name: :lily) } - let(:student1) { build(:student, id: 2, name: :lily23) } + let(:student1) { build(:student, id: 1, username: :lily) } + let(:student1) { build(:student, id: 2, username: :lily23) } let(:student2) { build(:student) } let(:student3) { build(:student, id: 10, role_id: 1, parent_id: nil) } let(:student4) { build(:student, id: 20, role_id: 4) } @@ -14,7 +14,7 @@ let(:institution1) { build(:institution, id: 1) } let(:assignment1) { build(:assignment, id: 2, is_conference_assignment: 1, max_team_size: 100) } let(:requested_user1) do - AccountRequest.new id: 4, name: 'requester1', role_id: 2, fullname: 're, requester1', + AccountRequest.new id: 4, username: 'requester1', role_id: 2, fullname: 're, requester1', institution_id: 1, email: 'requester1@test.com', status: nil, self_introduction: 'no one' end let(:superadmin) { build(:superadmin) } @@ -46,7 +46,7 @@ it 'save successfully for new Author' do request_params = { - user: { name: 'lily', + user: { username: 'lily', role_id: 2, email: 'chenzy@gmail.com', fullname: 'John Bumgardner', @@ -62,10 +62,10 @@ it 'save successfully for existing user as Author' do request_params = { - user: { name: 'lily', + user: { username: 'lily', assignment: '2' } } - allow(User).to receive(:find_by).with(name: 'lily').and_return(student1) + allow(User).to receive(:find_by).with(username: 'lily').and_return(student1) allow(Assignment).to receive(:find_by_id).with('2').and_return(assignment1) allow(Assignment).to receive(:find).with('2').and_return(assignment1) allow(AssignmentParticipant).to receive(:create).with(any_args).and_return(participant) @@ -75,7 +75,7 @@ end it 'return error if user email already exist' do request_params = { - user: { name: 'lily', + user: { username: 'lily', role_id: 2, email: 'chenzy@gmail.com', fullname: 'John Bumgardner', @@ -88,7 +88,7 @@ post :create, params: request_params request_params2 = { - user: { name: 'lily23', + user: { username: 'lily23', role_id: 2, email: 'chenzy@gmail.com', fullname: 'John Bumgardner', @@ -106,7 +106,7 @@ it 'should redirect to root with correct recaptcha' do user_session = { user: student1 } request_params = { - user: { name: 'lily', + user: { username: 'lily', crypted_password: 'password', role_id: 1, password_salt: 1, @@ -136,7 +136,7 @@ it 'should redirect to join conference page with incorrect recaptcha' do user_session = { user: student2 } request_params = { - user: { name: 'lily2', + user: { username: 'lily2', crypted_password: 'password', role_id: 1, password_salt: 1, diff --git a/spec/controllers/courses_controller_spec.rb b/spec/controllers/courses_controller_spec.rb index 26d74c1c098..9779c509486 100644 --- a/spec/controllers/courses_controller_spec.rb +++ b/spec/controllers/courses_controller_spec.rb @@ -155,7 +155,7 @@ allow(Role).to receive(:find_by_name).with('Teaching Assistant').and_return(true) allow(user).to receive(:save).and_return(true) - params = { course_id: 1, user: { name: 'Teaching Assistant' } } + params = { course_id: 1, user: { username: 'Teaching Assistant' } } post :add_ta, params: params expect(response).to be_redirect end diff --git a/spec/controllers/grades_controller_spec.rb b/spec/controllers/grades_controller_spec.rb index 6f494201777..a7fd36cde8a 100644 --- a/spec/controllers/grades_controller_spec.rb +++ b/spec/controllers/grades_controller_spec.rb @@ -215,7 +215,7 @@ } allow(participant).to receive(:update_attribute).with(any_args).and_return(participant) post :update, params: request_params - expect(flash[:note]).to eq("The computed score will be used for #{participant.user.name}.") + expect(flash[:note]).to eq("The computed score will be used for #{participant.user.username}.") expect(response).to redirect_to('/grades/1/edit') end end @@ -231,7 +231,7 @@ } allow(participant).to receive(:update_attribute).with(any_args).and_return(participant) post :update, params: request_params - expect(flash[:note]).to eq("The computed score will be used for #{participant.user.name}.") + expect(flash[:note]).to eq("The computed score will be used for #{participant.user.username}.") expect(response).to redirect_to('/grades/1/edit') end end diff --git a/spec/controllers/impersonate_controller_spec.rb b/spec/controllers/impersonate_controller_spec.rb index cdd57a4a83a..afef4a46d7f 100644 --- a/spec/controllers/impersonate_controller_spec.rb +++ b/spec/controllers/impersonate_controller_spec.rb @@ -1,11 +1,11 @@ describe ImpersonateController do let(:instructor) { build(:instructor, id: 2) } - let(:student1) { build(:student, id: 30, name: :Amanda) } - let(:student2) { build(:student, id: 40, name: :Brian) } - let(:admin) { build(:admin, id: 3, name: :Admin) } - let(:super_admin) { build(:superadmin, id: 5, name: :Superadmin) } + let(:student1) { build(:student, id: 30, username: :Amanda) } + let(:student2) { build(:student, id: 40, username: :Brian) } + let(:admin) { build(:admin, id: 3, username: :Admin) } + let(:super_admin) { build(:superadmin, id: 5, username: :Superadmin) } - let(:teaching_assistant) { build(:teaching_assistant, id: 6, name: :Teaching_Assistant) } + let(:teaching_assistant) { build(:teaching_assistant, id: 6, username: :Teaching_Assistant) } # impersonate is mostly used by instructors # run all tests using instructor account # except some exceptions where we'll use other accounts @@ -16,7 +16,7 @@ context '#impersonate' do it 'when input is blank' do request.env['HTTP_REFERER'] = 'http://www.example.com' - @params = { user: { name: '' } } + @params = { user: { username: '' } } get :impersonate, params: @params expect(response).to redirect_to('http://www.example.com') end @@ -31,18 +31,18 @@ end it 'redirects to back' do - allow(User).to receive(:find_by).with(name: student1.name).and_return(student1) + allow(User).to receive(:find_by).with(username: student1.username).and_return(student1) request.env['HTTP_REFERER'] = 'http://www.example.com' - @params = { user: { name: student1.name } } + @params = { user: { username: student1.username } } get :impersonate, params: @params expect(response).to redirect_to('http://www.example.com') end it 'instructor should be able to impersonate a user with their real name' do - allow(User).to receive(:find_by).with(name: student1.name).and_return(student1) + allow(User).to receive(:find_by).with(username: student1.username).and_return(student1) allow(instructor).to receive(:can_impersonate?).with(student1).and_return(true) request.env['HTTP_REFERER'] = 'http://www.example.com' - @params = { user: { name: student1.name } } + @params = { user: { username: student1.username } } @session = { user: instructor } post :impersonate, params: @params, session: @session expect(session[:super_user]).to eq instructor @@ -52,30 +52,30 @@ end it 'instructor should not be able to impersonate a super admin user with their real name' do - allow(User).to receive(:find_by).with(name: super_admin.name).and_return(super_admin) + allow(User).to receive(:find_by).with(username: super_admin.username).and_return(super_admin) allow(instructor).to receive(:can_impersonate?).with(super_admin).and_return(false) request.env['HTTP_REFERER'] = 'http://www.example.com' - @params = { user: { name: super_admin.name } } + @params = { user: { username: super_admin.username } } @session = { user: instructor } post :impersonate, params: @params, session: @session expect(session[:impersonate]).to be nil end it 'instructor should not be able to impersonate an admin user with their real name' do - allow(User).to receive(:find_by).with(name: admin.name).and_return(admin) + allow(User).to receive(:find_by).with(username: admin.username).and_return(admin) allow(instructor).to receive(:can_impersonate?).with(admin).and_return(false) request.env['HTTP_REFERER'] = 'http://www.example.com' - @params = { user: { name: admin.name } } + @params = { user: { username: admin.username } } @session = { user: instructor } post :impersonate, params: @params, session: @session expect(session[:impersonate]).to be nil end it 'instructor should be able to impersonate a teaching assistant user with their real name' do - allow(User).to receive(:find_by).with(name: teaching_assistant.name).and_return(teaching_assistant) + allow(User).to receive(:find_by).with(username: teaching_assistant.username).and_return(teaching_assistant) allow(instructor).to receive(:can_impersonate?).with(teaching_assistant).and_return(true) request.env['HTTP_REFERER'] = 'http://www.example.com' - @params = { user: { name: teaching_assistant.name } } + @params = { user: { username: teaching_assistant.username } } @session = { user: instructor } post :impersonate, params: @params, session: @session expect(session[:super_user]).to eq instructor @@ -86,10 +86,10 @@ it 'teaching assistant should be able to impersonate a student with their real name' do stub_current_user(teaching_assistant, teaching_assistant.role.name, teaching_assistant.role) - allow(User).to receive(:find_by).with(name: student1.name).and_return(student1) + allow(User).to receive(:find_by).with(username: student1.username).and_return(student1) allow(teaching_assistant).to receive(:can_impersonate?).with(student1).and_return(true) request.env['HTTP_REFERER'] = 'http://www.example.com' - @params = { user: { name: student1.name } } + @params = { user: { username: student1.username } } @session = { user: teaching_assistant } post :impersonate, params: @params, session: @session expect(session[:super_user]).to eq teaching_assistant @@ -100,10 +100,10 @@ it 'teaching assistant should not be able to impersonate an instructor with their real name' do stub_current_user(teaching_assistant, teaching_assistant.role.name, teaching_assistant.role) - allow(User).to receive(:find_by).with(name: instructor.name).and_return(instructor) + allow(User).to receive(:find_by).with(username: instructor.username).and_return(instructor) allow(teaching_assistant).to receive(:can_impersonate?).with(instructor).and_return(false) request.env['HTTP_REFERER'] = 'http://www.example.com' - @params = { user: { name: instructor.name } } + @params = { user: { username: instructor.username } } @session = { user: teaching_assistant } post :impersonate, params: @params, session: @session expect(session[:impersonate]).to be nil @@ -111,10 +111,10 @@ it 'teaching assistant should not be able to impersonate an admin with their real name' do stub_current_user(teaching_assistant, teaching_assistant.role.name, teaching_assistant.role) - allow(User).to receive(:find_by).with(name: admin.name).and_return(admin) + allow(User).to receive(:find_by).with(username: admin.username).and_return(admin) allow(teaching_assistant).to receive(:can_impersonate?).with(admin).and_return(false) request.env['HTTP_REFERER'] = 'http://www.example.com' - @params = { user: { name: admin.name } } + @params = { user: { username: admin.username } } @session = { user: teaching_assistant } post :impersonate, params: @params, session: @session expect(session[:impersonate]).to be nil @@ -122,10 +122,10 @@ it 'teaching assistant should not be able to impersonate an super admin with their real name' do stub_current_user(teaching_assistant, teaching_assistant.role.name, teaching_assistant.role) - allow(User).to receive(:find_by).with(name: super_admin.name).and_return(super_admin) + allow(User).to receive(:find_by).with(username: super_admin.username).and_return(super_admin) allow(teaching_assistant).to receive(:can_impersonate?).with(super_admin).and_return(false) request.env['HTTP_REFERER'] = 'http://www.example.com' - @params = { user: { name: super_admin.name } } + @params = { user: { username: super_admin.username } } @session = { user: teaching_assistant } post :impersonate, params: @params, session: @session expect(session[:impersonate]).to be nil @@ -133,10 +133,10 @@ it 'admin should be able to impersonate a student with their real name' do stub_current_user(admin, admin.role.name, admin.role) - allow(User).to receive(:find_by).with(name: student1.name).and_return(student1) + allow(User).to receive(:find_by).with(username: student1.username).and_return(student1) allow(admin).to receive(:can_impersonate?).with(student1).and_return(true) request.env['HTTP_REFERER'] = 'http://www.example.com' - @params = { user: { name: student1.name } } + @params = { user: { username: student1.username } } @session = { user: admin } post :impersonate, params: @params, session: @session expect(session[:super_user]).to eq admin @@ -147,10 +147,10 @@ it 'admin should be able to impersonate a teaching assistant with their real name' do stub_current_user(admin, admin.role.name, admin.role) - allow(User).to receive(:find_by).with(name: teaching_assistant.name).and_return(teaching_assistant) + allow(User).to receive(:find_by).with(username: teaching_assistant.username).and_return(teaching_assistant) allow(admin).to receive(:can_impersonate?).with(teaching_assistant).and_return(true) request.env['HTTP_REFERER'] = 'http://www.example.com' - @params = { user: { name: teaching_assistant.name } } + @params = { user: { username: teaching_assistant.username } } @session = { user: admin } post :impersonate, params: @params, session: @session expect(session[:super_user]).to eq admin @@ -161,10 +161,10 @@ it 'admin should be able to impersonate an instructor with their real name' do stub_current_user(admin, admin.role.name, admin.role) - allow(User).to receive(:find_by).with(name: instructor.name).and_return(instructor) + allow(User).to receive(:find_by).with(username: instructor.username).and_return(instructor) allow(admin).to receive(:can_impersonate?).with(instructor).and_return(true) request.env['HTTP_REFERER'] = 'http://www.example.com' - @params = { user: { name: instructor.name } } + @params = { user: { username: instructor.username } } @session = { user: admin } post :impersonate, params: @params, session: @session expect(session[:super_user]).to eq admin @@ -175,10 +175,10 @@ it 'admin should not be able to impersonate a super admin with their real name' do stub_current_user(admin, admin.role.name, admin.role) - allow(User).to receive(:find_by).with(name: super_admin.name).and_return(super_admin) + allow(User).to receive(:find_by).with(username: super_admin.username).and_return(super_admin) allow(admin).to receive(:can_impersonate?).with(super_admin).and_return(false) request.env['HTTP_REFERER'] = 'http://www.example.com' - @params = { user: { name: super_admin.name } } + @params = { user: { username: super_admin.username } } @session = { user: admin } post :impersonate, params: @params, session: @session expect(session[:impersonate]).to be nil @@ -186,10 +186,10 @@ it 'super admin should be able to impersonate a student with their real name' do stub_current_user(super_admin, super_admin.role.name, super_admin.role) - allow(User).to receive(:find_by).with(name: student1.name).and_return(student1) + allow(User).to receive(:find_by).with(username: student1.username).and_return(student1) allow(super_admin).to receive(:can_impersonate?).with(student1).and_return(true) request.env['HTTP_REFERER'] = 'http://www.example.com' - @params = { user: { name: student1.name } } + @params = { user: { username: student1.username } } @session = { user: super_admin } post :impersonate, params: @params, session: @session expect(session[:super_user]).to eq super_admin @@ -200,10 +200,10 @@ it 'super admin should be able to impersonate a teaching assistant with their real name' do stub_current_user(super_admin, super_admin.role.name, super_admin.role) - allow(User).to receive(:find_by).with(name: teaching_assistant.name).and_return(teaching_assistant) + allow(User).to receive(:find_by).with(username: teaching_assistant.username).and_return(teaching_assistant) allow(super_admin).to receive(:can_impersonate?).with(teaching_assistant).and_return(true) request.env['HTTP_REFERER'] = 'http://www.example.com' - @params = { user: { name: teaching_assistant.name } } + @params = { user: { username: teaching_assistant.username } } @session = { user: super_admin } post :impersonate, params: @params, session: @session expect(session[:super_user]).to eq super_admin @@ -214,10 +214,10 @@ it 'super admin should be able to impersonate an instructor with their real name' do stub_current_user(super_admin, super_admin.role.name, super_admin.role) - allow(User).to receive(:find_by).with(name: instructor.name).and_return(instructor) + allow(User).to receive(:find_by).with(username: instructor.username).and_return(instructor) allow(super_admin).to receive(:can_impersonate?).with(instructor).and_return(true) request.env['HTTP_REFERER'] = 'http://www.example.com' - @params = { user: { name: instructor.name } } + @params = { user: { username: instructor.username } } @session = { user: super_admin } post :impersonate, params: @params, session: @session expect(session[:super_user]).to eq super_admin @@ -228,10 +228,10 @@ it 'super admin should be able to impersonate an admin with their real name' do stub_current_user(super_admin, super_admin.role.name, super_admin.role) - allow(User).to receive(:find_by).with(name: admin.name).and_return(admin) + allow(User).to receive(:find_by).with(username: admin.username).and_return(admin) allow(super_admin).to receive(:can_impersonate?).with(admin).and_return(true) request.env['HTTP_REFERER'] = 'http://www.example.com' - @params = { user: { name: admin.name } } + @params = { user: { username: admin.username } } @session = { user: super_admin } post :impersonate, params: @params, session: @session expect(session[:super_user]).to eq super_admin @@ -241,22 +241,22 @@ end it 'instructor redirects to student home page after impersonating a student' do - allow(User).to receive(:find_by).with(name: student1.name).and_return(student1) + allow(User).to receive(:find_by).with(username: student1.username).and_return(student1) allow(instructor).to receive(:can_impersonate?).with(student1).and_return(true) request.env['HTTP_REFERER'] = 'http://www.example.com' - @params = { user: { name: student1.name } } + @params = { user: { username: student1.username } } @session = { user: instructor } post :impersonate, params: @params, session: @session expect(response).to redirect_to('/tree_display/drill') end it 'instructor should be able to impersonate a user with their anonymized name' do - allow(User).to receive(:find_by).with(name: student1.name).and_return(student1) + allow(User).to receive(:find_by).with(username: student1.username).and_return(student1) allow(instructor).to receive(:can_impersonate?).with(student1).and_return(true) allow(User).to receive(:anonymized_view?).and_return(true) - allow(User).to receive(:real_user_from_anonymized_name).with('Student30').and_return(student1) + allow(User).to receive(:real_user_from_anonymized_username).with('Student30').and_return(student1) request.env['HTTP_REFERER'] = 'http://www.example.com' - @params = { user: { name: 'Student30' } } + @params = { user: { username: 'Student30' } } @session = { user: instructor } post :impersonate, params: @params, session: @session expect(session[:super_user]).to eq instructor @@ -266,15 +266,15 @@ end it 'instructor should be able to impersonate a user while already impersonating a user' do - allow(User).to receive(:find_by).with(name: student1.name).and_return(student1) - allow(User).to receive(:find_by).with(name: student2.name).and_return(student2) + allow(User).to receive(:find_by).with(username: student1.username).and_return(student1) + allow(User).to receive(:find_by).with(username: student2.username).and_return(student2) allow(instructor).to receive(:can_impersonate?).with(student1).and_return(true) allow(instructor).to receive(:can_impersonate?).with(student2).and_return(true) request.env['HTTP_REFERER'] = 'http://www.example.com' - @params = { user: { name: student1.name } } + @params = { user: { username: student1.username } } @session = { user: instructor } post :impersonate, params: @params, session: @session - @params = { user: { name: student2.name } } + @params = { user: { username: student2.username } } post :impersonate, params: @params, session: @session expect(session[:super_user]).to eq instructor expect(session[:user]).to eq student2 @@ -283,16 +283,16 @@ end it 'instructor should be able to impersonate a user while already impersonating a user but from nav bar' do - allow(User).to receive(:find_by).with(name: student1.name).and_return(student1) - allow(User).to receive(:find_by).with(name: student2.name).and_return(student2) + allow(User).to receive(:find_by).with(username: student1.username).and_return(student1) + allow(User).to receive(:find_by).with(username: student2.username).and_return(student2) allow(instructor).to receive(:can_impersonate?).with(student1).and_return(true) allow(instructor).to receive(:can_impersonate?).with(student2).and_return(true) request.env['HTTP_REFERER'] = 'http://www.example.com' - @params = { user: { name: student1.name } } + @params = { user: { username: student1.username } } @session = { user: instructor } post :impersonate, params: @params, session: @session # nav bar uses the :impersonate as the param name, so let make sure it always works from there too. - @params = { impersonate: { name: student2.name } } + @params = { impersonate: { username: student2.username } } post :impersonate, params: @params, session: @session expect(session[:super_user]).to eq instructor expect(session[:user]).to eq student2 diff --git a/spec/controllers/invitations_controller_spec.rb b/spec/controllers/invitations_controller_spec.rb index 4cf1e007778..8e4ea76bb59 100644 --- a/spec/controllers/invitations_controller_spec.rb +++ b/spec/controllers/invitations_controller_spec.rb @@ -43,11 +43,11 @@ describe '#check_user_before_invitation' do it 'invitation added for existing user' do - allow(User).to receive(:find_by).with(name: 'student@gmail.com').and_return(student) + allow(User).to receive(:find_by).with(username: 'student@gmail.com').and_return(student) allow(AssignmentParticipant).to receive(:find).with('1').and_return(participant) allow(Assignment).to receive(:find).with(1).and_return(assignment) request_params = { - user: { name: 'student@gmail.com', email: 'student@gmail.com' }, + user: { username: 'student@gmail.com', email: 'student@gmail.com' }, student_id: 1 } user_session = { user: student } @@ -58,7 +58,7 @@ it 'invitation added for new user who does not have an expertiza account yet and sends an invitation' do allow(User).to receive(:skip_callback).with(:create, :after, :email_welcome).and_return(true) request_params = { - user: { name: 'testuser@gmail.com', + user: { username: 'testuser@gmail.com', fullname: 'John Bumgardner', parent_id: 1, institution_id: 1 }, @@ -76,7 +76,7 @@ it 'invitation not added for new user if entered email has incorrect format' do allow(User).to receive(:skip_callback).with(:create, :after, :email_welcome).and_return(true) request_params = { - user: { name: 'testuser', + user: { username: 'testuser', parent_id: 1, institution_id: 1 }, student_id: 1, @@ -92,7 +92,7 @@ it 'invitation and user not added for new user with normal assignment' do request_params = { - user: { name: 'testuser@gmail.com', + user: { username: 'testuser@gmail.com', email: 'testuser@gmail.com' }, student_id: 1, team_id: 1 @@ -103,7 +103,7 @@ allow(Team).to receive(:find).with('1').and_return(team) user_session = { user: student1 } expect { post :create, params: request_params, session: user_session }.to change(Invitation, :count).by(0).and change(User, :count).by(0) - expect(flash[:error]).to eq 'The user "testuser@gmail.com" does not exist. Please make sure the name entered is correct.' + expect(flash[:error]).to eq 'The user "testuser@gmail.com" does not exist. Please make sure the username entered is correct.' end end describe '#create' do diff --git a/spec/controllers/lock_controller_spec.rb b/spec/controllers/lock_controller_spec.rb index 280f59f9898..931686a734b 100644 --- a/spec/controllers/lock_controller_spec.rb +++ b/spec/controllers/lock_controller_spec.rb @@ -1,6 +1,6 @@ describe LockController do let(:super_admin) { build(:superadmin, id: 1, role_id: 5) } - let(:instructor1) { build(:instructor, id: 10, role_id: 3, parent_id: 3, name: 'Instructor1') } + let(:instructor1) { build(:instructor, id: 10, role_id: 3, parent_id: 3, username: 'Instructor1') } let(:student1) { build(:student, id: 21, role_id: 1) } let(:lock1) { build(:lock, id: 1, user: instructor1, lockable_type: 'test lockable') } diff --git a/spec/controllers/lottery_controller_spec.rb b/spec/controllers/lottery_controller_spec.rb index 10e6f705f4b..4936a5b8fe3 100644 --- a/spec/controllers/lottery_controller_spec.rb +++ b/spec/controllers/lottery_controller_spec.rb @@ -2,12 +2,12 @@ let(:assignment) { create(:assignment, is_intelligent: true, name: 'assignment', directory_path: 'assignment') } let(:assignment_2) { create(:assignment, is_intelligent: false, name: 'assignment_2', directory_path: 'assignment_2') } - let(:student1) { create(:student, name: 'student1') } - let(:student2) { create(:student, name: 'student2') } - let(:student3) { create(:student, name: 'student3') } - let(:student4) { create(:student, name: 'student4') } - let(:student5) { create(:student, name: 'student5') } - let(:student6) { create(:student, name: 'student6') } + let(:student1) { create(:student, username: 'student1') } + let(:student2) { create(:student, username: 'student2') } + let(:student3) { create(:student, username: 'student3') } + let(:student4) { create(:student, username: 'student4') } + let(:student5) { create(:student, username: 'student5') } + let(:student6) { create(:student, username: 'student6') } let(:topic1) { create(:topic, assignment_id: assignment.id) } let(:topic2) { create(:topic, assignment_id: assignment.id) } diff --git a/spec/controllers/lti_controller_spec.rb b/spec/controllers/lti_controller_spec.rb index 44bbcf988de..22a9cfdc92f 100644 --- a/spec/controllers/lti_controller_spec.rb +++ b/spec/controllers/lti_controller_spec.rb @@ -16,7 +16,7 @@ 'other_param' => 'value' } end - let(:user) { User.create(name: 'testuser', email: 'testuser@ncsu.edu') } + let(:user) { User.create(username: 'testuser', email: 'testuser@ncsu.edu') } let(:shared_secret) { 'shared_secret' } before do @@ -140,10 +140,10 @@ describe '#authenticate_and_login_user' do context 'when user exists' do - let(:user) { User.create(name: 'testuser', email: 'testuser@ncsu.edu') } + let(:user) { User.create(username: 'testuser', email: 'testuser@ncsu.edu') } before do - allow(User).to receive(:find_by).with(name: 'testuser').and_return(user) + allow(User).to receive(:find_by).with(username: 'testuser').and_return(user) allow(controller).to receive(:redirect_to) allow(controller).to receive(:session).and_return({}) allow(AuthController).to receive(:set_current_role) @@ -159,7 +159,7 @@ context 'when user does not exist' do before do - allow(User).to receive(:find_by).with(name: 'testuser').and_return(nil) + allow(User).to receive(:find_by).with(username: 'testuser').and_return(nil) allow(controller).to receive(:redirect_to) end @@ -171,7 +171,7 @@ context 'when an error occurs' do before do - allow(User).to receive(:find_by).with(name: 'testuser').and_raise(StandardError.new('Test error')) + allow(User).to receive(:find_by).with(username: 'testuser').and_raise(StandardError.new('Test error')) allow(controller).to receive(:redirect_to) allow(Rails.logger).to receive(:error) end diff --git a/spec/controllers/pair_programming_controller_spec.rb b/spec/controllers/pair_programming_controller_spec.rb index a9edcb4305b..18ebbc97bf6 100644 --- a/spec/controllers/pair_programming_controller_spec.rb +++ b/spec/controllers/pair_programming_controller_spec.rb @@ -1,7 +1,7 @@ describe PairProgrammingController do let(:super_admin) { build(:superadmin, id: 1, role_id: 5) } let(:admin) { build(:admin, id: 3) } - let(:instructor1) { build(:instructor, id: 10, role_id: 3, parent_id: 3, name: 'Instructor1') } + let(:instructor1) { build(:instructor, id: 10, role_id: 3, parent_id: 3, username: 'Instructor1') } let(:student1) { build(:student, id: 21, role_id: 1) } let(:student2) { build(:student, id: 22, role_id: 1) } let(:ta) { build(:teaching_assistant, id: 6) } diff --git a/spec/controllers/participants_controller_spec.rb b/spec/controllers/participants_controller_spec.rb index a37f5211621..c48f9fa3cc0 100644 --- a/spec/controllers/participants_controller_spec.rb +++ b/spec/controllers/participants_controller_spec.rb @@ -1,7 +1,7 @@ describe ParticipantsController do let(:instructor) { build(:instructor, id: 6) } let(:student) { build(:student) } - let(:student1) { build_stubbed(:student, id: 1, name: 'student') } + let(:student1) { build_stubbed(:student, id: 1, username: 'student') } let(:course_participant) { build(:course_participant) } let(:participant) { build(:participant) } let(:assignment_node) { build(:assignment_node) } @@ -108,15 +108,15 @@ describe '#add' do it 'adds a participant' do allow(Assignment).to receive(:find).with('1').and_return(assignment) - allow(User).to receive(:find_by).with(name: student.name).and_return(student) - request_params = { model: 'Assignment', authorization: 'participant', id: 1, user: { name: student.name } } + allow(User).to receive(:find_by).with(username: student.username).and_return(student) + request_params = { model: 'Assignment', authorization: 'participant', id: 1, user: { username: student.username } } user_session = { user: instructor } get :add, params: request_params, session: user_session, xhr: true expect(response).to render_template('add.js.erb') end it 'does not add a participant for a non-existing user' do allow(Assignment).to receive(:find).with('1').and_return(assignment) - request_params = { model: 'Assignment', authorization: 'participant', id: 1, user: { name: 'Aaa' } } + request_params = { model: 'Assignment', authorization: 'participant', id: 1, user: { username: 'Aaa' } } user_session = { user: instructor } get :add, params: request_params, session: user_session, xhr: true expect(flash[:error]).to eq 'The user Aaa does not exist or has already been added.' @@ -235,10 +235,10 @@ allow(assignment).to receive(:participants).and_return([participant]) allow(participant).to receive(:permission_granted?).and_return(true) allow(participant).to receive(:user).and_return(student) - allow(student).to receive(:name).and_return('name') + allow(student).to receive(:username).and_return('name') allow(student).to receive(:fullname).and_return('fullname') pc = ParticipantsController.new - expect(pc.send(:get_user_info, student, assignment)).to eq(name: 'name', fullname: 'fullname', pub_rights: 'Granted', verified: false) + expect(pc.send(:get_user_info, student, assignment)).to eq(username: 'name', fullname: 'fullname', pub_rights: 'Granted', verified: false) end end diff --git a/spec/controllers/password_retrieval_controller_spec.rb b/spec/controllers/password_retrieval_controller_spec.rb index dec9aded183..ba9fdd5bea1 100644 --- a/spec/controllers/password_retrieval_controller_spec.rb +++ b/spec/controllers/password_retrieval_controller_spec.rb @@ -4,7 +4,7 @@ @user = User.new @user.email = 'example@example.edu' @user.fullname = 'John Bumgardner' - @user.name = 'ex' + @user.username = 'exe' @user.save! request_params = { user: { email: 'example@example.edu' } } post :send_password, params: request_params @@ -14,7 +14,7 @@ @user = User.new @user.email = 'example@example.edu' @user.fullname = 'John Bumgardner' - @user.name = 'Shubham' + @user.username = 'Shubham' @user.save! @password_retrival = PasswordReset.new @local_token = 'some random string' @@ -28,7 +28,7 @@ it 'if no user no entry is created' do @user = User.new @user.email = 'aexample@example.edu' - @user.name = 'Shubham' + @user.username = 'Shubham' @user.fullname = 'John Bumgardner' @user.save! request_params = { user: { email: 'example@example.edu' } } diff --git a/spec/controllers/popup_controller_spec.rb b/spec/controllers/popup_controller_spec.rb index f9f472e1e99..a97f34b2153 100644 --- a/spec/controllers/popup_controller_spec.rb +++ b/spec/controllers/popup_controller_spec.rb @@ -8,8 +8,8 @@ let(:instructor) { build_stubbed(:instructor, id: 6) } let(:team) { build_stubbed(:assignment_team, id: 1, name: 'team1', assignment: assignment) } - let(:student) { build_stubbed(:student, id: 1, name: 'student') } - let(:student2) { build_stubbed(:student, id: 2, name: 'student2') } + let(:student) { build_stubbed(:student, id: 1, username: 'student') } + let(:student2) { build_stubbed(:student, id: 2, username: 'student2') } let(:participant) { build_stubbed(:participant, id: 1, user_id: 1, user: student, assignment: assignment) } let(:participant2) { build_stubbed(:participant, id: 2, user: student2, assignment: assignment) } let(:response) { build_stubbed(:response, id: 1) } @@ -123,7 +123,7 @@ describe '#reviewer_details_popup' do it 'render reviewer_details_popup page successfully' do participant = double(:participant, user_id: 1) - user = double(:user, fullname: 'Test User', name: 'Test', email: 'test@gmail.com', handle: 1) + user = double(:user, fullname: 'Test User', username: 'Test', email: 'test@gmail.com', handle: 1) allow(Participant).to receive(:find).with('1').and_return(participant) allow(User).to receive(:find).with(participant.user_id).and_return(user) request_params = { id: 1, assignment_id: 1 } @@ -131,7 +131,7 @@ get :reviewer_details_popup, params: request_params, session: user_session expect(@response).to have_http_status(200) expect(user.fullname).to eq('Test User') - expect(user.name).to eq('Test') + expect(user.username).to eq('Test') expect(user.email).to eq('test@gmail.com') expect(user.handle).to eq(1) end diff --git a/spec/controllers/profile_controller_spec.rb b/spec/controllers/profile_controller_spec.rb index 3e4dd1ca7cf..799f85265f5 100644 --- a/spec/controllers/profile_controller_spec.rb +++ b/spec/controllers/profile_controller_spec.rb @@ -3,7 +3,7 @@ describe ProfileController do # initialize objects using factories.rb required for stubbing in test cases let(:super_admin) { build(:superadmin, id: 1) } - let(:instructor1) { build(:instructor, id: 10, name: 'Instructor1') } + let(:instructor1) { build(:instructor, id: 10, username: 'Instructor1') } let(:questionnaire) { build(:questionnaire, id: 666) } let(:assignment_questionnaire) { build(:assignment_questionnaire, id: 1, questionnaire: questionnaire) } diff --git a/spec/controllers/publishing_controller_spec.rb b/spec/controllers/publishing_controller_spec.rb index 13a96d74835..90963d27dd2 100644 --- a/spec/controllers/publishing_controller_spec.rb +++ b/spec/controllers/publishing_controller_spec.rb @@ -1,7 +1,7 @@ describe PublishingController do let(:super_admin) { build(:superadmin, id: 1, role_id: 5) } let(:admin) { build(:admin, id: 3) } - let(:instructor1) { build(:instructor, id: 10, role_id: 3, parent_id: 3, name: 'Instructor1') } + let(:instructor1) { build(:instructor, id: 10, role_id: 3, parent_id: 3, username: 'Instructor1') } let(:student1) { build(:student, id: 21, role_id: 1) } let(:ta) { build(:teaching_assistant, id: 6) } let(:participant) {build(:participant, id: 1)} diff --git a/spec/controllers/questionnaires_controller_spec.rb b/spec/controllers/questionnaires_controller_spec.rb index 76199c48cd3..fbcaafee8f6 100644 --- a/spec/controllers/questionnaires_controller_spec.rb +++ b/spec/controllers/questionnaires_controller_spec.rb @@ -72,8 +72,8 @@ def check_access(username) # Otherwise the TA will be indirectly associated with the questionnaire teaching_assistant = create(:teaching_assistant) stub_current_user(teaching_assistant, teaching_assistant.role.name, teaching_assistant.role) - instructor1 = create(:instructor, name: 'test_instructor1') - instructor2 = create(:instructor, name: 'test_instructor2') + instructor1 = create(:instructor, username: 'test_instructor1') + instructor2 = create(:instructor, username: 'test_instructor2') course = create(:course, instructor_id: instructor2.id) TaMapping.create(ta_id: teaching_assistant.id, course_id: course.id) check_access(teaching_assistant).to be false diff --git a/spec/controllers/review_bids_controller_spec.rb b/spec/controllers/review_bids_controller_spec.rb index a2550675eb9..27a53365890 100644 --- a/spec/controllers/review_bids_controller_spec.rb +++ b/spec/controllers/review_bids_controller_spec.rb @@ -1,7 +1,7 @@ describe ReviewBidsController do # let(:assignment) { double('Assignment', id: 1) } # let(:participant) { double('AssignmentParticipant', id: 1, can_review: false, user: double('User', id: 1)) } - let(:student) { build(:student, id: 1, name: 'name', fullname: 'no one', email: 'expertiza@mailinator.com') } + let(:student) { build(:student, id: 1, username: 'name', fullname: 'no one', email: 'expertiza@mailinator.com') } let(:assignment) { build(:assignment, id: 1, name: 'Test Assgt', rounds_of_reviews: 2) } let(:participant) { build(:participant, id: 1, parent_id: 1, user: student) } diff --git a/spec/controllers/review_mapping_controller_spec.rb b/spec/controllers/review_mapping_controller_spec.rb index 84cabc77dd9..1d2c5ac4266 100644 --- a/spec/controllers/review_mapping_controller_spec.rb +++ b/spec/controllers/review_mapping_controller_spec.rb @@ -61,11 +61,11 @@ describe '#add_reviewer and #get_reviewer' do before(:each) do - allow(User).to receive_message_chain(:where, :first).with(name: 'expertiza').with(no_args).and_return(double('User', id: 1)) + allow(User).to receive_message_chain(:where, :first).with(username: 'expertiza').with(no_args).and_return(double('User', id: 1)) @params = { id: 1, topic_id: 1, - user: { name: 'expertiza' }, + user: { username: 'expertiza' }, contributor_id: 1 } end @@ -289,12 +289,12 @@ end it 'redirects to review_mapping#list_mappings page' do - user = double('User', id: 1, name: 'no one') + user = double('User', id: 1, username: 'no one') allow(User).to receive(:from_params).with(any_args).and_return(user) # allow_any_instance_of(ReviewMappingController).to receive(:url_for).with(action: 'add_user_to_assignment', id: 1, user_id: 1).and_return('') allow_any_instance_of(ReviewMappingController).to receive(:get_reviewer) .with(user, assignment, 'http://test.host/review_mapping/add_user_to_assignment?id=1&user_id=1') - .and_return(double('AssignmentParticipant', id: 1, name: 'no one')) + .and_return(double('AssignmentParticipant', id: 1, username: 'no one')) allow(ReviewResponseMap).to receive(:where).with(reviewed_object_id: 1, reviewer_id: 1).and_return([nil]) request_params = { id: 1 } post :add_metareviewer, params: request_params diff --git a/spec/controllers/sample_reviews_controller_spec.rb b/spec/controllers/sample_reviews_controller_spec.rb index 175663bfb4e..d77a3980533 100644 --- a/spec/controllers/sample_reviews_controller_spec.rb +++ b/spec/controllers/sample_reviews_controller_spec.rb @@ -23,8 +23,8 @@ let(:response1) { build(:response, id: 2, map_id: 1, round: 2, response_map: review_response_map) } let(:response2) { build(:response, id: 3, map_id: 1, round: nil, response_map: review_response_map, is_submitted: true) } let(:metareview_response_map) { build(:meta_review_response_map, reviewed_object_id: 1) } - let(:student) { build(:student, id: 1, name: 'name', fullname: 'no one', email: 'expertiza@mailinator.com') } - let(:student1) { build(:student, id: 2, name: 'name1', fullname: 'no one', email: 'expertiza@mailinator.com') } + let(:student) { build(:student, id: 1, username: 'name', fullname: 'no one', email: 'expertiza@mailinator.com') } + let(:student1) { build(:student, id: 2, username: 'name1', fullname: 'no one', email: 'expertiza@mailinator.com') } let(:questionnaire) { Questionnaire.new(id: 1, type: 'ReviewQuestionnaire') } let(:answer) { Answer.new(id: 5, question_id: 1) } let(:samplereview1) { SampleReview.new id: 3, assignment_id: 10, response_id: 5 } diff --git a/spec/controllers/sign_up_sheet_controller_spec.rb b/spec/controllers/sign_up_sheet_controller_spec.rb index 2a53759f4c6..de231fec2a2 100755 --- a/spec/controllers/sign_up_sheet_controller_spec.rb +++ b/spec/controllers/sign_up_sheet_controller_spec.rb @@ -520,7 +520,7 @@ describe '#signup_as_instructor_action' do context 'when user cannot be found' do it 'shows an flash error message and redirects to assignment#edit page' do - allow(User).to receive(:find_by).with(name: 'no name').and_return(nil) + allow(User).to receive(:find_by).with(username: 'no name').and_return(nil) allow(User).to receive(:find).with(8).and_return(student) allow(Team).to receive(:find).with(1).and_return(team) request_params = { username: 'no name', assignment_id: 1 } @@ -532,7 +532,7 @@ context 'when user can be found' do before(:each) do - allow(User).to receive(:find_by).with(name: 'no name').and_return(student) + allow(User).to receive(:find_by).with(username: 'no name').and_return(student) end context 'when an assignment_participant can be found' do diff --git a/spec/controllers/student_view_controller_spec.rb b/spec/controllers/student_view_controller_spec.rb index c62d42dfcf1..aefc594e8d3 100644 --- a/spec/controllers/student_view_controller_spec.rb +++ b/spec/controllers/student_view_controller_spec.rb @@ -1,6 +1,6 @@ describe StudentViewController do let(:instructor) { build(:instructor, id: 2) } - let(:student1) { build(:student, id: 30, name: :Amanda) } + let(:student1) { build(:student, id: 30, username: :Amanda) } # student view is only accessible to instructors, so we will make one before(:each) do diff --git a/spec/controllers/submission_records_controller_spec.rb b/spec/controllers/submission_records_controller_spec.rb index 7eec4130e4e..3f16ea80276 100644 --- a/spec/controllers/submission_records_controller_spec.rb +++ b/spec/controllers/submission_records_controller_spec.rb @@ -1,12 +1,12 @@ describe SubmissionRecordsController do # initialize objects using factories.rb required for stubbing in test cases let(:super_admin) { build(:superadmin, id: 1) } - let(:instructor1) { build(:instructor, id: 10, name: 'Instructor1') } - let(:instructor2) { build(:instructor, id: 11, name: 'Instructor2') } + let(:instructor1) { build(:instructor, id: 10, username: 'Instructor1') } + let(:instructor2) { build(:instructor, id: 11, username: 'Instructor2') } let(:ta) { build(:teaching_assistant, id: 8) } let(:assignment) { build(:assignment, id: 1, name: 'Test Assgt', rounds_of_reviews: 2, instructor_id: 10) } - let(:student) { build(:student, id: 1, name: 'name', fullname: 'no one', email: 'expertiza@mailinator.com') } + let(:student) { build(:student, id: 1, username: 'name', fullname: 'no one', email: 'expertiza@mailinator.com') } let(:team) { build(:assignment_team, id: 1, name: 'team no name', assignment: assignment, users: [student], parent_id: 1) } let(:submission_record) { build(:submission_record, id: 1, team_id: 27158, assignment_id: 1) } diff --git a/spec/controllers/submitted_content_controller_spec.rb b/spec/controllers/submitted_content_controller_spec.rb index ba230766f8d..b9942264e4f 100644 --- a/spec/controllers/submitted_content_controller_spec.rb +++ b/spec/controllers/submitted_content_controller_spec.rb @@ -1,7 +1,7 @@ describe SubmittedContentController do let(:admin) { build(:admin, id: 3) } let(:super_admin) { build(:superadmin, id: 1, role_id: 5) } - let(:instructor1) { build(:instructor, id: 10, role_id: 3, parent_id: 3, name: 'Instructor1') } + let(:instructor1) { build(:instructor, id: 10, role_id: 3, parent_id: 3, username: 'Instructor1') } let(:student1) { build(:student, id: 21, role_id: 1) } let(:team) { build(:assignment_team, id: 1) } let(:participant) { build(:participant, id: 1, user_id: 21) } diff --git a/spec/controllers/suggestion_controller_spec.rb b/spec/controllers/suggestion_controller_spec.rb index 773bd883189..8d627f9f717 100644 --- a/spec/controllers/suggestion_controller_spec.rb +++ b/spec/controllers/suggestion_controller_spec.rb @@ -51,7 +51,7 @@ describe '#add_comment' do it 'adds a participant' do allow(Assignment).to receive(:find).with('1').and_return(assignment) - allow(User).to receive(:find_by).with(name: student.name).and_return(student) + allow(User).to receive(:find_by).with(username: student.username).and_return(student) allow(SuggestionComment).to receive(:new).and_return(suggestion_comment) allow_any_instance_of(SuggestionComment).to receive(:save).and_return(true) request_params = { id: 1, suggestion_comment: { vote: 'Y', comments: 'comments' } } diff --git a/spec/controllers/teams_users_controller_spec.rb b/spec/controllers/teams_users_controller_spec.rb index c43f20e8c38..5318713f2f2 100644 --- a/spec/controllers/teams_users_controller_spec.rb +++ b/spec/controllers/teams_users_controller_spec.rb @@ -88,11 +88,11 @@ describe '#create' do context 'when user is added to assignment or course team' do it 'it throws error when user is not defined' do - allow(User).to receive(:find_by).with(name: 'instructor6').and_return(nil) + allow(User).to receive(:find_by).with(username: 'instructor6').and_return(nil) allow(Team).to receive(:find).with('1').and_return(team1) user_session = { user: admin } request_params = { - user: { name: 'instructor6' }, id: 1 + user: { username: 'instructor6' }, id: 1 } post :create, params: request_params, session: user_session # Expect to throw error @@ -104,14 +104,14 @@ context 'when user is added to assignment team' do it 'it throws error when user added is not a participant of the current assignment' do - allow(User).to receive(:find_by).with(name: student1.name).and_return(student1) + allow(User).to receive(:find_by).with(username: student1.username).and_return(student1) allow(Team).to receive(:find).with('1').and_return(team1) allow(AssignmentTeam).to receive(:find).with('1').and_return(team1) allow(Assignment).to receive(:find).with(1).and_return(assignment1) allow(AssignmentParticipant).to receive(:find_by).with(user_id: 1, parent_id: 1).and_return(nil) user_session = { user: admin } request_params = { - user: { name: 'student2065' }, id: 1 + user: { username: 'student2065' }, id: 1 } post :create, params: request_params, session: user_session # Expect to throw error @@ -123,7 +123,7 @@ context 'when user is added to assignment team' do it 'it throws error when assignmentTeam has maximum number of participants' do - allow(User).to receive(:find_by).with(name: student1.name).and_return(student1) + allow(User).to receive(:find_by).with(username: student1.username).and_return(student1) allow(Team).to receive(:find).with('1').and_return(team1) allow(AssignmentTeam).to receive(:find).with('1').and_return(team1) allow(Assignment).to receive(:find).with(1).and_return(assignment1) @@ -131,7 +131,7 @@ allow_any_instance_of(Team).to receive(:add_member).with(any_args).and_return(false) user_session = { user: admin } request_params = { - user: { name: 'student2065' }, id: 1 + user: { username: 'student2065' }, id: 1 } post :create, params: request_params, session: user_session # Expect to throw error @@ -143,7 +143,7 @@ context 'when user is added to assignment team' do it 'new user gets successfully added to the assignment' do - allow(User).to receive(:find_by).with(name: student1.name).and_return(student1) + allow(User).to receive(:find_by).with(username: student1.username).and_return(student1) allow(Team).to receive(:find).with(any_args).and_return(team1) allow(AssignmentTeam).to receive(:find).with('1').and_return(team1) allow(Assignment).to receive(:find).with(1).and_return(assignment1) @@ -152,7 +152,7 @@ allow(TeamsUser).to receive(:last).with(any_args).and_return(student1) user_session = { user: admin } request_params = { - user: { name: 'student2065' }, id: 1 + user: { username: 'student2065' }, id: 1 } post :create, params: request_params, session: user_session # Expect the response to redirect to 'http://test.host/teams/list?id=1' @@ -162,14 +162,14 @@ context 'when user is added to course team' do it 'it throws error when user added to course Team is not defined' do - allow(User).to receive(:find_by).with(name: student1.name).and_return(student1) + allow(User).to receive(:find_by).with(username: student1.username).and_return(student1) allow(Team).to receive(:find).with('5').and_return(team5) allow(CourseTeam).to receive(:find).with('5').and_return(team5) allow(Course).to receive(:find).with(1).and_return(course1) allow(CourseParticipant).to receive(:find_by).with(user_id: 1, parent_id: 1).and_return(nil) user_session = { user: admin } request_params = { - user: { name: 'student2065' }, id: 5 + user: { username: 'student2065' }, id: 5 } post :create, params: request_params, session: user_session # Expect to throw error @@ -181,7 +181,7 @@ context 'when user is added to course team' do it 'it throws error when courseTeam has maximum number of participants' do - allow(User).to receive(:find_by).with(name: student1.name).and_return(student1) + allow(User).to receive(:find_by).with(username: student1.username).and_return(student1) allow(Team).to receive(:find).with('5').and_return(team5) allow(CourseTeam).to receive(:find).with('5').and_return(team5) allow(Course).to receive(:find).with(1).and_return(course1) @@ -189,7 +189,7 @@ allow_any_instance_of(CourseTeam).to receive(:add_member).with(any_args).and_return(false) user_session = { user: admin } request_params = { - user: { name: 'student2065' }, id: 5 + user: { username: 'student2065' }, id: 5 } post :create, params: request_params, session: user_session # Expect to throw error @@ -201,7 +201,7 @@ context 'when user is added to course team' do it 'new user gets successfully added to course' do - allow(User).to receive(:find_by).with(name: student1.name).and_return(student1) + allow(User).to receive(:find_by).with(username: student1.username).and_return(student1) allow(Team).to receive(:find).with('5').and_return(team5) allow(CourseTeam).to receive(:find).with('5').and_return(team5) allow(TeamsUser).to receive(:create).with(user_id: 1, team_id: 5).and_return(double('TeamsUser', id: 1)) @@ -212,7 +212,7 @@ allow_any_instance_of(CourseTeam).to receive(:add_member).with(any_args).and_return(true) user_session = { user: admin } request_params = { - user: { name: 'student2065' }, id: 5 + user: { username: 'student2065' }, id: 5 } post :create, params: request_params, session: user_session # Expect the response to redirect to 'http://test.host/teams/list?id=1' @@ -222,7 +222,7 @@ context 'when user is already on an assignment team' do it 'returns redirect_back' do - allow(User).to receive(:find_by).with(name: student1.name).and_return(student1) + allow(User).to receive(:find_by).with(username: student1.username).and_return(student1) allow(Team).to receive(:find).with(any_args).and_return(team1) allow(AssignmentTeam).to receive(:find).with('1').and_return(team1) allow(Assignment).to receive(:find).with(1).and_return(assignment1) @@ -232,7 +232,7 @@ allow(assignment1).to receive(:user_on_team?).with(student1).and_return(true) user_session = { user: admin } request_params = { - user: { name: 'student2065' }, id: 1 + user: { username: 'student2065' }, id: 1 } post :create, params: request_params, session: user_session # Expect to throw error @@ -244,7 +244,7 @@ context 'when user is added to assignment team while on a team already' do it 'it throws error that they are already on a team' do - allow(User).to receive(:find_by).with(name: student1.name).and_return(student1) + allow(User).to receive(:find_by).with(username: student1.username).and_return(student1) allow(Team).to receive(:find).with('1').and_return(team1) allow(AssignmentTeam).to receive(:find).with('1').and_return(team1) allow(Assignment).to receive(:find).with(1).and_return(assignment1) @@ -252,7 +252,7 @@ allow_any_instance_of(Team).to receive(:add_member).with(any_args).and_raise("Member on existing team error") user_session = { user: admin } request_params = { - user: { name: 'student2065' }, id: 1 + user: { username: 'student2065' }, id: 1 } post :create, params: request_params, session: user_session # Expect to throw error @@ -264,7 +264,7 @@ context 'when user is already on a course team' do it 'returns redirect_back' do - allow(User).to receive(:find_by).with(name: student1.name).and_return(student1) + allow(User).to receive(:find_by).with(username: student1.username).and_return(student1) allow(Team).to receive(:find).with('5').and_return(team5) allow(CourseTeam).to receive(:find).with('5').and_return(team5) allow(TeamsUser).to receive(:create).with(user_id: 1, team_id: 5).and_return(double('TeamsUser', id: 1)) @@ -276,7 +276,7 @@ allow(course1).to receive(:user_on_team?).with(student1).and_return(true) user_session = { user: admin } request_params = { - user: { name: 'student2065' }, id: 5 + user: { username: 'student2065' }, id: 5 } post :create, params: request_params, session: user_session # Expect to throw error @@ -288,7 +288,7 @@ context 'when user is added to course team while on a team already' do it 'it throws error that they are already on a team' do - allow(User).to receive(:find_by).with(name: student1.name).and_return(student1) + allow(User).to receive(:find_by).with(username: student1.username).and_return(student1) allow(Team).to receive(:find).with('5').and_return(team5) allow(CourseTeam).to receive(:find).with('5').and_return(team5) allow(Course).to receive(:find).with(1).and_return(course1) @@ -296,7 +296,7 @@ allow_any_instance_of(CourseTeam).to receive(:add_member).with(any_args).and_raise("Member on existing team error") user_session = { user: admin } request_params = { - user: { name: 'student2065' }, id: 5 + user: { username: 'student2065' }, id: 5 } post :create, params: request_params, session: user_session # Expect to throw error diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index e19ba856282..b2e741f39d9 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -2,17 +2,17 @@ let(:admin) { build(:admin, id: 3) } let(:super_admin) { build(:superadmin) } let(:instructor) { build(:instructor, id: 2) } - let(:student1) { build(:student, id: 1, name: :lily) } + let(:student1) { build(:student, id: 1, username: :lily) } let(:student2) { build(:student) } let(:student3) { build(:student, id: 10, role_id: 1, parent_id: nil) } let(:student4) { build(:student, id: 20, role_id: 4) } let(:student5) { build(:student, role_id: 4, parent_id: 3) } - let(:student6) { build(:student, role_id: nil, name: :lilith) } - let(:student7) { build(:student, id: 30, name: :amanda) } + let(:student6) { build(:student, role_id: nil, username: :lilith) } + let(:student7) { build(:student, id: 30, username: :amanda) } let(:institution1) { build(:institution, id: 1) } let(:requested_user1) do - AccountRequest.new id: 4, name: 'requester1', role_id: 2, fullname: 're, requester1', + AccountRequest.new id: 4, username: 'requester1', role_id: 2, fullname: 're, requester1', institution_id: 1, email: 'requester1@test.com', status: nil, self_introduction: 'no one' end let(:superadmin) { build(:superadmin) } @@ -122,19 +122,19 @@ allow(User).to receive(:find).with(2).and_return(instructor) end it 'user is nil' do - allow(User).to receive(:find_by).with(name: 'instructor6').and_return(nil) + allow(User).to receive(:find_by).with(username: 'instructor6').and_return(nil) user_session = { user: admin } request_params = { - user: { name: 'instructor6' } + user: { username: 'instructor6' } } post :show_if_authorized, params: request_params, session: user_session expect(response).to redirect_to('http://test.host/users/list') end it 'user is not nil and user is available for editing' do - allow(User).to receive(:find_by).with(name: 'instructor6').and_return(student3) + allow(User).to receive(:find_by).with(username: 'instructor6').and_return(student3) request_params = { - user: { name: 'instructor6' } + user: { username: 'instructor6' } } get :show_if_authorized, params: request_params expect(response).to render_template(:show) @@ -148,7 +148,7 @@ instructor = create(:instructor) stub_current_user(teaching_assistant, teaching_assistant.role.name, teaching_assistant.role) request_params = { - user: { name: instructor.name } + user: { username: instructor.username } } user_session = { user: teaching_assistant } post :show_if_authorized, params: request_params, session: user_session @@ -197,10 +197,10 @@ allow(User).to receive(:find).with(3).and_return(admin) end it 'save successfully with email as name' do - allow(User).to receive(:find_by).with(name: 'lily').and_return(student1) + allow(User).to receive(:find_by).with(username: 'lily').and_return(student1) user_session = { user: admin } request_params = { - user: { name: 'lily', + user: { username: 'lily', crypted_password: 'password', role_id: 2, password_salt: 1, @@ -230,7 +230,7 @@ it 'save successfully without the same name' do user_session = { user: admin } request_params = { - user: { name: 'instructor6', + user: { username: 'instructor6', crypted_password: 'password', role_id: 2, password_salt: 1, @@ -261,7 +261,7 @@ expect_any_instance_of(User).to receive(:save).and_return(false) user_session = { user: admin } request_params = { - user: { name: 'instructor6', + user: { username: 'instructor6', crypted_password: 'password', role_id: 2, password_salt: 1, diff --git a/spec/controllers/versions_controller_spec.rb b/spec/controllers/versions_controller_spec.rb index 08770ad4a1d..94f758feb3d 100644 --- a/spec/controllers/versions_controller_spec.rb +++ b/spec/controllers/versions_controller_spec.rb @@ -1,7 +1,7 @@ describe VersionsController do let(:admin) { build(:admin, id: 3) } let(:instructor) { build(:instructor, id: 2) } - let(:student) { build_stubbed(:student, id: 1, name: 'student') } + let(:student) { build_stubbed(:student, id: 1, username: 'student') } let(:super_admin) { build(:superadmin, id: 1, role_id: 5) } let(:version) { build(:version) } diff --git a/spec/factories/factories.rb b/spec/factories/factories.rb index c359e784672..dbcb358029d 100644 --- a/spec/factories/factories.rb +++ b/spec/factories/factories.rb @@ -49,7 +49,7 @@ end factory :admin, class: User do - sequence(:name) { |n| "admin#{n}" } + sequence(:username) { |n| "admin#{n}" } role { Role.where(name: 'Administrator').first || association(:role_of_administrator) } password 'password' password_confirmation 'password' @@ -71,7 +71,7 @@ end factory :superadmin, class: User do - sequence(:name) { |n| "superadmin#{n}" } + sequence(:username) { |n| "superadmin#{n}" } role { Role.where(name: 'Super-Administrator').first || association(:role_of_superadministrator) } password 'password' password_confirmation 'password' @@ -101,7 +101,7 @@ end factory :mentor, class: AssignmentParticipant do - sequence(:name) { |n| n = n % 3; "mentor206#{n + 4}" } + sequence(:username) { |n| n = n % 3; "mentor206#{n + 4}" } can_submit true can_review true assignment { Assignment.first || association(:assignment) } @@ -121,7 +121,7 @@ factory :student, class: User do # Zhewei: In order to keep students the same names (2065, 2066, 2064) before each example. - sequence(:name) { |n| n = n % 3; "student206#{n + 4}" } + sequence(:username) { |n| n = n % 3; "student206#{n + 4}" } role { Role.where(name: 'Student').first || association(:role_of_student) } password 'password' password_confirmation 'password' @@ -143,7 +143,7 @@ end factory :instructor, class: Instructor do - name 'instructor6' + username 'instructor6' role { Role.where(name: 'Instructor').first || association(:role_of_instructor) } password 'password' password_confirmation 'password' @@ -165,7 +165,7 @@ end factory :teaching_assistant, class: Ta do - name 'teaching_assistant5888' + username 'teaching_assistant5888' role { Role.where(name: 'Teaching Assistant').first || association(:role_of_teaching_assistant) } password 'password' password_confirmation 'password' @@ -572,7 +572,7 @@ end factory :requested_user, class: AccountRequest do - name 'requester1' + username 'requester1' role_id 2 fullname 'requester, requester' institution_id 1 @@ -640,7 +640,7 @@ end factory :test_user, class: User do - name 'username' + username 'username' fullname 'full name' email 'abc@mailinator.com' end diff --git a/spec/features/account_request_spec.rb b/spec/features/account_request_spec.rb index 8ba3ae42551..071d3c89542 100644 --- a/spec/features/account_request_spec.rb +++ b/spec/features/account_request_spec.rb @@ -4,7 +4,7 @@ # create(:role_of_instructor) # create(:role_of_administrator) # create(:role_of_teaching_assistant) - create(:admin, name: 'super_administrator2') + create(:admin, username: 'super_administrator2') create(:institution) end @@ -36,7 +36,7 @@ fill_in 'user_email', with: 'test@test.com' expect { click_on 'Request' }.to change { AccountRequest.count }.by(1) - expect(AccountRequest.first.name).to eq('requester') + expect(AccountRequest.first.username).to eq('requester') expect(AccountRequest.first.role_id).to eq(3) expect(AccountRequest.first.fullname).to eq('requester, requester') expect(AccountRequest.first.email).to eq('test@test.com') @@ -57,9 +57,9 @@ context 'when super-admin or admin accepts a requester' do context 'using name as username and password in the email' do it 'allows the new user to login Expertiza' do - create(:student, name: 'approved_requster1', password: 'password') + create(:student, username: 'approved_requster1', password: 'password') visit '/' - fill_in 'login_name', with: 'approved_requster1' + fill_in 'login_username', with: 'approved_requster1' fill_in 'login_password', with: 'password' click_button 'Sign in' expect(page).to have_current_path('/student_task/list') diff --git a/spec/features/airbrake_exception_errors_feature_tests_spec.rb b/spec/features/airbrake_exception_errors_feature_tests_spec.rb index ab7b7b3a138..ec47524f061 100644 --- a/spec/features/airbrake_exception_errors_feature_tests_spec.rb +++ b/spec/features/airbrake_exception_errors_feature_tests_spec.rb @@ -40,7 +40,7 @@ assignment = Assignment.first assignment.update_attributes(require_quiz: true) login_as 'student2064' - user_id = User.find_by(name: 'student2064').id + user_id = User.find_by(username: 'student2064').id participant_id = Participant.where(user_id: user_id).first.id visit '/student_task/list' click_link 'TestAssignment' @@ -137,7 +137,7 @@ it "can access to '/student_task/list' after login as a student" do stu = create(:student) - login_as stu.name + login_as stu.username visit '/tree_display/list' expect(page).to have_current_path('/student_task/list') expect(page).to have_content('Assignments') diff --git a/spec/features/assignment_creation_participants_spec.rb b/spec/features/assignment_creation_participants_spec.rb index a860c8687f7..ce2db2a3d61 100644 --- a/spec/features/assignment_creation_participants_spec.rb +++ b/spec/features/assignment_creation_participants_spec.rb @@ -16,7 +16,7 @@ assignment_id = Assignment.where(name: 'participants Assignment').first.id visit "/participants/list?id=#{assignment_id}&model=Assignment" - fill_in 'user_name', with: student.name, match: :first + fill_in 'user_name', with: student.username, match: :first choose 'user_role_participant', match: :first expect do diff --git a/spec/features/assignment_creation_spec.rb b/spec/features/assignment_creation_spec.rb index f2213151ecf..1f71c487773 100644 --- a/spec/features/assignment_creation_spec.rb +++ b/spec/features/assignment_creation_spec.rb @@ -662,7 +662,7 @@ def fill_assignment_form assignment_id = Assignment.where(name: 'participants Assignment').first.id visit "/participants/list?id=#{assignment_id}&model=Assignment" - fill_in 'user_name', with: student.name, match: :first + fill_in 'user_name', with: student.username, match: :first choose 'user_role_participant', match: :first expect { click_button 'Add', match: :first; sleep(1) }.to change { Participant.count }.by 1 diff --git a/spec/features/assignment_submission_spec.rb b/spec/features/assignment_submission_spec.rb index 487fd68d5d1..bdec5bd8a6f 100644 --- a/spec/features/assignment_submission_spec.rb +++ b/spec/features/assignment_submission_spec.rb @@ -17,8 +17,8 @@ end def signup_topic - user = User.find_by(name: 'student2064') - login_as(user.name) + user = User.find_by(username: 'student2064') + login_as(user.username) stub_current_user(user, user.role.name, user.role) visit '/student_task/list' visit '/sign_up_sheet/sign_up?id=1&topic_id=1' # signup topic @@ -146,7 +146,7 @@ def signup_topic it "notifies the reviewer/s who have reviewed the previous submission of the new submission" do signup_topic - reviewer = AssignmentParticipant.find_by(user: User.find_by(name: "student2065")) # An arbitrary reviewer on the assignment + reviewer = AssignmentParticipant.find_by(user: User.find_by(username: "student2065")) # An arbitrary reviewer on the assignment create(:review_response_map, reviewer: reviewer) # a reviewer submits a review for this team attach_file('uploaded_file', Rails.root + "spec/features/assignment_submission_files/valid_assignment_file.jpg") diff --git a/spec/features/assignment_survey_spec.rb b/spec/features/assignment_survey_spec.rb index 8d2f7908079..40d3f2365e9 100644 --- a/spec/features/assignment_survey_spec.rb +++ b/spec/features/assignment_survey_spec.rb @@ -12,7 +12,7 @@ def deploy_assignment_survey(start_date, end_date, survey_name) create_assignment_questionnaire survey_name survey = Questionnaire.where(name: survey_name) visit '/survey_deployment/new?id=' + \ - Assignment.where(instructor_id: User.where(name: 'instructor6').first.id).first.id.to_s + '&type=AssignmentSurveyDeployment' + Assignment.where(instructor_id: User.where(username: 'instructor6').first.id).first.id.to_s + '&type=AssignmentSurveyDeployment' expect(page).to have_content('New Survey Deployment') fill_in 'survey_deployment_start_date', with: start_date fill_in 'survey_deployment_end_date', with: end_date diff --git a/spec/features/assignment_team_import_spec.rb b/spec/features/assignment_team_import_spec.rb index bf0dcb9b2cc..55c4a2d9747 100644 --- a/spec/features/assignment_team_import_spec.rb +++ b/spec/features/assignment_team_import_spec.rb @@ -13,7 +13,7 @@ # to test create new teams by importing a txt file it 'is able to create team by importing a file' do login_as('instructor6') - instructor = User.where(name: 'instructor6').first + instructor = User.where(username: 'instructor6').first assignment = Assignment.where(instructor_id: instructor.id).first visit "/teams/list?id=#{assignment.id}&type=Assignment" click_link 'Import Teams' diff --git a/spec/features/assignment_team_member_spec.rb b/spec/features/assignment_team_member_spec.rb index 7bfc4f30d3f..076b6e2d6cd 100644 --- a/spec/features/assignment_team_member_spec.rb +++ b/spec/features/assignment_team_member_spec.rb @@ -16,7 +16,7 @@ user = AssignmentParticipant.first visit "/teams/list?id=#{assignment.id}&type=Assignment" visit "/teams_users/new?id=#{team.id}" - fill_in 'user_name', with: user.name + fill_in 'user_name', with: user.username click_button 'Add' expect(team.participants).to include(user) end diff --git a/spec/features/course_creation_spec.rb b/spec/features/course_creation_spec.rb index 7da2cf2970f..a2ce98e488a 100644 --- a/spec/features/course_creation_spec.rb +++ b/spec/features/course_creation_spec.rb @@ -9,7 +9,7 @@ student = create(:student) login_as('instructor6') visit "/course/view_teaching_assistants?id=#{@course.id}&model=Course" - fill_in 'user_name', with: student.name + fill_in 'user_name', with: student.username expect do click_button 'Add TA' diff --git a/spec/features/course_survey_spec.rb b/spec/features/course_survey_spec.rb index 09a83c5339d..b33eec49d45 100644 --- a/spec/features/course_survey_spec.rb +++ b/spec/features/course_survey_spec.rb @@ -11,7 +11,7 @@ def deploy_course_survey(start_date, end_date, survey_name) expect(page).to have_content('Manage content') create_course_questionnaire survey_name survey = Questionnaire.where(name: survey_name) - instructor = User.where(name: 'instructor6').first + instructor = User.where(username: 'instructor6').first course = Course.where(instructor_id: instructor.id).first visit '/survey_deployment/new?id=' + course.id.to_s + '&type=CourseSurveyDeployment' expect(page).to have_content('New Survey Deployment') diff --git a/spec/features/global_survey_spec.rb b/spec/features/global_survey_spec.rb index 8fab6c271f3..9ac61f17894 100644 --- a/spec/features/global_survey_spec.rb +++ b/spec/features/global_survey_spec.rb @@ -11,7 +11,7 @@ def deploy_global_survey(start_date, end_date, survey_name) expect(page).to have_content('Manage content') create_global_questionnaire survey_name survey = Questionnaire.where(name: survey_name) - instructor = User.where(name: 'instructor6').first + instructor = User.where(username: 'instructor6').first course = Course.where(instructor_id: instructor.id).first visit '/survey_deployment/new?id=' + course.id.to_s + '&type=CourseSurveyDeployment' expect(page).to have_content('New Survey Deployment') diff --git a/spec/features/impersonate_student_spec.rb b/spec/features/impersonate_student_spec.rb index e601e050180..1fb8dbd7e77 100644 --- a/spec/features/impersonate_student_spec.rb +++ b/spec/features/impersonate_student_spec.rb @@ -6,11 +6,11 @@ assignment_test = create(:assignment, name: 'E1968', course: nil) # create an assignment without course expect(assignment_test.instructor_id).to eql(instructor6.id) expect(assignment_test.course_id).to eql(nil) - student_test = create(:student, name: 'student6666', email: 'stu6666@ncsu.edu') # create a student for test + student_test = create(:student, username: 'student6666', email: 'stu6666@ncsu.edu') # create a student for test # 2. log in as instructor6 visit(root_path) - fill_in('login_name', with: 'instructor6') + fill_in('login_username', with: 'instructor6') fill_in('login_password', with: 'password') click_button('Sign in') expect(current_path).to eql('/tree_display/list') @@ -19,18 +19,18 @@ # 3. assign the assignment without course to the test student visit("/participants/list?id=#{assignment_test.id}&model=Assignment") expect(page).to have_content('E1968') - fill_in('user_name', match: :first, with: student_test.name) + fill_in('user_name', match: :first, with: student_test.username) click_button('Add', match: :first) - expect(page).to have_content(student_test.name) + expect(page).to have_content(student_test.username) expect(page).to have_content(student_test.email) # 3. impersonate the student with the assignment which is not subject to any course visit('/impersonate/start') expect(page).to have_content('Enter user account') - fill_in('user_name', with: student_test.name) + fill_in('user_name', with: student_test.username) click_button('Impersonate') expect(current_path).to eql('/student_task/list') - expect(page).to have_content("User: #{student_test.name}") + expect(page).to have_content("User: #{student_test.username}") expect(page).to have_content('E1968') end end diff --git a/spec/features/instructor_do_review_spec.rb b/spec/features/instructor_do_review_spec.rb index ad821ab6a52..e70e064a828 100644 --- a/spec/features/instructor_do_review_spec.rb +++ b/spec/features/instructor_do_review_spec.rb @@ -20,10 +20,10 @@ expect(assignment_test.instructor_id).to eql(instructor6.id) expect(assignment_test.course_id).to eql(nil) - student_test = create(:student, name: 'student6666', email: 'stu6666@ncsu.edu') # create a student for test + student_test = create(:student, username: 'student6666', email: 'stu6666@ncsu.edu') # create a student for test visit(root_path) - fill_in('login_name', with: 'instructor6') + fill_in('login_username', with: 'instructor6') fill_in('login_password', with: 'password') click_button('Sign in') expect(current_path).to eql('/tree_display/list') @@ -31,20 +31,20 @@ visit("/participants/list?id=#{assignment_test.id}&model=Assignment") expect(page).to have_content('E2086') - fill_in('user_name', match: :first, with: instructor6.name) + fill_in('user_name', match: :first, with: instructor6.username) click_button('Add', match: :first) - expect(page).to have_content(instructor6.name) + expect(page).to have_content(instructor6.username) expect(page).to have_content(instructor6.email) click_button('Submit', match: :first) visit("/participants/list?id=#{assignment_test.id}&model=Assignment") expect(page).to have_content('E2086') - fill_in('user_name', match: :first, with: student_test.name) + fill_in('user_name', match: :first, with: student_test.username) click_button('Add', match: :first) - expect(page).to have_content(student_test.name) + expect(page).to have_content(student_test.username) expect(page).to have_content(student_test.email) - user_id = User.find_by(name: 'student6666').id + user_id = User.find_by(username: 'student6666').id participant_student = Participant.where(user_id: user_id) participant_id = participant_student.first.id parent_id = participant_student.first.parent_id @@ -68,10 +68,10 @@ visit('/impersonate/start') expect(page).to have_content('Enter user account') - fill_in('user_name', with: student_test.name) + fill_in('user_name', with: student_test.username) click_button('Impersonate') expect(current_path).to eql('/student_task/list') - expect(page).to have_content("User: #{student_test.name}") + expect(page).to have_content("User: #{student_test.username}") expect(page).to have_content('E2086') click_link('E2086') end @@ -93,10 +93,10 @@ expect(assignment_test.instructor_id).to eql(instructor6.id) expect(assignment_test.course_id).to eql(nil) - student_test = create(:student, name: 'student6666', email: 'stu6666@ncsu.edu') # create a student for test + student_test = create(:student, username: 'student6666', email: 'stu6666@ncsu.edu') # create a student for test visit(root_path) - fill_in('login_name', with: 'instructor6') + fill_in('login_username', with: 'instructor6') fill_in('login_password', with: 'password') click_button('Sign in') expect(current_path).to eql('/tree_display/list') @@ -104,20 +104,20 @@ visit("/participants/list?id=#{assignment_test.id}&model=Assignment") expect(page).to have_content('E2086') - fill_in('user_name', match: :first, with: instructor6.name) + fill_in('user_name', match: :first, with: instructor6.username) click_button('Add', match: :first) - expect(page).to have_content(instructor6.name) + expect(page).to have_content(instructor6.username) expect(page).to have_content(instructor6.email) click_button('Submit', match: :first) visit("/participants/list?id=#{assignment_test.id}&model=Assignment") expect(page).to have_content('E2086') - fill_in('user_name', match: :first, with: student_test.name) + fill_in('user_name', match: :first, with: student_test.username) click_button('Add', match: :first) - expect(page).to have_content(student_test.name) + expect(page).to have_content(student_test.username) expect(page).to have_content(student_test.email) - user_id = User.find_by(name: 'student6666').id + user_id = User.find_by(username: 'student6666').id participant_student = Participant.where(user_id: user_id) participant_id = participant_student.first.id parent_id = participant_student.first.parent_id diff --git a/spec/features/instructor_interface_spec.rb b/spec/features/instructor_interface_spec.rb index 61464e650a9..38b1e7efc6c 100644 --- a/spec/features/instructor_interface_spec.rb +++ b/spec/features/instructor_interface_spec.rb @@ -14,7 +14,7 @@ it 'with invalid username and password' do visit root_path - fill_in 'login_name', with: 'instructor6' + fill_in 'login_username', with: 'instructor6' fill_in 'login_password', with: 'something' click_button 'Sign in' expect(page).to have_text('Your username or password is incorrect.') @@ -60,7 +60,7 @@ expect(page).to have_content('Action Preference') choose 'no_show_action_not_show_actions' click_button 'Save' - expect(User.where(name: 'instructor6').first.etc_icons_on_homepage).to eq(false) + expect(User.where(username: 'instructor6').first.etc_icons_on_homepage).to eq(false) end end diff --git a/spec/features/internationalization_spec.rb b/spec/features/internationalization_spec.rb index b2f3cbe1327..9aafd5f2712 100644 --- a/spec/features/internationalization_spec.rb +++ b/spec/features/internationalization_spec.rb @@ -1,6 +1,6 @@ describe 'internationalization', js: true do before(:each) do - instructor = create(:instructor, name: 'hindi_instructor') + instructor = create(:instructor, username: 'hindi_instructor') student = create(:student) course = create(:course, name: 'Hindi Course Intl', instructor: instructor, locale: Course.locales['hi_IN']) @@ -36,7 +36,7 @@ describe "changing the user's locale preference" do it "should display the profile page in the user's configured language" do - login_as(hindi_course_student.name) + login_as(hindi_course_student.username) visit '/profile/update/edit' # Default locale preference is 'No Preference' @@ -55,7 +55,7 @@ end it 'should be able to persist user locale preference across sessions' do - login_as(hindi_course_student.name) + login_as(hindi_course_student.username) visit '/profile/update/edit' expect(page).to have_select('user_locale', selected: 'No Preference') @@ -63,18 +63,18 @@ click_button 'Save', match: :first Capybara.reset_sessions! - login_as(hindi_course_student.name) + login_as(hindi_course_student.username) visit '/profile/update/edit' expect(page).to have_select('user_locale', selected: 'Hindi') end end describe "changing the course's locale preference" do - let(:instructor) { Instructor.find_by(name: 'hindi_instructor') } + let(:instructor) { Instructor.find_by(username: 'hindi_instructor') } let(:course) { Course.find_by(name: 'English Course') } it "should display the course page in the course's configured language" do - login_as(instructor.name) + login_as(instructor.username) visit "/course/#{course.id}/edit" # English Course locale is 'English' @@ -91,7 +91,7 @@ end it 'should be able to persist course locale preference across sessions' do - login_as(instructor.name) + login_as(instructor.username) visit "/course/#{course.id}/edit" expect(page).to have_select('course_locale', selected: 'English') @@ -99,7 +99,7 @@ click_button 'Update', match: :first Capybara.reset_sessions! - login_as(instructor.name) + login_as(instructor.username) visit "/course/#{course.id}/edit" expect(page).to have_select('course_locale', selected: 'Hindi') end @@ -107,7 +107,7 @@ describe 'a user with no language preference' do it 'views the profile page (and other pages without a locale affinity) in English' do - login_as(hindi_course_student.name) + login_as(hindi_course_student.username) visit '/profile/update/edit' expect(page).to have_select('user_locale', selected: 'No Preference') @@ -115,7 +115,7 @@ expect(page).to have_content('Assignments') end it 'views the course page in the course language (and also for other pages with a locale affinity)' do - login_as(hindi_course_student.name) + login_as(hindi_course_student.username) visit '/profile/update/edit' expect(page).to have_select('user_locale', selected: 'No Preference') @@ -127,7 +127,7 @@ describe "a user with a language preference of 'Hindi'" do before(:each) do - login_as(hindi_course_student.name) + login_as(hindi_course_student.username) visit '/profile/update/edit' select 'Hindi', from: 'user_locale' click_button 'Save', match: :first diff --git a/spec/features/questionnaire_spec.rb b/spec/features/questionnaire_spec.rb index a715da0d3bc..2e48327c8ad 100644 --- a/spec/features/questionnaire_spec.rb +++ b/spec/features/questionnaire_spec.rb @@ -15,7 +15,7 @@ it 'with invalid username and password' do visit root_path - fill_in 'login_name', with: 'instructor6' + fill_in 'login_username', with: 'instructor6' fill_in 'login_password', with: 'something' click_button 'Sign in' expect(page).to have_text('Your username or password is incorrect.') diff --git a/spec/features/quiz_spec.rb b/spec/features/quiz_spec.rb index 1cfec0bf2f8..cd4f53dd25d 100644 --- a/spec/features/quiz_spec.rb +++ b/spec/features/quiz_spec.rb @@ -20,7 +20,7 @@ def create_default_test_data(num_qs) end def login_and_create_quiz - login_as @student.name + login_as @student.username click_link 'Assignments' click_link @assignment.name click_link 'Your work' @@ -195,7 +195,7 @@ def fill_in_quiz # [S3] - Students may not take quizzes on a phase that does not allow them to do so. When on a stage that does allow # for quizzes, they may take quizzes on work that they have reviewed. it 'should not be able to take quiz before doing review' do - login_as @student2.name + login_as @student2.username click_link @assignment.name expect(page).to have_content('Take quizzes') click_link 'Take quizzes' @@ -206,7 +206,7 @@ def fill_in_quiz it 'should be able to take quiz after doing review' do create :team_user, team: @team2, user: @student2 create :review_response_map, assignment: @assignment, reviewee: @team1, reviewer_id: 2 - login_as @student2.name + login_as @student2.username click_link @assignment.name expect(page).to have_content('Take quizzes') click_link 'Take quizzes' @@ -306,7 +306,7 @@ def init_instructor_tests # Verify that an instructor can see all quiz questions, # answers, and scores on the review questions page. it 'can view quiz questions and scores' do - login_as @instructor.name + login_as @instructor.username visit "/student_quizzes/review_questions?id=#{@assignment.id}&type=Assignment" student = all('tr > td')[0] score = all('tr > td')[1] @@ -338,7 +338,7 @@ def init_instructor_tests end it 'can not take quiz' do - login_as @student2.name + login_as @student2.username click_link @assignment.name click_link 'Take quizzes' expect(page).to have_no_content('Begin') @@ -359,7 +359,7 @@ def init_instructor_tests end it 'can take quiz' do - login_as @student2.name + login_as @student2.username click_link @assignment.name click_link 'Take quizzes' expect(page).to have_link('Begin') @@ -391,7 +391,7 @@ def init_instructor_tests end it 'can take quiz' do - login_as @student2.name + login_as @student2.username click_link @assignment.name click_link 'Take quizzes' expect(page).to have_link('Begin') @@ -414,7 +414,7 @@ def init_instructor_tests end it 'can view quiz' do - login_as @student2.name + login_as @student2.username click_link @assignment.name click_link 'Take quizzes' expect(page).to have_link('View') diff --git a/spec/features/review_assignment_spec.rb b/spec/features/review_assignment_spec.rb index 470f63ff8c3..baf1deac569 100644 --- a/spec/features/review_assignment_spec.rb +++ b/spec/features/review_assignment_spec.rb @@ -18,8 +18,8 @@ end def signup_topic - user = User.find_by(name: 'student2064') - login_as(user.name) + user = User.find_by(username: 'student2064') + login_as(user.username) visit '/student_task/list' visit '/sign_up_sheet/sign_up?id=1&topic_id=1' # signup topic visit '/student_task/list' @@ -42,8 +42,8 @@ def submit_to_topic end it 'is not able to select review with no submissions' do - user = User.find_by(name: 'student2065') - login_as(user.name) + user = User.find_by(username: 'student2065') + login_as(user.username) visit '/student_task/list' click_link 'TestAssignment' click_link "Others' work" @@ -74,8 +74,8 @@ def submit_to_topic it 'is able to select topic for review with valid submissions' do submit_to_topic click_link 'Logout' - user = User.find_by(name: 'student2065') - login_as(user.name) + user = User.find_by(username: 'student2065') + login_as(user.username) visit '/student_task/list' visit '/sign_up_sheet/sign_up?id=1&topic_id=1' visit '/student_task/list' @@ -89,8 +89,8 @@ def submit_to_topic it 'is able to be assigned random topic for review' do submit_to_topic click_link 'Logout' - user = User.find_by(name: 'student2065') - login_as(user.name) + user = User.find_by(username: 'student2065') + login_as(user.username) visit '/student_task/list' visit '/sign_up_sheet/sign_up?id=1&topic_id=1' visit '/student_task/list' diff --git a/spec/features/review_mapping_spec.rb b/spec/features/review_mapping_spec.rb index 9b13bbb1716..0dbee9a80d8 100644 --- a/spec/features/review_mapping_spec.rb +++ b/spec/features/review_mapping_spec.rb @@ -36,7 +36,7 @@ def add_matareviewer(student_name) create(:deadline_right, name: 'OK') (1..10).each do |i| - student = create :student, name: 'student' + i.to_s + student = create :student, username: 'student' + i.to_s create :participant, assignment: @assignment, user: student if (i % 3 == 1) && (i != 10) instance_variable_set('@team' + (i / 3 + 1).to_s, create(:assignment_team, name: 'team' + i.to_s)) @@ -54,27 +54,27 @@ def add_matareviewer(student_name) # add_reviewer first(:link, 'add reviewer').click - add_reviewer(participant_reviewer.user.name) - expect(page).to have_content participant_reviewer.user.name + add_reviewer(participant_reviewer.user.username) + expect(page).to have_content participant_reviewer.user.username click_link('delete') - expect(page).to have_content "The review mapping for \"#{@team1.name}\" and \"#{participant_reviewer.user.name}\" has been deleted" + expect(page).to have_content "The review mapping for \"#{@team1.name}\" and \"#{participant_reviewer.user.username}\" has been deleted" # add_meta_reviewer first(:link, 'add reviewer').click - add_reviewer(participant_reviewer.user.name) + add_reviewer(participant_reviewer.user.username) click_link('add metareviewer') - add_matareviewer(participant_reviewer2.user.name) - expect(page).to have_content participant_reviewer2.user.name + add_matareviewer(participant_reviewer2.user.username) + expect(page).to have_content participant_reviewer2.user.username # delete_meta_reviewer find(:xpath, "//a[@href='/review_mapping/delete_metareviewer?id=3']").click - expect(page).to have_content "The metareview mapping for #{participant_reviewer.user.name} and #{participant_reviewer2.user.name} has been deleted" + expect(page).to have_content "The metareview mapping for #{participant_reviewer.user.username} and #{participant_reviewer2.user.username} has been deleted" click_link('add metareviewer') - add_matareviewer(participant_reviewer2.user.name) + add_matareviewer(participant_reviewer2.user.username) # delete_all_meta_reviewer click_link('delete all metareviewers') - expect(page).to have_content "metareview mappings for contributor \"#{@team1.name}\" and reviewer \"#{participant_reviewer.user.name}\" have been deleted" + expect(page).to have_content "metareview mappings for contributor \"#{@team1.name}\" and reviewer \"#{participant_reviewer.user.username}\" have been deleted" first(:link, 'delete outstanding reviewers').click expect(page).to have_content "All review mappings for \"#{@team1.name}\" have been deleted" @@ -112,8 +112,8 @@ def add_matareviewer(student_name) login_and_assign_reviewer('instructor6', @assignment.id, 0, 2) # add_reviewer first(:link, 'add reviewer').click - add_reviewer(participant_reviewer.user.name) - expect(page).to have_content participant_reviewer.user.name + add_reviewer(participant_reviewer.user.username) + expect(page).to have_content participant_reviewer.user.username # create new submitted review team = AssignmentTeam.find(1) diff --git a/spec/features/staggered_deadline_spec.rb b/spec/features/staggered_deadline_spec.rb index 3a2d007909d..45383ac4cdf 100644 --- a/spec/features/staggered_deadline_spec.rb +++ b/spec/features/staggered_deadline_spec.rb @@ -72,8 +72,8 @@ def topic_due(type, time, topic_id, round, review_allowed_id = 3) # impersonate student to submit work def submit_topic(name, topic, work) - user = User.find_by(name: name) - login_as(user.name) + user = User.find_by(username: name) + login_as(user.username) visit '/student_task/list' visit topic # signup topic visit '/student_task/list' @@ -103,8 +103,8 @@ def change_due(topic, type, round, time) # impersonate each participant and check their topic's current stage # ####student 1: - user = User.find_by(name: 'student2064') - login_as(user.name) + user = User.find_by(username: 'student2064') + login_as(user.username) visit '/student_task/list' expect(page).to have_content 'review' @@ -121,8 +121,8 @@ def change_due(topic, type, round, time) click_link('Logout') # Although student2065 is in submission stage, he or she can still review other's work. - user = User.find_by(name: 'student2065') - login_as(user.name) + user = User.find_by(username: 'student2065') + login_as(user.username) visit '/student_task/list' expect(page).to have_content 'Stage Deadline' click_link 'Assignment1665' @@ -158,8 +158,8 @@ def change_due(topic, type, round, time) # impersonate each participant and check their topic's current stage # ##first student: - user = User.find_by(name: 'student2064') - login_as(user.name) + user = User.find_by(username: 'student2064') + login_as(user.username) visit '/student_task/list' expect(page).to have_content 'review' @@ -185,8 +185,8 @@ def change_due(topic, type, round, time) click_link('Logout') # ##second student - user = User.find_by(name: 'student2065') - login_as(user.name) + user = User.find_by(username: 'student2065') + login_as(user.username) visit '/student_task/list' expect(page).to have_content 'review' @@ -230,8 +230,8 @@ def change_due(topic, type, round, time) change_due(2, 2, 2, DateTime.now.in_time_zone - 10) # impersonate each participant and check their topic's current stage - user = User.find_by(name: 'student2064') - login_as(user.name) + user = User.find_by(username: 'student2064') + login_as(user.username) visit '/student_task/list' expect(page).to have_content 'Finished' @@ -244,8 +244,8 @@ def change_due(topic, type, round, time) expect { choose 'topic_id_2' }.to raise_error(/Unable to find visible radio button "topic_id_2"/) click_link('Logout') - user = User.find_by(name: 'student2065') - login_as(user.name) + user = User.find_by(username: 'student2065') + login_as(user.username) visit '/student_task/list' expect(page).to have_content 'Finished' click_link 'Assignment1665' diff --git a/spec/features/student_interface_spec.rb b/spec/features/student_interface_spec.rb index 02349f7ba4b..2a30a5c3b7b 100644 --- a/spec/features/student_interface_spec.rb +++ b/spec/features/student_interface_spec.rb @@ -4,14 +4,14 @@ describe 'Student login' do it 'with valid username and password' do student = create(:student) - login_as(student.name) + login_as(student.username) visit '/student_task/list' expect(page).to have_content('Assignments') end it 'with invalid username and password' do visit root_path - fill_in 'login_name', with: 'student2064' + fill_in 'login_username', with: 'student2064' fill_in 'login_password', with: 'something' click_button 'Sign in' expect(page).to have_text('Your username or password is incorrect.') @@ -21,7 +21,7 @@ describe 'Anonymized view tab exists in the menu' do it 'with valid username and password' do student = create(:student) - login_as(student.name) + login_as(student.username) visit '/student_task/list' expect(page).to have_content('Anonymized view') end diff --git a/spec/features/survey_spec.rb b/spec/features/survey_spec.rb index 31de178c9f9..1e3af96a133 100644 --- a/spec/features/survey_spec.rb +++ b/spec/features/survey_spec.rb @@ -12,7 +12,7 @@ def deploy_survey(start_date, end_date, survey_name) create_assignment_questionnaire survey_name survey = Questionnaire.where(name: survey_name) - instructor = User.where(name: 'instructor6').first + instructor = User.where(username: 'instructor6').first assignment = Assignment.where(instructor_id: instructor.id).first visit '/survey_deployment/new?id=' + assignment.id.to_s + '&type=AssignmentSurveyDeployment' expect(page).to have_content('New Survey Deployment') diff --git a/spec/features/team_creation_spec.rb b/spec/features/team_creation_spec.rb index bddb547bc7d..b9169976889 100644 --- a/spec/features/team_creation_spec.rb +++ b/spec/features/team_creation_spec.rb @@ -19,7 +19,7 @@ describe 'one student who signup for a topic should send an inviatation to the other student who has no topic' do before(:each) do - user = User.find_by(name: 'student2064') + user = User.find_by(username: 'student2064') stub_current_user(user, user.role.name, user.role) visit '/student_task/list' # Assignment name @@ -45,7 +45,7 @@ click_button 'Invite' expect(page).to have_content('student2065') - user = User.find_by(name: 'student2065') + user = User.find_by(username: 'student2065') stub_current_user(user, user.role.name, user.role) visit '/student_task/list' expect(page).to have_content('final2') @@ -69,7 +69,7 @@ describe 'one student who has a topic sends an invitation to other student who also has a topic' do before(:each) do - user = User.find_by(name: 'student2064') + user = User.find_by(username: 'student2064') stub_current_user(user, user.role.name, user.role) visit '/student_task/list' expect(page).to have_content('final2') @@ -83,7 +83,7 @@ visit '/sign_up_sheet/sign_up?assignment_id=1&id=1' # expect(page).to have_content('Your topic(s)') # signup for topic for user1 finish - user = User.find_by(name: 'student2065') + user = User.find_by(username: 'student2065') stub_current_user(user, user.role.name, user.role) visit '/student_task/list' expect(page).to have_content('final2') @@ -97,7 +97,7 @@ visit '/sign_up_sheet/sign_up?assignment_id=1&id=2' # expect(page).to have_content('Your topic(s)') # signup for topic for user2 finish - user = User.find_by(name: 'student2064') + user = User.find_by(username: 'student2064') stub_current_user(user, user.role.name, user.role) visit '/student_task/list' expect(page).to have_content('final2') @@ -112,7 +112,7 @@ click_button 'Invite' expect(page).to have_content('Waiting for reply') - user = User.find_by(name: 'student2065') + user = User.find_by(username: 'student2065') stub_current_user(user, user.role.name, user.role) visit '/student_task/list' click_link 'final2' @@ -134,7 +134,7 @@ describe 'one student should send an invitation to other student and both does not have topics' do before(:each) do - user = User.find_by(name: 'student2066') + user = User.find_by(username: 'student2066') stub_current_user(user, user.role.name, user.role) visit '/student_task/list' expect(page).to have_content('final2') @@ -149,7 +149,7 @@ visit "/sign_up_sheet/sign_up?id=#{assignment_id}&topic_id=1" expect(page).to have_content('Your topic(s)') - user = User.find_by(name: 'student2064') + user = User.find_by(username: 'student2064') stub_current_user(user, user.role.name, user.role) visit '/student_task/list' expect(page).to have_content('final2') @@ -168,7 +168,7 @@ click_button 'Invite' expect(page).to have_content('Waiting for reply') - user = User.find_by(name: 'student2065') + user = User.find_by(username: 'student2065') stub_current_user(user, user.role.name, user.role) visit '/student_task/list' expect(page).to have_content('final2') @@ -193,7 +193,7 @@ describe 'one student should send an invitation to other student who has a topic signed up for' do before(:each) do - user = User.find_by(name: 'student2065') + user = User.find_by(username: 'student2065') stub_current_user(user, user.role.name, user.role) visit '/student_task/list' expect(page).to have_content('final2') @@ -209,7 +209,7 @@ expect(page).to have_content('Your topic(s)') # choose a topic for student5710 - user = User.find_by(name: 'student2064') + user = User.find_by(username: 'student2064') stub_current_user(user, user.role.name, user.role) visit '/student_task/list' expect(page).to have_content('final2') @@ -226,7 +226,7 @@ click_button 'Invite' expect(page).to have_content('Waiting for reply') - user = User.find_by(name: 'student2065') + user = User.find_by(username: 'student2065') stub_current_user(user, user.role.name, user.role) visit '/student_task/list' expect(page).to have_content('final2') diff --git a/spec/features/teams_as_reviewers_spec.rb b/spec/features/teams_as_reviewers_spec.rb index e32fd486f6d..85a887e9f5c 100644 --- a/spec/features/teams_as_reviewers_spec.rb +++ b/spec/features/teams_as_reviewers_spec.rb @@ -31,7 +31,7 @@ end xit 'can allow team mates to edit the response' do - user = User.where(name: 'student10').first + user = User.where(username: 'student10').first student = AssignmentParticipant.where(user_id: user.id).first # login as student 10 and start working on the review diff --git a/spec/features/topic_suggestion_spec.rb b/spec/features/topic_suggestion_spec.rb index 18b96455791..e0635f61537 100644 --- a/spec/features/topic_suggestion_spec.rb +++ b/spec/features/topic_suggestion_spec.rb @@ -25,9 +25,9 @@ describe 'topic_suggestion' do it 'Instructor set an assignment which allow student suggest topic and register student2065' do # login as student2065, Note by Xing Pan: modify spec/factories/factories.rb to generate student11 and call "create student" at beginning - user = User.find_by(name: 'student2064') + user = User.find_by(username: 'student2064') # stub_current_user(user, user.role.name, user.role) - login_as(user.name) + login_as(user.username) visit '/student_task/list' expect(page).to have_content 'Assignment_suggest_topic' @@ -42,8 +42,8 @@ expect(page).to have_content 'Thank you for your suggestion' logout visit login_path - user = User.find_by(name: 'instructor6') - login_as(user.name) + user = User.find_by(username: 'instructor6') + login_as(user.username) # instructor approve the suggestion topic # DUE date need to be added here @@ -57,8 +57,8 @@ it ' student2064 hold suggest topic and suggest a new one and student2065 enroll on waitlist of suggested topic', js: true do # login_as "student2064" - user = User.find_by(name: 'student2064') - login_as(user.name) + user = User.find_by(username: 'student2064') + login_as(user.username) visit '/student_task/list' expect(page).to have_content 'Assignment_suggest_topic' @@ -72,8 +72,8 @@ expect(page).to have_content 'Thank you for your suggestion' click_link('Logout') - user = User.find_by(name: 'instructor6') - login_as(user.name) + user = User.find_by(username: 'instructor6') + login_as(user.username) # instructor approve the suggestion topic visit '/suggestion/list?id=1&type=Assignment' @@ -88,8 +88,8 @@ # case 2 student already have topic switch to new topic # need two students one to be on the waitlist of previous suggested topic, # the other one (student2065) is holding it and suggest another topic and wish to switch to the new one - user = User.find_by(name: 'student2065') - login_as(user.name) + user = User.find_by(username: 'student2065') + login_as(user.username) visit '/student_task/list' click_link('Assignment_suggest_topic') click_link('Signup sheet') @@ -97,8 +97,8 @@ click_link('Logout') # log in student2064 - user = User.find_by(name: 'student2064') - login_as(user.name) + user = User.find_by(username: 'student2064') + login_as(user.username) visit '/student_task/list' click_link('Assignment_suggest_topic') expect(page).to have_content 'Suggest a topic' @@ -110,8 +110,8 @@ click_link('Logout') # login_as instructor6 to approve the 2nd suggested topic - user = User.find_by(name: 'instructor6') - login_as(user.name) + user = User.find_by(username: 'instructor6') + login_as(user.username) # instructor approve the suggestion topic visit '/tree_display/list' @@ -127,8 +127,8 @@ click_link('Logout') # login as student 2064 to switch to new approved topic - user = User.find_by(name: 'student2064') - login_as(user.name) + user = User.find_by(username: 'student2064') + login_as(user.username) visit '/student_task/list' click_link('Assignment_suggest_topic') click_link('Signup sheet') @@ -139,15 +139,15 @@ click_link('Logout') # login as student 2065 to see if it's holding the topic rather than on the wait list - user = User.find_by(name: 'student2065') - login_as(user.name) + user = User.find_by(username: 'student2065') + login_as(user.username) visit '/student_task/list' expect(page).to have_content 'suggested_topic' click_link('Logout') # login as studnet 2064 to see if it's already shifted to the new suggested topic - user = User.find_by(name: 'student2064') - login_as(user.name) + user = User.find_by(username: 'student2064') + login_as(user.username) visit '/student_task/list' expect(page).to have_content 'suggested_topic2_will_switch' click_link('Logout') @@ -159,8 +159,8 @@ ######################################## it 'student2065 hold suggest topic and suggest a new one, but wish to stay in the old topic', js: true do # login_as "student2065" - user = User.find_by(name: 'student2065') - login_as(user.name) + user = User.find_by(username: 'student2065') + login_as(user.username) visit '/student_task/list' expect(page).to have_content 'Assignment_suggest_topic' @@ -175,8 +175,8 @@ click_link('Logout') # login_as "instructor6" - user = User.find_by(name: 'instructor6') - login_as(user.name) + user = User.find_by(username: 'instructor6') + login_as(user.username) # instructor approve the suggestion topic # DUE date need to be added here @@ -191,8 +191,8 @@ # One team is holding a topic. They sent a suggestion for new topic ###################################### # login_as "student2065" - user = User.find_by(name: 'student2065') - login_as(user.name) + user = User.find_by(username: 'student2065') + login_as(user.username) visit '/student_task/list' expect(page).to have_content 'Assignment_suggest_topic' @@ -208,8 +208,8 @@ click_link('Logout') # login_as "instructor6" - user = User.find_by(name: 'instructor6') - login_as(user.name) + user = User.find_by(username: 'instructor6') + login_as(user.username) # instructor approve the suggestion topic visit '/tree_display/list' @@ -225,8 +225,8 @@ click_link('Logout') # login_as "student2065" - user = User.find_by(name: 'student2065') - login_as(user.name) + user = User.find_by(username: 'student2065') + login_as(user.username) visit '/student_task/list' expect(page).to have_content 'Assignment_suggest_topic' click_link('Assignment_suggest_topic') @@ -241,8 +241,8 @@ click_link('Logout') # login_as "student2064" - user = User.find_by(name: 'student2064') - login_as(user.name) + user = User.find_by(username: 'student2064') + login_as(user.username) visit '/student_task/list' expect(page).to have_content 'Assignment_suggest_topic' click_link('Assignment_suggest_topic') @@ -257,8 +257,8 @@ it 'professor could approve anonymous suggestion topic' do # login_as "student2064" - user = User.find_by(name: 'student2064') - login_as(user.name) + user = User.find_by(username: 'student2064') + login_as(user.username) visit '/student_task/list' expect(page).to have_content 'Assignment_suggest_topic' @@ -273,8 +273,8 @@ expect(page).to have_content 'You have submitted an anonymous suggestion.' click_link('Logout') - user = User.find_by(name: 'instructor6') - login_as(user.name) + user = User.find_by(username: 'instructor6') + login_as(user.username) # instructor approve the suggestion topic visit '/suggestion/list?id=1&type=Assignment' diff --git a/spec/features/versions_search_spec.rb b/spec/features/versions_search_spec.rb index f1d4986bd93..e7fdae40aac 100644 --- a/spec/features/versions_search_spec.rb +++ b/spec/features/versions_search_spec.rb @@ -2,7 +2,7 @@ it 'admin must be able to search logs' do admin = create(:admin, id: 5) user = admin - login_as(user.name) + login_as(user.username) visit '/versions/search' fill_in 'start_time', with: (Time.now.in_time_zone - 1.day).strftime('%Y/%m/%d %H:%M') fill_in 'end_time', with: (Time.now.in_time_zone + 10.days).strftime('%Y/%m/%d %H:%M') @@ -13,7 +13,7 @@ it 'super-admin must be able to search logs' do superadmin = create(:superadmin, id: 1) user = superadmin - login_as(user.name) + login_as(user.username) visit '/versions/search' fill_in 'start_time', with: (Time.now.in_time_zone - 10.days).strftime('%Y/%m/%d %H:%M') fill_in 'end_time', with: (Time.now.in_time_zone + 10.days).strftime('%Y/%m/%d %H:%M') @@ -37,7 +37,7 @@ it 'select type with datetimepicker' do admin = create(:admin, id: 5) user = admin - login_as(user.name) + login_as(user.username) visit '/versions/search' select('Node', from: 'post_item_type') fill_in 'start_time', with: (Time.now.in_time_zone + 1.day).strftime('%Y/%m/%d %H:%M') @@ -49,7 +49,7 @@ it 'select event with datetimepicker', js: true do admin = create(:admin, id: 5) user = admin - login_as(user.name) + login_as(user.username) visit '/versions/search' select('create', from: 'post_event') fill_in 'start_time', with: (Time.now.in_time_zone + 1.day).strftime('%Y/%m/%d %H:%M') diff --git a/spec/features/view_team_spec.rb b/spec/features/view_team_spec.rb index 11cbe8964cb..ac2dfbcd892 100644 --- a/spec/features/view_team_spec.rb +++ b/spec/features/view_team_spec.rb @@ -38,8 +38,8 @@ # User 3 navigates to the Your scores page def load_your_scores - login_as(User.where(role_id: 1).third.name) - expect(page).to have_content 'User: ' + User.where(role_id: 1).third.name + login_as(User.where(role_id: 1).third.username) + expect(page).to have_content 'User: ' + User.where(role_id: 1).third.username click_link 'Assignments' expect(page).to have_content 'TestAssignment' @@ -55,8 +55,8 @@ def load_your_scores # User 1 adds a review to Team 2 def add_review - login_as(User.where(role_id: 1).first.name) - expect(page).to have_content 'User: ' + User.where(role_id: 1).first.name + login_as(User.where(role_id: 1).first.username) + expect(page).to have_content 'User: ' + User.where(role_id: 1).first.username expect(page).to have_content 'TestAssignment' diff --git a/spec/helpers/answer_helper_spec.rb b/spec/helpers/answer_helper_spec.rb index f758fc045b9..286fe6310b3 100644 --- a/spec/helpers/answer_helper_spec.rb +++ b/spec/helpers/answer_helper_spec.rb @@ -20,7 +20,7 @@ @assignment_questionnaire1 = create(:assignment_questionnaire, id: 1, assignment_id: @assignment1.id, questionnaire_id: @questionnaire1.id, used_in_round: 1) @assignment_questionnaire2 = create(:assignment_questionnaire, id: 2, assignment_id: @assignment1.id, questionnaire_id: @questionnaire2.id, used_in_round: 2) @assignment_questionnaire3 = create(:assignment_questionnaire, id: 3, assignment_id: @assignment2.id, questionnaire_id: @questionnaire3.id, used_in_round: nil) - @user = create(:student, name: 'name', fullname: 'name') + @user = create(:student, username: 'name', fullname: 'name') @participant = create(:participant, user_id: @user.id, parent_id: @assignment1.id) @response_map = create(:review_response_map, reviewer: @participant, assignment: @assignment1) @response = create(:response, response_map: @response_map, created_at: '2019-11-01 23:30:00') @@ -31,8 +31,8 @@ context 'when the response is in reviewing period' do it 'deletes the answers' do allow(AnswerHelper).to receive(:log_answer_responses).with([@question.id], @questionnaire2.id).and_return([@answer.response_id]) - allow(AnswerHelper).to receive(:log_response_info).with([@answer.response_id]).and_return(@answer.response_id => { email: @user.email, answers: @answer.comments, name: @user.name, assignment_name: @assignment1.name }) - expect(AnswerHelper).to receive(:review_mailer).with(@user.email, @answer.comments, @user.name, @assignment1.name).and_return(true) + allow(AnswerHelper).to receive(:log_response_info).with([@answer.response_id]).and_return(@answer.response_id => { email: @user.email, answers: @answer.comments, name: @user.username, assignment_name: @assignment1.name }) + expect(AnswerHelper).to receive(:review_mailer).with(@user.email, @answer.comments, @user.username, @assignment1.name).and_return(true) expect(Answer.exists?(response_id: @answer.response_id)).to eql(true) # verify the answer exists before deleting AnswerHelper.delete_existing_responses([@question.id], @questionnaire2.id) expect(Answer.exists?(response_id: @answer.response_id)).to eql(false) @@ -50,7 +50,7 @@ describe '#log_response_info' do it 'logs info from each response_id to be used in answer deletion' do AnswerHelper.log_response_info([@answer.response_id]) - expect(AnswerHelper.log_response_info([@answer.response_id])).to eql(1 => { email: 'expertiza@mailinator.com', answers: 'comment', name: 'name', assignment_name: 'name1' }) + expect(AnswerHelper.log_response_info([@answer.response_id])).to eql(1 => { email: 'expertiza@mailinator.com', answers: 'comment', username: 'name', assignment_name: 'name1' }) end end @@ -60,14 +60,14 @@ to: @user.email, subject: 'Expertiza Notification: The review rubric has been changed, please re-attempt the review', body: { - name: @user.name, + name: @user.username, assignment_name: @assignment1.name, answers: @answer.comments } ).and_return(@mail) allow(@mail).to receive(:deliver_now) expect(Mailer).to receive(:notify_review_rubric_change).once - AnswerHelper.review_mailer(@user.email, @answer.comments, @user.name, @assignment1.name) + AnswerHelper.review_mailer(@user.email, @answer.comments, @user.username, @assignment1.name) end end diff --git a/spec/helpers/authorization_helper_spec.rb b/spec/helpers/authorization_helper_spec.rb index 4ac98c7a06a..33d218289d5 100644 --- a/spec/helpers/authorization_helper_spec.rb +++ b/spec/helpers/authorization_helper_spec.rb @@ -619,8 +619,8 @@ end it 'returns false if the assignment has some other instructor' do - instructor1 = create(:instructor, name: 'test_instructor_1') - instructor2 = create(:instructor, name: 'test_instructor_2') + instructor1 = create(:instructor, username: 'test_instructor_1') + instructor2 = create(:instructor, username: 'test_instructor_2') assignment = create(:assignment, instructor_id: instructor1.id) stub_current_user(instructor2, instructor2.role.name, instructor2.role) expect(current_user_instructs_assignment?(assignment)).to be false @@ -633,8 +633,8 @@ end it 'returns true if the course associated with the assignment is instructed by the current user' do - instructor1 = create(:instructor, name: 'test_instructor_1') - instructor2 = create(:instructor, name: 'test_instructor_2') + instructor1 = create(:instructor, username: 'test_instructor_1') + instructor2 = create(:instructor, username: 'test_instructor_2') course = create(:course, instructor_id: instructor1.id) assignment = create(:assignment, instructor_id: instructor2.id, course_id: course.id) stub_current_user(instructor1, instructor1.role.name, instructor1.role) @@ -655,8 +655,8 @@ end it 'returns false if the current user and the given assignment are NOT associated by a TA mapping' do - ta1 = create(:teaching_assistant, name: 'test_ta_1') - ta2 = create(:teaching_assistant, name: 'test_ta_2') + ta1 = create(:teaching_assistant, username: 'test_ta_1') + ta2 = create(:teaching_assistant, username: 'test_ta_2') course = create(:course) assignment = create(:assignment, course_id: course.id) TaMapping.create(ta_id: ta1.id, course_id: course.id) diff --git a/spec/helpers/participants_helper_spec.rb b/spec/helpers/participants_helper_spec.rb index 2199dfceddc..4c64e4de6c7 100644 --- a/spec/helpers/participants_helper_spec.rb +++ b/spec/helpers/participants_helper_spec.rb @@ -9,7 +9,7 @@ allow(Role).to receive(:find_by).with({:name=>'Student'}).and_return(1) attribute = ParticipantsHelper.define_attributes(line_split,config) expect(attribute['role_id']).to eq(1) - expect(attribute['name']).to eq('Test1') + expect(attribute['username']).to eq('Test1') expect(attribute['fullname']).to eq('test2') expect(attribute['email']).to eq('test@ncsu.edu') expect(attribute['password'].length).to eq(8) @@ -23,14 +23,14 @@ describe '#create_new_user' do context 'when create_new_user is called' do #Checking if a user has een correctly created - let(:instructor1) { build(:instructor, id: 10, role_id: 3, parent_id: 3, name: 'Instructor1') } + let(:instructor1) { build(:instructor, id: 10, role_id: 3, parent_id: 3, username: 'Instructor1') } it 'returns correct user when create_new_user is called' do - attributes = {'role_id' => 1, 'name' => 'Test1', 'fullname' => 'test2', 'email' => 'test@ncsu.edu', 'email_on_submission' => 1, 'email_on_review' => 1, 'email_on_review_of_review' => 1} + attributes = {'role_id' => 1, 'username' => 'Test1', 'fullname' => 'test2', 'email' => 'test@ncsu.edu', 'email_on_submission' => 1, 'email_on_review' => 1, 'email_on_review_of_review' => 1} session = {user: instructor1} user = ParticipantsHelper.create_new_user(attributes, session) expect(user['role_id']).to eq(1) - expect(user['name']).to eq('Test1') + expect(user['username']).to eq('Test1') expect(user['fullname']).to eq('test2') expect(user['email']).to eq('test@ncsu.edu') expect(user['email_on_submission']).to eq(true) diff --git a/spec/helpers/review_mapping_helper_spec.rb b/spec/helpers/review_mapping_helper_spec.rb index 28a336a96db..8a0193f3d54 100644 --- a/spec/helpers/review_mapping_helper_spec.rb +++ b/spec/helpers/review_mapping_helper_spec.rb @@ -1004,7 +1004,7 @@ @assignment1 = create(:assignment, name: 'name1') @questionnaire = create(:questionnaire) @question = create(:question, questionnaire_id: @questionnaire.id) - @user = create(:student, name: 'name', fullname: 'name') + @user = create(:student, username: 'name', fullname: 'name') @participant = create(:participant, user_id: @user.id, parent_id: @assignment1.id) @response_map = create(:review_response_map, reviewer: @participant, assignment: @assignment1) @response = create(:response, response_map: @response_map, created_at: '2019-11-01 23:30:00') @@ -1022,7 +1022,7 @@ @assignment1 = create(:assignment, name: 'name1') @questionnaire = create(:questionnaire) @question = create(:question, questionnaire_id: @questionnaire.id) - @user = create(:student, name: 'name', fullname: 'name') + @user = create(:student, username: 'name', fullname: 'name') @participant = create(:participant, user_id: @user.id, parent_id: @assignment1.id) @response_map = create(:review_response_map, reviewer: @participant, assignment: @assignment1) @response = create(:response, response_map: @response_map, created_at: '2019-11-01 23:30:00') @@ -1042,7 +1042,7 @@ @assignment1 = create(:assignment, name: 'name1') @questionnaire = create(:questionnaire) @question = create(:question, questionnaire_id: @questionnaire.id) - @user = create(:student, name: 'name', fullname: 'name') + @user = create(:student, username: 'name', fullname: 'name') @participant = create(:participant, user_id: @user.id, parent_id: @assignment1.id) @response_map = create(:review_response_map, reviewer: @participant, assignment: @assignment1) @id = @assignment1.id @@ -1058,7 +1058,7 @@ @assignment1 = create(:assignment, name: 'name1') @questionnaire = create(:questionnaire) @question = create(:question, questionnaire_id: @questionnaire.id) - @user = create(:student, name: 'name', fullname: 'name') + @user = create(:student, username: 'name', fullname: 'name') @participant = create(:participant, user_id: @user.id, parent_id: @assignment1.id) @response_map = create(:review_response_map, reviewer: @participant, assignment: @assignment1) @id = @assignment1.id diff --git a/spec/lib/scoring_spec.rb b/spec/lib/scoring_spec.rb index 4587ca33915..a1152c31dfb 100644 --- a/spec/lib/scoring_spec.rb +++ b/spec/lib/scoring_spec.rb @@ -12,7 +12,7 @@ let(:signed_up_team) { build(:signed_up_team, team_id: contributor.id) } # ReviewResponseMap Spec Additions - let(:student) { build(:student, id: 1, name: 'name', fullname: 'no one', email: 'expertiza@mailinator.com') } + let(:student) { build(:student, id: 1, username: 'name', fullname: 'no one', email: 'expertiza@mailinator.com') } let(:participant) { build(:participant, id: 1, parent_id: 1, user: student) } let(:response3) { build(:response) } let(:question) { double('Question') } diff --git a/spec/models/administrator_spec.rb b/spec/models/administrator_spec.rb index 7c5b722f18b..a2dc878e9af 100644 --- a/spec/models/administrator_spec.rb +++ b/spec/models/administrator_spec.rb @@ -1,7 +1,7 @@ describe Administrator do describe 'class' do it 'creates a valid object' do - expect(Administrator.new(name: 'name', fullname: 'John Bumgardner', email: 'email@email.com')).to be_valid + expect(Administrator.new(username: 'name', fullname: 'John Bumgardner', email: 'email@email.com')).to be_valid end end end diff --git a/spec/models/answer_tag_spec.rb b/spec/models/answer_tag_spec.rb index 932bbef4fe1..1702ca1471a 100644 --- a/spec/models/answer_tag_spec.rb +++ b/spec/models/answer_tag_spec.rb @@ -10,7 +10,7 @@ let(:tag_prompt_cb) { TagPrompt.create id: 1, prompt: '??', desc: 'desc', control_type: 'checkbox' } let(:tag_deploy) { TagPromptDeployment.create id: 1, tag_prompt: tag_prompt, question_type: 'Criterion' } let(:tag_deploy_cb) { TagPromptDeployment.create id: 1, tag_prompt: tag_prompt_cb, question_type: 'Criterion' } - let(:user) { User.new name: 'abc', fullname: 'abc xyz', email: 'abcxyz@gmail.com', password: '12345678', password_confirmation: '12345678' } + let(:user) { User.new username: 'abc', fullname: 'abc xyz', email: 'abcxyz@gmail.com', password: '12345678', password_confirmation: '12345678' } it 'is invalid without valid attributes' do expect(AnswerTag.new).not_to be_valid diff --git a/spec/models/assignment_participant_spec.rb b/spec/models/assignment_participant_spec.rb index f60546a1e7c..3c3c064c510 100644 --- a/spec/models/assignment_participant_spec.rb +++ b/spec/models/assignment_participant_spec.rb @@ -156,7 +156,7 @@ ActionMailer::Base.deliveries.clear allow(ImportFileHelper).to receive(:define_attributes).with(row).and_return(attributes) allow(ImportFileHelper).to receive(:create_new_user) do - test_user = User.new(name: 'abc', fullname: 'abc bbc', email: 'abcbbc@gmail.com') + test_user = User.new(username: 'abc', fullname: 'abc bbc', email: 'abcbbc@gmail.com') test_user.id = 123 test_user.save! password = test_user.reset_password # the password is reset @@ -166,7 +166,7 @@ end # allow(ImportFileHelper).to receive(:create_new_user).with(attributes, {}).and_return() allow(Assignment).to receive(:find).with(1).and_return(assignment) - allow(User).to receive(:exists?).with(name: 'no one').and_return(false) + allow(User).to receive(:exists?).with(username: 'no one').and_return(false) allow(participant).to receive(:set_handle).and_return('handle') allow(AssignmentParticipant).to receive(:exists?).and_return(false) allow(AssignmentParticipant).to receive(:create).and_return(participant) @@ -213,7 +213,7 @@ describe '.export' do it 'exports all participants in current assignment' do allow(AssignmentParticipant).to receive_message_chain(:where, :find_each).with(parent_id: 1).with(no_args).and_yield(participant) - allow(participant).to receive(:user).and_return(build(:student, name: 'student2065', fullname: '2065, student')) + allow(participant).to receive(:user).and_return(build(:student, username: 'student2065', fullname: '2065, student')) options = { 'personal_details' => 'true', 'role' => 'true', 'handle' => 'true', 'parent' => 'true', 'email_options' => 'true' } expect(AssignmentParticipant.export([], 1, options)).to eq( [['student2065', @@ -230,7 +230,7 @@ end describe '#set_handle' do - let(:student) { build(:student, name: 'no one') } + let(:student) { build(:student, username: 'no one') } before(:each) do allow(participant).to receive(:user).and_return(student) end diff --git a/spec/models/assignment_spec.rb b/spec/models/assignment_spec.rb index 033df68b938..b759905d88f 100644 --- a/spec/models/assignment_spec.rb +++ b/spec/models/assignment_spec.rb @@ -1,7 +1,7 @@ describe Assignment do let(:assignment) { build(:assignment, id: 1, name: 'no assignment', participants: [participant], teams: [team], max_team_size: 2) } let(:instructor) { build(:instructor, id: 6) } - let(:student) { build(:student, id: 3, name: 'no one') } + let(:student) { build(:student, id: 3, username: 'no one') } let(:review_response_map) { build(:review_response_map, response: [response], reviewer: build(:participant), reviewee: build(:assignment_team)) } let(:teammate_review_response_map) { build(:review_response_map, type: 'TeammateReviewResponseMap') } let(:participant) { build(:participant, id: 1) } @@ -344,7 +344,7 @@ describe '#add_participant' do context 'when user is nil' do it 'raises an error' do - allow(User).to receive(:find_by).with(name: 'no one').and_return(nil) + allow(User).to receive(:find_by).with(username: 'no one').and_return(nil) allow_any_instance_of(Assignment).to receive(:url_for).with(controller: 'users', action: 'new').and_return('users/new/1') expect { assignment.add_participant('no one', nil, nil, nil, nil) }.to raise_error(RuntimeError, %r{a href='users/new/1'>create the user first}) end @@ -352,7 +352,7 @@ context 'when the user is already a participant of current assignment' do it 'raises an error' do - allow(User).to receive(:find_by).with(name: 'no one').and_return(student) + allow(User).to receive(:find_by).with(username: 'no one').and_return(student) allow(AssignmentParticipant).to receive(:find_by).with(parent_id: 1, user_id: 3).and_return(participant) expect { assignment.add_participant('no one', nil, nil, nil, nil) }.to raise_error(RuntimeError, /The user no one is already a participant/) end @@ -360,7 +360,7 @@ context 'when AssignmentParticipant was created successfully' do it 'returns true' do - allow(User).to receive(:find_by).with(name: 'no one').and_return(student) + allow(User).to receive(:find_by).with(username: 'no one').and_return(student) allow(AssignmentParticipant).to receive(:find_by).with(parent_id: 1, user_id: 3).and_return(nil) allow(AssignmentParticipant).to receive(:create).with(parent_id: 1, user_id: 3, permission_granted: 0, can_submit: true, can_review: true, can_take_quiz: false, can_mentor: false).and_return(participant) @@ -586,7 +586,7 @@ before(:each) do create(:assignment) create(:assignment_team, name: 'team1') - @student = create(:student, name: 'student1') + @student = create(:student, username: 'student1') create(:participant, user: @student) create(:questionnaire) create(:question) diff --git a/spec/models/assignment_survey_response_map_spec.rb b/spec/models/assignment_survey_response_map_spec.rb index 2473212c1bf..9c2541d3c9b 100644 --- a/spec/models/assignment_survey_response_map_spec.rb +++ b/spec/models/assignment_survey_response_map_spec.rb @@ -1,10 +1,10 @@ describe AssignmentSurveyResponseMap, type: :model do - let(:participant) { build(:participant, user_id: 1, user: build(:student, name: 'Jane', fullname: 'Doe, Jane', id: 1)) } + let(:participant) { build(:participant, user_id: 1, user: build(:student, username: 'Jane', fullname: 'Doe, Jane', id: 1)) } let(:assignment_questionnaire1) { build(:assignment_questionnaire, id: 1, assignment_id: 1, questionnaire_id: 1) } let(:previous_day) { (Time.now.getlocal - 1 * 86_400).strftime('%Y-%m-%d %H:%M:%S') } let(:next_day) { (Time.now.getlocal + 1 * 86_400).strftime('%Y-%m-%d %H:%M:%S') } let(:assignment) { build(:assignment, id: 1, name: 'Assignment1') } - let(:user) { build(:student, email: 'expertiza.debugging@gmail.com', name: 'Jane', fullname: 'Doe, Jane', id: 1) } + let(:user) { build(:student, email: 'expertiza.debugging@gmail.com', username: 'Jane', fullname: 'Doe, Jane', id: 1) } before(:each) do survey_deployment = AssignmentSurveyDeployment.new questionnaire_id: 1, start_date: previous_day, end_date: next_day, parent_id: '12345678', type: 'AssignmentSurveyDeployment' @assignment_survey_response_map = AssignmentSurveyResponseMap.new diff --git a/spec/models/authority_spec.rb b/spec/models/authority_spec.rb index 4562cdf6ae5..b5b7fdd35e4 100644 --- a/spec/models/authority_spec.rb +++ b/spec/models/authority_spec.rb @@ -1,5 +1,5 @@ describe Authority do - let(:user1) { create(:student, name: 'expertizauser', id: 1) } + let(:user1) { create(:student, username: 'expertizauser', id: 1) } let(:admin) { build(:admin) } describe '#initialize' do it 'sets the current user' do diff --git a/spec/models/bookmark_rating_spec.rb b/spec/models/bookmark_rating_spec.rb index ddd0aea0114..a88a71b1fc7 100644 --- a/spec/models/bookmark_rating_spec.rb +++ b/spec/models/bookmark_rating_spec.rb @@ -1,5 +1,5 @@ describe BookmarkRating do - let(:user1) { create(:student, name: 'expertizauser', id: 1) } + let(:user1) { create(:student, username: 'expertizauser', id: 1) } bookmark1 = nil before(:each) do diff --git a/spec/models/cake_spec.rb b/spec/models/cake_spec.rb index c0472a2a6d2..673a5be1f48 100644 --- a/spec/models/cake_spec.rb +++ b/spec/models/cake_spec.rb @@ -4,7 +4,7 @@ let(:answer) { Answer.new answer: 45 } let(:answer1) { Answer.new answer: 50 } let(:team) { build(:assignment_team, id: 1, name: 'no team', users: [user]) } - let(:user) { build(:student, id: 1, name: 'no name', fullname: 'no one', participants: [participant]) } + let(:user) { build(:student, id: 1, username: 'no name', fullname: 'no one', participants: [participant]) } let(:participant) { build(:participant, user_id: 1) } describe '#edit' do it 'returns the html ' do diff --git a/spec/models/collusion_cycle_spec.rb b/spec/models/collusion_cycle_spec.rb index bf51be42ec9..b44e8714144 100644 --- a/spec/models/collusion_cycle_spec.rb +++ b/spec/models/collusion_cycle_spec.rb @@ -12,7 +12,7 @@ let(:questionnaire) { build(:questionnaire, id: 1) } (1..4).each do |i| let("team#{i}".to_sym) { build(:assignment_team, id: i, name: "team#{i}", assignment: assignment) } - let("participant#{i}".to_sym) { build(:participant, id: i, user: build(:student, name: "stu#{i}"), assignment: assignment) } + let("participant#{i}".to_sym) { build(:participant, id: i, user: build(:student, username: "stu#{i}"), assignment: assignment) } end let(:response_1_2) { build(:response, id: 1) } let(:response_2_1) { build(:response, id: 2) } diff --git a/spec/models/course_analytic_spec.rb b/spec/models/course_analytic_spec.rb index 53a03110ad2..99e435a1900 100644 --- a/spec/models/course_analytic_spec.rb +++ b/spec/models/course_analytic_spec.rb @@ -12,9 +12,9 @@ def initialize(course, participants, assignments) describe CourseAnalytic do let(:course) { build(:course, id: 1, name: 'ECE517') } - let(:participant) { build(:participant, user: build(:student, name: 'Jane', fullname: 'Doe, Jane', id: 1)) } - let(:participant2) { build(:participant, user: build(:student, name: 'John', fullname: 'Doe, John', id: 2)) } - let(:participant3) { build(:participant, can_review: false, user: build(:student, name: 'King', fullname: 'Titan, King', id: 3)) } + let(:participant) { build(:participant, user: build(:student, username: 'Jane', fullname: 'Doe, Jane', id: 1)) } + let(:participant2) { build(:participant, user: build(:student, username: 'John', fullname: 'Doe, John', id: 2)) } + let(:participant3) { build(:participant, can_review: false, user: build(:student, username: 'King', fullname: 'Titan, King', id: 3)) } let(:assignment) { build(:assignment, id: 1, name: 'no assignment', participants: [participant], teams: [team]) } let(:assignment2) { build(:assignment, id: 2, name: 'no assignment', participants: [participant], teams: [team]) } let(:assignment3) { build(:assignment, id: 3, name: 'no assignment', participants: [participant], teams: [team]) } diff --git a/spec/models/course_node_spec.rb b/spec/models/course_node_spec.rb index caf9e8a7f7c..bad4fc64dda 100644 --- a/spec/models/course_node_spec.rb +++ b/spec/models/course_node_spec.rb @@ -1,7 +1,7 @@ describe CourseNode do let(:course) { build(:course, id: 1, name: 'ECE517') } let(:course_node) { build(:course_node, id: 1) } - let(:user1) { User.new name: 'abc', fullname: 'abc bbc', email: 'abcbbc@gmail.com', password: '123456789', password_confirmation: '123456789' } + let(:user1) { User.new username: 'abc', fullname: 'abc bbc', email: 'abcbbc@gmail.com', password: '123456789', password_confirmation: '123456789' } let(:assignment) { build(:assignment, id: 1) } before(:each) do course_node.node_object_id = 1 diff --git a/spec/models/course_spec.rb b/spec/models/course_spec.rb index 4b35aa439cf..52bdc11c55f 100644 --- a/spec/models/course_spec.rb +++ b/spec/models/course_spec.rb @@ -3,10 +3,10 @@ let(:course_team1) { build(:course_team, id: 1) } let(:course_team2) { build(:course_team, id: 2) } let(:instructor) { build(:instructor, id: 6) } - let(:user1) { User.new name: 'abc', fullname: 'abc bbc', email: 'abcbbc@gmail.com', password: '123456789', password_confirmation: '123456789' } - let(:user2) { User.new name: 'bcd', fullname: 'cbd ccd', email: 'bcdccd@gmail.com', password: '123456789', password_confirmation: '123456789' } - let(:participant) { build(:participant, user: build(:student, name: 'Jane', fullname: 'Doe, Jane', id: 1)) } - let(:participant2) { build(:participant, user: build(:student, name: 'John', fullname: 'Doe, John', id: 2)) } + let(:user1) { User.new username: 'abc', fullname: 'abc bbc', email: 'abcbbc@gmail.com', password: '123456789', password_confirmation: '123456789' } + let(:user2) { User.new username: 'bcd', fullname: 'cbd ccd', email: 'bcdccd@gmail.com', password: '123456789', password_confirmation: '123456789' } + let(:participant) { build(:participant, user: build(:student, username: 'Jane', fullname: 'Doe, Jane', id: 1)) } + let(:participant2) { build(:participant, user: build(:student, username: 'John', fullname: 'Doe, John', id: 2)) } let(:assignment) { build(:assignment, id: 1, name: 'no assgt') } describe 'validations' do @@ -59,14 +59,14 @@ describe '#add_participant' do context 'when the user cannot be found' do it 'returns an error and requests that the user creates a user with the username' do - allow(User).to receive(:find_by).with(name: 'bcd').and_return(nil) + allow(User).to receive(:find_by).with(username: 'bcd').and_return(nil) allow(course).to receive(:url_for).and_return('users/new') expect { course.add_participant('bcd') }.to raise_error(RuntimeError) end end context 'if the user is already added to the course' do it 'returns an error that the user is already a participant' do - allow(User).to receive(:find_by).with(name: 'abc').and_return(user1) + allow(User).to receive(:find_by).with(username: 'abc').and_return(user1) allow(user1).to receive(:id).and_return(1) allow(CourseParticipant).to receive(:where).with(parent_id: 1, user_id: 1).and_return([participant]) expect { course.add_participant('abc') }.to raise_error('The user abc is already a participant.') @@ -74,7 +74,7 @@ end context 'the user can be added successfully' do it 'returns a participant to the course' do - allow(User).to receive(:find_by).with(name: 'abc').and_return(user1) + allow(User).to receive(:find_by).with(username: 'abc').and_return(user1) allow(user1).to receive(:id).and_return(1) allow(CourseParticipant).to receive(:where).with(parent_id: 1, user_id: 1).and_return([nil]) allow(CourseParticipant).to receive(:create).with(parent_id: 1, user_id: 1, permission_granted: 0).and_return(participant) diff --git a/spec/models/course_survey_response_map_spec.rb b/spec/models/course_survey_response_map_spec.rb index 79f7fde0659..2f2cc9f9bb3 100644 --- a/spec/models/course_survey_response_map_spec.rb +++ b/spec/models/course_survey_response_map_spec.rb @@ -1,9 +1,9 @@ describe CourseSurveyResponseMap do - let(:participant) { build(:participant, user_id: 1, user: build(:student, name: 'Jane', fullname: 'Doe, Jane', id: 1)) } + let(:participant) { build(:participant, user_id: 1, user: build(:student, username: 'Jane', fullname: 'Doe, Jane', id: 1)) } let(:course_survey_questionnaire) { CourseSurveyQuestionnaire.new id: 985, name: 'course_survey', private: 0, min_question_score: 0, max_question_score: 10, instructor_id: 1234 } let(:previous_day) { (Time.now.getlocal - 1 * 86_400).strftime('%Y-%m-%d %H:%M:%S') } let(:next_day) { (Time.now.getlocal + 1 * 86_400).strftime('%Y-%m-%d %H:%M:%S') } - let(:user) { build(:student, email: 'expertiza.debugging@gmail.com', name: 'Jane', fullname: 'Doe, Jane', id: 1) } + let(:user) { build(:student, email: 'expertiza.debugging@gmail.com', username: 'Jane', fullname: 'Doe, Jane', id: 1) } let(:course) { build(:course, id: 1, name: 'ECE517') } before(:each) do survey_deployment = CourseSurveyDeployment.new questionnaire_id: 985, start_date: previous_day, end_date: next_day, parent_id: '12345678', type: 'CourseSurveyDeployment' diff --git a/spec/models/course_team_spec.rb b/spec/models/course_team_spec.rb index d7406310b55..78691622040 100644 --- a/spec/models/course_team_spec.rb +++ b/spec/models/course_team_spec.rb @@ -1,6 +1,6 @@ describe 'CourseTeam' do let(:course_team1) { build(:course_team, id: 1, name: 'no team') } - let(:user2) { build(:student, id: 2, name: 'no name') } + let(:user2) { build(:student, id: 2, username: 'no name') } let(:participant) { build(:participant, user: user2) } let(:course) { build(:course, id: 1, name: 'ECE517') } let(:team_user) { build(:team_user, id: 1, user: user2) } diff --git a/spec/models/duty_spec.rb b/spec/models/duty_spec.rb index 9a01bc75079..726e1716531 100644 --- a/spec/models/duty_spec.rb +++ b/spec/models/duty_spec.rb @@ -3,9 +3,9 @@ let(:participant) { build(:participant, id: 1, user_id: 1) } let(:participant2) { build(:participant, id: 2, user_id: 2) } let(:participant3) { build(:participant, id: 3, user_id: 3) } - let(:user) { build(:student, id: 1, name: 'no name', fullname: 'no one', participants: [participant]) } - let(:user2) { build(:student, id: 2, name: 'no name2', fullname: 'no one2', participants: [participant2]) } - let(:user3) { build(:student, id: 3, name: 'no name3', fullname: 'no one3', participants: [participant3]) } + let(:user) { build(:student, id: 1, username: 'no name', fullname: 'no one', participants: [participant]) } + let(:user2) { build(:student, id: 2, username: 'no name2', fullname: 'no one2', participants: [participant2]) } + let(:user3) { build(:student, id: 3, username: 'no name3', fullname: 'no one3', participants: [participant3]) } let(:team1) { build(:assignment_team, id: 1, name: 'no team', users: [user, user2, user3]) } let(:sample_duty_taken) { build(:duty, id: 1, name: 'Developer', max_members_for_duty: 1, assignment_id: 1) } diff --git a/spec/models/feedback_response_map_spec.rb b/spec/models/feedback_response_map_spec.rb index 79039b10ec4..97afa0a4d6a 100644 --- a/spec/models/feedback_response_map_spec.rb +++ b/spec/models/feedback_response_map_spec.rb @@ -9,7 +9,7 @@ let(:review_response_map) { build(:review_response_map, id: 2, assignment: assignment, reviewer: participant, reviewee: team) } let(:answer) { Answer.new(answer: 1, comments: 'Answer text', question_id: 1) } let(:response) { build(:response, id: 1, map_id: 1, response_map: review_response_map, scores: [answer]) } - let(:user1) { User.new name: 'abc', fullname: 'abc bbc', email: 'abcbbc@gmail.com', password: '123456789', password_confirmation: '123456789' } + let(:user1) { User.new username: 'abc', fullname: 'abc bbc', email: 'abcbbc@gmail.com', password: '123456789', password_confirmation: '123456789' } before(:each) do questionnaires = [questionnaire1, questionnaire2] allow(feedback_response_map).to receive(:reviewee).and_return(participant) diff --git a/spec/models/instructor_spec.rb b/spec/models/instructor_spec.rb index 607b063936c..c104464cb1a 100644 --- a/spec/models/instructor_spec.rb +++ b/spec/models/instructor_spec.rb @@ -5,8 +5,8 @@ let(:participant2) { build(:participant, id: 2) } let(:team) { build(:assignment_team, id: 1, name: 'no team') } let(:course) { build(:course) } - let(:user1) { User.new name: 'abc', fullname: 'abc bbc', email: 'abcbbc@gmail.com', password: '123456789', password_confirmation: '123456789' } - let(:user2) { User.new name: 'abc', fullname: 'abc bbc', email: 'abcbbe@gmail.com', password: '123456789', password_confirmation: '123456789' } + let(:user1) { User.new username: 'abc', fullname: 'abc bbc', email: 'abcbbc@gmail.com', password: '123456789', password_confirmation: '123456789' } + let(:user2) { User.new username: 'abc', fullname: 'abc bbc', email: 'abcbbe@gmail.com', password: '123456789', password_confirmation: '123456789' } let(:ta_mapping1) { TaMapping.new } let(:ta_mapping2) { TaMapping.new } before(:each) do diff --git a/spec/models/lock_spec.rb b/spec/models/lock_spec.rb index 9f929d9b323..441f9f7b034 100644 --- a/spec/models/lock_spec.rb +++ b/spec/models/lock_spec.rb @@ -7,10 +7,10 @@ before(:each) do # I was unable to use regular create! calls for user. # I think this might be because the writers of user.rb overrode User.initialize - @smyoder = User.new(name: 'smyoder', fullname: 'John Bumgardner', email: 'smyoder@ncsu.edu') + @smyoder = User.new(username: 'smyoder', fullname: 'John Bumgardner', email: 'smyoder@ncsu.edu') @smyoder.save! - @smyoder1 = User.new(name: 'smyoder1', fullname: 'John Bumgardner', email: 'smyoder1@ncsu.edu') + @smyoder1 = User.new(username: 'smyoder1', fullname: 'John Bumgardner', email: 'smyoder1@ncsu.edu') @smyoder1.save! @response = Response.create!(round: 1) end diff --git a/spec/models/mentor_management_spec.rb b/spec/models/mentor_management_spec.rb index 1a818eafdb4..ced77d3ba69 100644 --- a/spec/models/mentor_management_spec.rb +++ b/spec/models/mentor_management_spec.rb @@ -356,7 +356,7 @@ # Test case for when mentor_ids is not empty a = FactoryBot.create(:assignment, id: 997, directory_path: 'A2', auto_assign_mentor: true) # Create mentors for this assignment - ta1 = FactoryBot.create(:teaching_assistant, name: 'ta1', id: 1002) + ta1 = FactoryBot.create(:teaching_assistant, username: 'ta1', id: 1002) FactoryBot.create(:participant, id: 1001, user_id: 1002, parent_id: a.id, duty: Participant::DUTY_MENTOR) # Assign a mentor to a team allow(Team).to receive(:find).with(team.id).and_return(team) diff --git a/spec/models/metareview_response_map_spec.rb b/spec/models/metareview_response_map_spec.rb index 571450b0e84..0267d412897 100644 --- a/spec/models/metareview_response_map_spec.rb +++ b/spec/models/metareview_response_map_spec.rb @@ -24,9 +24,9 @@ let(:response2) { build(:response, id: 3, map_id: 1, round: nil, response_map: review_response_map, is_submitted: true) } let(:response3) { build(:response) } let(:metareview_response_map) { build(:meta_review_response_map, review_mapping: review_response_map) } - let(:student) { build(:student, id: 1, name: 'name', fullname: 'no one', email: 'expertiza@mailinator.com') } - let(:student1) { build(:student, id: 2, name: 'name1', fullname: 'no one', email: 'expertiza@mailinator.com') } - let(:student2) { build(:student, id: 3, name: 'name2', fullname: 'no one', email: 'expertiza@mailinator.com') } + let(:student) { build(:student, id: 1, username: 'name', fullname: 'no one', email: 'expertiza@mailinator.com') } + let(:student1) { build(:student, id: 2, username: 'name1', fullname: 'no one', email: 'expertiza@mailinator.com') } + let(:student2) { build(:student, id: 3, username: 'name2', fullname: 'no one', email: 'expertiza@mailinator.com') } let(:assignment_questionnaire1) { build(:assignment_questionnaire, id: 1, assignment_id: 1, questionnaire_id: 1) } let(:assignment_questionnaire2) { build(:assignment_questionnaire, id: 2, assignment_id: 1, questionnaire_id: 2) } let(:questionnaire1) { build(:questionnaire, type: 'ReviewQuestionnaire') } @@ -104,18 +104,18 @@ expect { MetareviewResponseMap.import(row_hash, session, 1) }.to raise_error(ArgumentError, 'Not enough items. The string should contain: Author, Reviewer, ReviewOfReviewer1 <, ..., ReviewerOfReviewerN>') # when reviewee user doesn't exist row_hash = { reviewee: 'name', metareviewers: ['name1'], reviewer: 'name1' } - allow(User).to receive(:find_by).with(name: 'name1').and_return(student) + allow(User).to receive(:find_by).with(username: 'name1').and_return(student) allow(AssignmentParticipant).to receive(:find_by).with(user_id: 1, parent_id: 1).and_return(nil) expect { MetareviewResponseMap.import(row_hash, session, 1) }.to raise_error(ImportError, 'Contributor, ' + row_hash[:reviewee].to_s + ', was not found.') # when a metareview response map is created - allow(User).to receive(:find_by).with(name: 'name2').and_return(student2) + allow(User).to receive(:find_by).with(username: 'name2').and_return(student2) allow(AssignmentParticipant).to receive(:where).with(user_id: 3, parent_id: 1).and_return([participant]) allow(AssignmentTeam).to receive(:where).with(name: 'name', parent_id: 1).and_return([team]) allow(AssignmentParticipant).to receive(:where).with(user_id: 1, parent_id: 1).and_return([student]) row_hash = { reviewee: 'name', metareviewers: ['name1'], reviewer: 'name2' } expect { MetareviewResponseMap.import(row_hash, session, 1).to eq(metareview_response_map) } ## when reviewer user doesn't exist - allow(User).to receive(:find_by).with(name: 'name2').and_return(student2) + allow(User).to receive(:find_by).with(username: 'name2').and_return(student2) allow(AssignmentParticipant).to receive(:where).with(user_id: 3, parent_id: 1).and_return([participant]) allow(AssignmentTeam).to receive(:where).with(name: 'name', parent_id: 1).and_return([team]) allow(AssignmentParticipant).to receive(:where).with(user_id: 1, parent_id: 1).and_return(nil) diff --git a/spec/models/participant_spec.rb b/spec/models/participant_spec.rb index 3a5bdc4291a..ebb358fe350 100644 --- a/spec/models/participant_spec.rb +++ b/spec/models/participant_spec.rb @@ -1,11 +1,11 @@ describe Participant do let(:team) { build(:assignment_team, id: 1, name: 'myTeam') } - let(:user) { build(:student, id: 4, name: 'no name', fullname: 'no two') } + let(:user) { build(:student, id: 4, username: 'no name', fullname: 'no two') } let(:team_user) { build(:team_user, id: 1, user: user, team: team) } let(:topic) { build(:topic) } - let(:participant) { build(:participant, user: build(:student, name: 'Jane', fullname: 'Doe, Jane', id: 1)) } - let(:participant2) { build(:participant, user: build(:student, name: 'John', fullname: 'Doe, John', id: 2)) } - let(:participant3) { build(:participant, can_review: false, user: build(:student, name: 'King', fullname: 'Titan, King', id: 3)) } + let(:participant) { build(:participant, user: build(:student, username: 'Jane', fullname: 'Doe, Jane', id: 1)) } + let(:participant2) { build(:participant, user: build(:student, username: 'John', fullname: 'Doe, John', id: 2)) } + let(:participant3) { build(:participant, can_review: false, user: build(:student, username: 'King', fullname: 'Titan, King', id: 3)) } let(:participant4) { Participant.new } let(:assignment) { build(:assignment, id: 1, name: 'no assgt') } let(:participant5) { build(:participant, user: user, assignment: assignment) } @@ -38,7 +38,7 @@ end describe '#name' do - it 'returns the name of the user' do + it 'returns the username of the user' do expect(participant.name).to eq('Jane') end end diff --git a/spec/models/quiz_assignment_spec.rb b/spec/models/quiz_assignment_spec.rb index d45395f2a69..866737eb91e 100644 --- a/spec/models/quiz_assignment_spec.rb +++ b/spec/models/quiz_assignment_spec.rb @@ -1,7 +1,7 @@ describe QuizAssignment do let(:assignment) { build(:assignment, id: 1, name: 'no assignment', participants: [participant], teams: [team]) } let(:instructor) { build(:instructor, id: 6) } - let(:student) { build(:student, id: 3, name: 'no one') } + let(:student) { build(:student, id: 3, username: 'no one') } let(:participant) { build(:participant, id: 1) } let(:team) { build(:assignment_team, id: 1, parent_id: 1) } let(:questionnaire1) { build(:questionnaire, id: 1, type: 'ReviewQuestionnaire') } diff --git a/spec/models/response_map_spec.rb b/spec/models/response_map_spec.rb index bcfc7648226..8102c923927 100644 --- a/spec/models/response_map_spec.rb +++ b/spec/models/response_map_spec.rb @@ -5,9 +5,9 @@ let(:participant) { build(:participant, id: 1, parent_id: 1, user: student) } let(:participant1) { build(:participant, id: 2, parent_id: 2, user: student1) } let(:participant2) { build(:participant, id: 3, parent_id: 3, user: student2) } - let(:student) { build(:student, id: 1, name: 'name', fullname: 'no one', email: 'expertiza@mailinator.com') } - let(:student1) { build(:student, id: 2, name: 'name1', fullname: 'no one', email: 'expertiza@mailinator.com') } - let(:student2) { build(:student, id: 3, name: 'name2', fullname: 'no one', email: 'expertiza@mailinator.com') } + let(:student) { build(:student, id: 1, username: 'name', fullname: 'no one', email: 'expertiza@mailinator.com') } + let(:student1) { build(:student, id: 2, username: 'name1', fullname: 'no one', email: 'expertiza@mailinator.com') } + let(:student2) { build(:student, id: 3, username: 'name2', fullname: 'no one', email: 'expertiza@mailinator.com') } let(:assignment) { build(:assignment, id: 1, name: 'Test Assgt', rounds_of_reviews: 2) } let(:assignment1) { build(:assignment, id: 2, name: 'Test Assgt2', rounds_of_reviews: 2) } diff --git a/spec/models/response_spec.rb b/spec/models/response_spec.rb index a6fb704ca8a..e46cdc94041 100644 --- a/spec/models/response_spec.rb +++ b/spec/models/response_spec.rb @@ -1,6 +1,6 @@ describe Response do - let(:user) { build(:student, id: 1, role_id: 1, name: 'no name', fullname: 'no one') } - let(:user2) { build(:student, id: 2, role_id: 2, name: 'no name2', fullname: 'no one2') } + let(:user) { build(:student, id: 1, role_id: 1, username: 'no name', fullname: 'no one') } + let(:user2) { build(:student, id: 2, role_id: 2, username: 'no name2', fullname: 'no one2') } let(:participant) { build(:participant, id: 1, parent_id: 1, user: user) } let(:participant2) { build(:participant, id: 2, parent_id: 2, user: user2) } let(:assignment) { build(:assignment, id: 1, name: 'Test Assgt') } diff --git a/spec/models/review_bid_spec.rb b/spec/models/review_bid_spec.rb index 7f0a7e7b28f..7ecda347fec 100644 --- a/spec/models/review_bid_spec.rb +++ b/spec/models/review_bid_spec.rb @@ -1,7 +1,7 @@ describe ReviewBid do let(:bid1) { build(:review_bid, priority: 3, participant_id: 7601, signuptopic_id: 123, assignment_id: 2085, updated_at: '2018-01-01 00:00:00') } let(:bid2) { build(:review_bid, priority: 2, participant_id: '7602', signuptopic_id: 124, assignment_id: 2086) } - let(:student) { build(:student, id: 1, name: 'name', fullname: 'no one', email: 'expertiza@mailinator.com') } + let(:student) { build(:student, id: 1, username: 'name', fullname: 'no one', email: 'expertiza@mailinator.com') } let(:participant) { build(:participant, id: 1, parent_id: 1, user: student, assignment: assignment1) } let(:topic) { build(:topic, id: 1, topic_name: 'New Topic') } let(:assignment1) { build(:assignment, id: 2, name: 'Test Assgt', rounds_of_reviews: 1) } diff --git a/spec/models/review_response_map_spec.rb b/spec/models/review_response_map_spec.rb index efc6fc6b956..da88716371d 100755 --- a/spec/models/review_response_map_spec.rb +++ b/spec/models/review_response_map_spec.rb @@ -24,8 +24,8 @@ let(:response2) { build(:response, id: 3, map_id: 1, round: nil, response_map: review_response_map, is_submitted: true) } let(:response3) { build(:response) } let(:metareview_response_map) { build(:meta_review_response_map, reviewed_object_id: 1) } - let(:student) { build(:student, id: 1, name: 'name', fullname: 'no one', email: 'expertiza@mailinator.com') } - let(:student1) { build(:student, id: 2, name: 'name1', fullname: 'no one', email: 'expertiza@mailinator.com') } + let(:student) { build(:student, id: 1, username: 'name', fullname: 'no one', email: 'expertiza@mailinator.com') } + let(:student1) { build(:student, id: 2, username: 'name1', fullname: 'no one', email: 'expertiza@mailinator.com') } let(:assignment_questionnaire1) { build(:assignment_questionnaire, id: 1, assignment_id: 1, questionnaire_id: 1) } let(:assignment_questionnaire2) { build(:assignment_questionnaire, id: 2, assignment_id: 1, questionnaire_id: 2) } let(:questionnaire1) { build(:questionnaire, type: 'ReviewQuestionnaire') } @@ -139,17 +139,17 @@ allow(User).to receive(:find_by).and_return(nil) expect { ReviewResponseMap.import(row_hash, session, 1) }.to raise_error(ArgumentError, 'Cannot find reviewee user.') # when reviewee user exists but reviewee user is not a participant in this assignment - allow(User).to receive(:find_by).with(name: 'name').and_return(student) + allow(User).to receive(:find_by).with(username: 'name').and_return(student) allow(AssignmentParticipant).to receive(:find_by).with(user_id: 1, parent_id: 1).and_return(nil) expect { ReviewResponseMap.import(row_hash, session, 1) }.to raise_error(ArgumentError, 'Reviewee user is not a participant in this assignment.') # when reviewee user exists and reviewee user is a participant in this assignment allow(AssignmentParticipant).to receive(:find_by).with(user_id: 1, parent_id: 1).and_return(participant) allow(AssignmentTeam).to receive(:team).with(participant).and_return(team) ## when reviewer user doesn't exist - allow(User).to receive(:find_by).with(name: 'name1').and_return(nil) + allow(User).to receive(:find_by).with(username: 'name1').and_return(nil) expect { ReviewResponseMap.import(row_hash, session, 1) }.to raise_error(ArgumentError, 'Cannot find reviewer user.') ## when reviewer user exist - allow(User).to receive(:find_by).with(name: 'name1').and_return(student1) + allow(User).to receive(:find_by).with(username: 'name1').and_return(student1) ### when reviewer user is not a participant in this assignment. allow(AssignmentParticipant).to receive(:find_by).with(user_id: 2, parent_id: 1).and_return(nil) expect { ReviewResponseMap.import(row_hash, session, 1) }.to raise_error(ArgumentError, 'Reviewer user is not a participant in this assignment.') @@ -166,7 +166,7 @@ allow(TeamsUser).to receive(:create).with(team_id: 1, user_id: 1).and_return(double('teams_users', id: 1, team_id: 1, user_id: 1)) allow(TeamNode).to receive(:create).with(parent_id: assignment_id, node_object_id: 1).and_return(double('team_node', id: 1, parent_id: 1, node_object_id: 1)) allow(TeamUserNode).to receive(:create).with(parent_id: 1, node_object_id: 1).and_return(double('team_user_node', id: 1, parent_id: 1, node_object_id: 1)) - allow(User).to receive(:find_by).with(name: 'name1').and_return(student1) + allow(User).to receive(:find_by).with(username: 'name1').and_return(student1) allow(AssignmentParticipant).to receive(:find_by).with(user_id: 2, parent_id: 1).and_return(participant1) allow(ReviewResponseMap).to receive(:find_or_create_by) .with(reviewed_object_id: 1, reviewer_id: 1, reviewee_id: 1, calibrate_to: false).and_return(review_response_map) diff --git a/spec/models/sign_up_topic_spec.rb b/spec/models/sign_up_topic_spec.rb index 367f206fab5..f60fe19e0dd 100755 --- a/spec/models/sign_up_topic_spec.rb +++ b/spec/models/sign_up_topic_spec.rb @@ -4,7 +4,7 @@ let(:signed_up_team) { build(:signed_up_team) } let(:team) { create(:assignment_team, id: 1, name: 'team 1', users: [user, user2]) } let(:user) { create(:student) } - let(:user2) { create(:student, name: 'qwertyui', id: 5) } + let(:user2) { create(:student, username: 'qwertyui', id: 5) } describe '.import' do @@ -215,7 +215,7 @@ describe '#reassign_topic' do let(:instructor) do User.create!( - name: 'Instructor', + username: 'Instructor', fullname: 'Full', # Ensure this matches the expected format if there are specific validations. email: 'instructor@example.com', # Provide a valid email format. password: 'securepassword', # Assume a password is required for user creation. diff --git a/spec/models/signed_up_team_spec.rb b/spec/models/signed_up_team_spec.rb index e0742f24c08..88b01ab3e12 100644 --- a/spec/models/signed_up_team_spec.rb +++ b/spec/models/signed_up_team_spec.rb @@ -4,10 +4,10 @@ let(:topic) { build(:topic) } let(:team) { create(:assignment_team, id: 1, name: 'team 1', users: [user, user2]) } let(:user) { create(:student) } - let(:user2) { create(:student, name: 'qwertyui', id: 5) } + let(:user2) { create(:student, username: 'qwertyui', id: 5) } describe '.drop_signup_record' do - let(:instructor) { User.create!(name: 'Instructor', fullname: 'FullInstructor', email: 'instructor@example.com', password: 'securepassword', password_confirmation: 'securepassword') } + let(:instructor) { User.create!(username: 'Instructor', fullname: 'FullInstructor', email: 'instructor@example.com', password: 'securepassword', password_confirmation: 'securepassword') } let(:assignment) { Assignment.create!(name: 'Test Assignment', instructor_id: instructor.id, directory_path: 'test/path') } let(:topic) { SignUpTopic.create!(topic_name: 'Sample Topic', assignment: assignment) } let(:team) { Team.create!(name: 'Sample Team') } diff --git a/spec/models/student_task_spec.rb b/spec/models/student_task_spec.rb index 2988b1f8419..14a659b392b 100644 --- a/spec/models/student_task_spec.rb +++ b/spec/models/student_task_spec.rb @@ -3,8 +3,8 @@ let(:participant) { build(:participant, id: 1, user_id: user.id, parent_id: assignment.id) } let(:participant2) { build(:participant, id: 2, user_id: user2.id, parent_id: assignment.id) } let(:user) { create(:student) } - let(:user2) { create(:student, name: 'qwertyui', id: 5) } - let(:user3) { create(:student, name: 'qwertyui1234', id: 6) } + let(:user2) { create(:student, username: 'qwertyui', id: 5) } + let(:user3) { create(:student, username: 'qwertyui1234', id: 6) } let(:course) { build(:course) } let(:assignment) { build(:assignment, name: 'assignment', directory_path: 'assignment') } let(:assignment2) { build(:assignment, name: 'assignment2', directory_path: 'assignment2') } diff --git a/spec/models/super_administrator_spec.rb b/spec/models/super_administrator_spec.rb index 638357eac1c..4546a77c4a4 100644 --- a/spec/models/super_administrator_spec.rb +++ b/spec/models/super_administrator_spec.rb @@ -1,6 +1,6 @@ describe SuperAdministrator do - let(:user1) { User.new name: 'abc', fullname: 'abc bbc', email: 'abcbbc@gmail.com', password: '123456789', password_confirmation: '123456789' } - let(:user2) { User.new name: 'abc', fullname: 'abc bbc', email: 'abcbbe@gmail.com', password: '123456789', password_confirmation: '123456789' } + let(:user1) { User.new username: 'abc', fullname: 'abc bbc', email: 'abcbbc@gmail.com', password: '123456789', password_confirmation: '123456789' } + let(:user2) { User.new username: 'abc', fullname: 'abc bbc', email: 'abcbbe@gmail.com', password: '123456789', password_confirmation: '123456789' } let(:superadmin) { build(:superadmin) } describe '#get_user_list' do it 'should return a list of all users in the system' do diff --git a/spec/models/ta_spec.rb b/spec/models/ta_spec.rb index 87551feaa19..2dfa15aaf03 100644 --- a/spec/models/ta_spec.rb +++ b/spec/models/ta_spec.rb @@ -6,7 +6,7 @@ let(:assignment) { build(:assignment, id: 1, name: 'no assignment', participants: [participant], teams: [team]) } let(:participant) { build(:participant, id: 1) } let(:team) { build(:assignment_team, id: 1, name: 'no team') } - let(:user) { build(:student, id: 4, name: 'no name', fullname: 'no two') } + let(:user) { build(:student, id: 4, username: 'no name', fullname: 'no two') } describe '#teaching_assistant?' do it 'returns true for a teaching assistant' do diff --git a/spec/models/team_spec.rb b/spec/models/team_spec.rb index 146d3e6bfea..1eaab626523 100644 --- a/spec/models/team_spec.rb +++ b/spec/models/team_spec.rb @@ -3,7 +3,7 @@ let(:participant) { build(:participant, user_id: 1) } let(:participant2) { build(:participant, user_id: 2) } let(:participant3) { build(:participant, user_id: 3) } - let(:user) { build(:student, id: 1, name: 'no name', fullname: 'no one', participants: [participant]) } + let(:user) { build(:student, id: 1, username: 'no name', fullname: 'no one', participants: [participant]) } let(:user2) { build(:student, id: 2) } let(:user3) { build(:student, id: 3) } let(:team) { build(:assignment_team, id: 1, name: 'no team', users: [user]) } @@ -91,7 +91,7 @@ describe '#add_member' do context 'when parameterized user has already joined in current team' do it 'raise an error' do - expect { team.add_member(user) }.to raise_error(RuntimeError, "The user #{user.name} is already a member of the team #{team.name}") + expect { team.add_member(user) }.to raise_error(RuntimeError, "The user #{user.username} is already a member of the team #{team.name}") end end @@ -161,9 +161,9 @@ end describe '.import_team_members' do - context 'when cannot find a user by name' do + context 'when cannot find a user by username' do it 'raises an ImportError' do - allow(User).to receive(:find_by).with(name: 'no name').and_return(nil) + allow(User).to receive(:find_by).with(username: 'no name').and_return(nil) expect { team.import_team_members(teammembers: ['no name']) }.to raise_error(ImportError, "The user 'no name' was not found. Create this user?") end @@ -171,7 +171,7 @@ context 'when can find certain user' do it 'adds the user to current team' do - allow(User).to receive(:find_by).with(name: 'no name').and_return(user) + allow(User).to receive(:find_by).with(username: 'no name').and_return(user) allow(TeamsUser).to receive(:find_by).with(team_id: 1, user_id: 1).and_return(nil) allow_any_instance_of(Team).to receive(:add_member).with(user).and_return(true) expect(team.import_team_members(teammembers: ['no name'])).to eq(['no name']) diff --git a/spec/models/teammate_review_response_map_spec.rb b/spec/models/teammate_review_response_map_spec.rb index dbebd4e330a..009d4c97213 100644 --- a/spec/models/teammate_review_response_map_spec.rb +++ b/spec/models/teammate_review_response_map_spec.rb @@ -13,8 +13,8 @@ let(:assignment) { build(:assignment, id: 1, name: 'Test Assgt', rounds_of_reviews: 2) } let(:assignment1) { build(:assignment, id: 2, name: 'Test Assgt', rounds_of_reviews: 1) } let(:response) { build(:response, id: 1, map_id: 1, round: 1, response_map: teammate_review_response_map1, is_submitted: true) } - let(:student) { build(:student, id: 1, name: 'name', fullname: 'no one', email: 'expertiza@mailinator.com') } - let(:student1) { build(:student, id: 2, name: 'name1', fullname: 'no one', email: 'expertiza@mailinator.com') } + let(:student) { build(:student, id: 1, username: 'name', fullname: 'no one', email: 'expertiza@mailinator.com') } + let(:student1) { build(:student, id: 2, username: 'name1', fullname: 'no one', email: 'expertiza@mailinator.com') } # let(:assignment_teammate_questionnaire1) { build(:assignment_teammate_questionnaire, id: 1, assignment: assignment1, questionnaire: teammate_questionnaire1) } # let(:assignment_teammate_questionnaire2) { build(:assignment_teammate_questionnaire, id: 2, assignment_id: 2, questionnaire_id: 2) } # let(:teammate_questionnaire1) { build(:teammate_questionnaire, id: 1, type: 'TeammateReviewQuestionnaire') } diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 8275c02e145..a9ba7ecab8e 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1,26 +1,26 @@ describe User do let(:user) do - User.new name: 'abc', fullname: 'abc xyz', email: 'abcxyz@gmail.com', password: '12345678', password_confirmation: '12345678', + User.new username: 'abc', fullname: 'abc xyz', email: 'abcxyz@gmail.com', password: '12345678', password_confirmation: '12345678', email_on_submission: 1, email_on_review: 1, email_on_review_of_review: 0, copy_of_emails: 1, handle: 'handle' end - let(:user1) { User.new name: 'abc', fullname: 'abc bbc', email: 'abcbbc@gmail.com', password: '123456789', password_confirmation: '123456789' } - let(:user2) { User.new name: 'abc', fullname: 'abc bbc', email: 'abcbbe@gmail.com', password: '123456789', password_confirmation: '123456789' } + let(:user1) { User.new username: 'abc', fullname: 'abc bbc', email: 'abcbbc@gmail.com', password: '123456789', password_confirmation: '123456789' } + let(:user2) { User.new username: 'abc', fullname: 'abc bbc', email: 'abcbbe@gmail.com', password: '123456789', password_confirmation: '123456789' } - describe '#name' do - it 'returns the name of the user' do - expect(user.name).to eq('abc') + describe '#username' do + it 'returns the username of the user' do + expect(user.username).to eq('abc') end - it 'Validate presence of name which cannot be blank' do + it 'Validate presence of username which cannot be blank' do expect(user).to be_valid - user.name = ' ' + user.username = ' ' expect(user).not_to be_valid end - it 'Validate that name is always unique' do - expect(user1).to validate_uniqueness_of(:name) + it 'Validate that username is always unique' do + expect(user1).to validate_uniqueness_of(:username).case_insensitive end - it 'Validate that the name does not contain white spaces' do + it 'Validate that the username does not contain white spaces' do expect(user).to be_valid - user.name = 'abc def' + user.username = 'abc def' expect(user).not_to be_valid end end @@ -92,8 +92,8 @@ allow(user1).to receive(:role).and_return('Student') allow(user2).to receive(:role).and_return('Student') expect(user.role.get_parents).to eq(['Student']) - allow(User).to receive(:all).with(conditions: ['name LIKE ?', 'abc%'], limit: 20).and_return([user1, user2]) - expect(user.get_available_users(user.name)).to eq([user1, user2]) + allow(User).to receive(:all).with(conditions: ['username LIKE ?', 'abc%'], limit: 20).and_return([user1, user2]) + expect(user.get_available_users(user.username)).to eq([user1, user2]) end end @@ -207,16 +207,16 @@ describe '.import' do it 'raises error if import column does not equal to 3' do - row = { 'name' => 'abc', 'fullname' => 'abc xyz' } + row = { 'username' => 'abc', 'fullname' => 'abc xyz' } expect { User.import(row, nil, nil, nil) }.to raise_error(ArgumentError) end it 'updates an existing user with info from impor file' do - create(:student, name: 'abc') + create(:student, username: 'abc') row = { username: 'abc', fullname: 'test, test', email: 'test@gmail.com' } allow(user).to receive(:id).and_return(6) User.import(row, nil, { user: user }, nil) - updated_user = User.find_by(name: 'abc') + updated_user = User.find_by(username: 'abc') expect(updated_user.email).to eq 'test@gmail.com' expect(updated_user.fullname).to eq 'test, test' expect(updated_user.parent_id).to eq 6 @@ -248,7 +248,7 @@ context 'when user\'s email is not stored in DB' do it 'finds user by email if the local part of email is the same as username' do allow(User).to receive(:find_by).with(email: 'abc@gmail.com').and_return(nil) - allow(User).to receive(:where).with('name = ?', 'abc').and_return([user]) + allow(User).to receive(:where).with('username = ?', 'abc').and_return([user]) expect(User.find_by_login('abc@gmail.com')).to eq(user) end end @@ -294,7 +294,7 @@ before(:each) do allow(User).to receive(:all).and_return([user]) allow(user).to receive_message_chain(:role, :name).and_return('Student') - allow(user).to receive_message_chain(:parent, :name).and_return('Instructor') + allow(user).to receive_message_chain(:parent, :username).and_return('Instructor') end it 'exports all information setting in options' do @@ -331,12 +331,12 @@ describe '.export_fields' do it 'exports all information setting in options' do expect(User.export_fields('personal_details' => 'true', 'role' => 'true', 'parent' => 'true', 'email_options' => 'true', 'handle' => 'true')) - .to eq(['name', 'full name', 'email', 'role', 'parent', 'email on submission', 'email on review', 'email on metareview', 'copy of emails', 'handle']) + .to eq(['username', 'full name', 'email', 'role', 'parent', 'email on submission', 'email on review', 'email on metareview', 'copy of emails', 'handle']) end it 'exports only personal_details' do expect(User.export_fields('personal_details' => 'true')) - .to eq(['name', 'full name', 'email']) + .to eq(['username', 'full name', 'email']) end it 'exports only current role and parent' do @@ -361,9 +361,9 @@ expect(User.from_params(user_id: 1)).to eq(user) end - it 'returns user by user name fetching from params' do - allow(User).to receive(:find_by).with(name: 'abc').and_return(user) - expect(User.from_params(user: { name: 'abc' })).to eq(user) + it 'returns user by user username fetching from params' do + allow(User).to receive(:find_by).with(username: 'abc').and_return(user) + expect(User.from_params(user: { username: 'abc' })).to eq(user) end it 'raises an error when Expertiza cannot find user' do @@ -428,24 +428,24 @@ # E1991 : checking whether anonymized view names functionality works describe '#anonymized_view' do - it 'returns anonymized name when anonymized view is set' do + it 'returns anonymized username when anonymized view is set' do student = create(:student) allow(User).to receive(:anonymized_view?).and_return(true) - expect(student.name).to eq 'Student ' + student.id.to_s + expect(student.username).to eq 'Student ' + student.id.to_s end - it 'returns real name when anonymized view is not set' do + it 'returns real username when anonymized view is not set' do student = create(:student) allow(User).to receive(:anonymized_view?).and_return(false) - expect(student.name).not_to eq 'Student ' + student.id.to_s + expect(student.username).not_to eq 'Student ' + student.id.to_s end # this test case is applicable to impersonate mode it 'returns correct real name from anonymized name' do student = create(:student) - expect(student.name).not_to eq 'Student' + student.id.to_s - real_student = User.real_user_from_anonymized_name(student.name) - expect(student.name).to eq real_student.name + expect(student.username).not_to eq 'Student' + student.id.to_s + real_student = User.real_user_from_anonymized_username(student.username) + expect(student.username).to eq real_student.username expect(student).to eq real_student end end @@ -454,7 +454,7 @@ let(:role) { Role.new } before(:each) do - allow(User).to receive_message_chain(:order, :where).with('(role_id in (?) or id = ?) and name like ?', role.get_available_roles, @user_id, '%name%') + allow(User).to receive_message_chain(:order, :where).with('(role_id in (?) or id = ?) and username like ?', role.get_available_roles, @user_id, '%username%') allow(User).to receive_message_chain(:order, :where).with('(role_id in (?) or id = ?) and fullname like ?', role.get_available_roles, @user_id, '%fullname%') allow(User).to receive_message_chain(:order, :where).with('(role_id in (?) or id = ?) and email like ?', role.get_available_roles, @user_id, '%email%') user_id = double @@ -463,7 +463,7 @@ it 'when the search_by is 1' do search_by = '1' allow(User).to receive_message_chain(:order, :where).and_return(user) - expect(User.search_users(role, @user_id, 'name', search_by)).to eq user + expect(User.search_users(role, @user_id, 'username', search_by)).to eq user end it 'when the search_by is 2' do diff --git a/spec/models/vm_user_answer_tagging_spec.rb b/spec/models/vm_user_answer_tagging_spec.rb index 1daa2d0bb14..c4d86661bad 100644 --- a/spec/models/vm_user_answer_tagging_spec.rb +++ b/spec/models/vm_user_answer_tagging_spec.rb @@ -1,5 +1,5 @@ describe VmUserAnswerTagging do - let(:user1) { User.new name: 'abc', fullname: 'abc bbc', email: 'abcbbc@gmail.com', password: '123456789', password_confirmation: '123456789' } + let(:user1) { User.new username: 'abc', fullname: 'abc bbc', email: 'abcbbc@gmail.com', password: '123456789', password_confirmation: '123456789' } describe '#initialize' do it 'sets the instance variables' do vm_user_answer_tagging = VmUserAnswerTagging.new(user1, 75, true, true, true, '3000-01-31') diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index f7e0376278f..e23d6d02dab 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -57,19 +57,19 @@ config.infer_spec_type_from_file_location! def login_as(user_name) - user = User.find_by(name: user_name) + user = User.find_by(username: user_name) msg = user.to_yaml File.open('log/diagnostic.txt', 'a') { |f| f.write msg } visit root_path - fill_in 'login_name', with: user_name + fill_in 'login_username', with: user_name fill_in 'login_password', with: 'password' click_button 'Sign in' stub_current_user(user, user.role.name, user.role) end def login_as_other_user(user_name) - # user = User.find_by(name: user_name) + # user = User.find_by(username: user_name) login_as(user_name) click_link 'Home' end diff --git a/spec/support/teams_shared.rb b/spec/support/teams_shared.rb index db923c28ae8..db26d8772f1 100644 --- a/spec/support/teams_shared.rb +++ b/spec/support/teams_shared.rb @@ -8,7 +8,7 @@ let(:admin) { build_stubbed(:admin) } let(:instructor) { build_stubbed(:instructor, id: 1) } let(:ta) { build_stubbed(:teaching_assistant) } - let(:student1) { build_stubbed(:student, id: 1, name: 'student2065') } + let(:student1) { build_stubbed(:student, id: 1, username: 'student2065') } let(:student2) { build_stubbed(:student, id: 2) } let(:course1) { build_stubbed(:course, name: 'TestCourse', id: 1, instructor_id: instructor.id) } let(:assignment1) do
    <%= label_tag(:user, "User:") %> <%= select("post", "user_id", if current_user_role?.name == 'Super-Administrator' - (User.all.collect {|u| [ u.name(session[:ip]), u.id ] }.insert(0, ['Any', 0])) + (User.all.collect {|u| [ u.username(session[:ip]), u.id ] }.insert(0, ['Any', 0])) else - (User.where("id = #{current_user.id}").collect {|u| [ u.name(session[:ip]), u.id ] }) + (User.where("id = #{current_user.id}").collect {|u| [ u.username(session[:ip]), u.id ] }) end, ) %>