fix Performance/Detect issue
Change-Id: I2f2ca4b876eee05572a718ca4fb7d449f61bf17d fixes: CNVS-20009 Reviewed-on: https://gerrit.instructure.com/52891 Tested-by: Jenkins Reviewed-by: Cody Cutrer <cody@instructure.com> Product-Review: Strand McCutchen <smccutchen@instructure.com> QA-Review: Strand McCutchen <smccutchen@instructure.com>
This commit is contained in:
parent
0fe45e8dfc
commit
0d6e0ea864
|
@ -58,7 +58,7 @@ module AvatarHelper
|
|||
if participants.size == 1
|
||||
avatar_url_for_user(participants.first)
|
||||
elsif participants.size == 2
|
||||
avatar_url_for_user(participants.select{ |u| u.id != conversation.user_id }.first)
|
||||
avatar_url_for_user(participants.find{ |u| u.id != conversation.user_id })
|
||||
else
|
||||
avatar_url_for_group
|
||||
end
|
||||
|
|
|
@ -298,7 +298,7 @@ class CommunicationChannel < ActiveRecord::Base
|
|||
if self.build_pseudonym_on_confirm && self.active?
|
||||
self.build_pseudonym_on_confirm = false
|
||||
pseudonym = self.user.pseudonyms.build(:unique_id => self.path, :account => Account.default)
|
||||
existing_pseudonym = self.user.pseudonyms.active.select{|p| p.account_id == Account.default.id }.first
|
||||
existing_pseudonym = self.user.pseudonyms.active.find{|p| p.account_id == Account.default.id }
|
||||
if existing_pseudonym
|
||||
pseudonym.password_salt = existing_pseudonym.password_salt
|
||||
pseudonym.crypted_password = existing_pseudonym.crypted_password
|
||||
|
|
|
@ -71,15 +71,15 @@ module Api::V1
|
|||
end
|
||||
|
||||
it 'has a hash of graders for each day keyed by id' do
|
||||
graders_hash = @days.select{|d| d[:date] == yesterday.to_date.as_json }.first[:graders]
|
||||
graders_hash = @days.find{|d| d[:date] == yesterday.to_date.as_json }[:graders]
|
||||
grader = graders_hash.first
|
||||
expect(grader[:id]).to eq @grader2.id
|
||||
expect(grader[:name]).to eq @grader2.name
|
||||
end
|
||||
|
||||
it 'puts an assignment list under each grader' do
|
||||
graders = @days.select{|d| d[:date] == yesterday.to_date.as_json }.first[:graders]
|
||||
grader2_assignments = graders.select { |g| g[:id] == @grader2.id }.first[:assignments]
|
||||
graders = @days.find{|d| d[:date] == yesterday.to_date.as_json }[:graders]
|
||||
grader2_assignments = graders.find { |g| g[:id] == @grader2.id }[:assignments]
|
||||
ids = grader2_assignments.map { |assignment| assignment['id'] }
|
||||
expect(ids).to include(@assignment1.id)
|
||||
expect(ids).to include(@assignment2.id)
|
||||
|
@ -122,7 +122,7 @@ module Api::V1
|
|||
end
|
||||
|
||||
it 'includes assignment data' do
|
||||
assignment_hash = @day_hash.select{|g| g[:id] == @grader1.id}.first[:assignments].first
|
||||
assignment_hash = @day_hash.find{|g| g[:id] == @grader1.id}[:assignments].first
|
||||
expect(assignment_hash['id']).to eq @assignment.id
|
||||
expect(assignment_hash['name']).to eq @assignment.title
|
||||
end
|
||||
|
|
|
@ -1121,8 +1121,7 @@ describe CoursesController do
|
|||
:limit_privileges_to_course_section => true
|
||||
expect(response).to be_success
|
||||
run_jobs
|
||||
enrollment = @course.reload.teachers.select { |t| t.name == 'Sam' }.
|
||||
first.enrollments.first
|
||||
enrollment = @course.reload.teachers.find { |t| t.name == 'Sam' }.enrollments.first
|
||||
expect(enrollment.limit_privileges_to_course_section).to eq true
|
||||
end
|
||||
end
|
||||
|
|
|
@ -46,7 +46,7 @@ describe GradebookHistoryApiController do
|
|||
describe 'GET days' do
|
||||
|
||||
def graders_hash_for(submission)
|
||||
json_body.select{|d| d['date'] == date_key(submission) }.first['graders']
|
||||
json_body.find{|d| d['date'] == date_key(submission) }['graders']
|
||||
end
|
||||
|
||||
describe 'default params' do
|
||||
|
@ -63,7 +63,7 @@ describe GradebookHistoryApiController do
|
|||
end
|
||||
|
||||
it 'includes a list of assignment names for each grader' do
|
||||
grader_hash = graders_hash_for(@submission3).select{|h| h['id'] == @other_grader.id }.first
|
||||
grader_hash = graders_hash_for(@submission3).find{|h| h['id'] == @other_grader.id }
|
||||
expect(grader_hash['assignments'].map{|a| a['name'] }.sort).to eq ['some assignment', 'another assignment'].sort
|
||||
end
|
||||
end
|
||||
|
@ -82,7 +82,7 @@ describe GradebookHistoryApiController do
|
|||
end
|
||||
|
||||
it 'lists assignment names under the graders' do
|
||||
expect(json_body.select{|g| g['id'] == @grader.id }.first['assignments'].first['name']).to eq @assignment1.title
|
||||
expect(json_body.find{|g| g['id'] == @grader.id }['assignments'].first['name']).to eq @assignment1.title
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -365,7 +365,7 @@ describe LearningOutcome do
|
|||
@outcome.reload
|
||||
expect(@outcome.learning_outcome_results).not_to be_empty
|
||||
expect(@outcome.learning_outcome_results.length).to eql(1)
|
||||
@result = @outcome.learning_outcome_results.select{|r| r.artifact_type == 'RubricAssessment'}.first
|
||||
@result = @outcome.learning_outcome_results.find{|r| r.artifact_type == 'RubricAssessment'}
|
||||
expect(@result).not_to be_nil
|
||||
expect(@result.user_id).to eql(@user.id)
|
||||
expect(@result.score).to eql(2.0)
|
||||
|
@ -430,7 +430,7 @@ describe LearningOutcome do
|
|||
})
|
||||
expect(@outcome.learning_outcome_results).not_to be_empty
|
||||
expect(@outcome.learning_outcome_results.length).to eql(1)
|
||||
@result = @outcome.learning_outcome_results.select{|r| r.artifact_type == 'RubricAssessment'}.first
|
||||
@result = @outcome.learning_outcome_results.find{|r| r.artifact_type == 'RubricAssessment'}
|
||||
expect(@result).not_to be_nil
|
||||
expect(@result.user_id).to eql(@user.id)
|
||||
expect(@result.score).to eql(2.0)
|
||||
|
|
|
@ -22,7 +22,7 @@ describe "users" do
|
|||
submit_form(pseudonym_form)
|
||||
wait_for_ajaximations
|
||||
|
||||
new_login = ff('.login').select { |e| e.attribute(:class) !~ /blank/ }.first
|
||||
new_login = ff('.login').find { |e| e.attribute(:class) !~ /blank/ }
|
||||
expect(new_login).not_to be_nil
|
||||
expect(new_login.find_element(:css, '.account_name').text()).not_to be_blank
|
||||
pseudonym = Pseudonym.by_unique_id('new_user').first
|
||||
|
|
Loading…
Reference in New Issue