spec: fix flaky past_lti_id user merge spec

load the context's shard before looking up past_lti_ids

test plan:
 • specs pass
 • verify in splunk after merge the test is no longer flaky

Change-Id: I5ee1967f17b5396254c6ea5567742eaaf57ad8b4
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/261169
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: August Thornton <august@instructure.com>
Product-Review: August Thornton <august@instructure.com>
This commit is contained in:
August Thornton 2021-03-19 14:43:23 -06:00
parent 9ee501d831
commit f3822b817b
1 changed files with 14 additions and 7 deletions

View File

@ -705,16 +705,23 @@ describe UserMerge do
context "sharding" do
specs_require_sharding
it "should move past_lti_id to the new user on other shard" do
course1 = course_factory(active_all: true)
user1 = user_with_pseudonym(:username => 'user1@example.com', :active_all => 1)
UserPastLtiId.create!(user: user1, context: course1, user_uuid: 'fake_uuid', user_lti_id: 'fake_lti_id_from_old_merge')
it 'should move past_lti_id to the new user on other shard' do
@shard1.activate do
account = Account.create!
@user2 = user_with_pseudonym(:username => 'user2@example.com', :active_all => 1, :account => account)
UserMerge.from(user1).into(@user2)
expect(@user2.reload.past_lti_ids.shard(@user2).take.user_lti_id).to eq 'fake_lti_id_from_old_merge'
@user1 = user_with_pseudonym(username: 'user1@example.com', active_all: 1, account: account)
end
course = course_factory(active_all: true)
user2 = user_with_pseudonym(username: 'user2@example.com', active_all: 1)
UserPastLtiId.create!(
user: user2,
context: course,
user_uuid: 'fake_uuid',
user_lti_id: 'fake_lti_id_from_old_merge'
)
UserMerge.from(user2).into(@user1)
expect(
UserPastLtiId.shard(course).where(user_id: @user1).take.user_lti_id
).to eq 'fake_lti_id_from_old_merge'
end
it 'should move prefs over with old format' do