Trigger iid logic from GitHub importer for issues.
This commit is contained in:
parent
a2d647b113
commit
b78a69b06c
2 changed files with 27 additions and 1 deletions
|
@ -55,7 +55,11 @@ module Gitlab
|
|||
updated_at: issue.updated_at
|
||||
}
|
||||
|
||||
GithubImport.insert_and_return_id(attributes, project.issues)
|
||||
GithubImport.insert_and_return_id(attributes, project.issues).tap do |id|
|
||||
# We use .insert_and_return_id which effectively disables all callbacks.
|
||||
# Trigger iid logic here to make sure we track internal id values consistently.
|
||||
project.issues.find(id).ensure_project_iid!
|
||||
end
|
||||
rescue ActiveRecord::InvalidForeignKey
|
||||
# It's possible the project has been deleted since scheduling this
|
||||
# job. In this case we'll just skip creating the issue.
|
||||
|
|
|
@ -78,6 +78,11 @@ describe Gitlab::GithubImport::Importer::IssueImporter, :clean_gitlab_redis_cach
|
|||
.to receive(:id_for)
|
||||
.with(issue)
|
||||
.and_return(milestone.id)
|
||||
|
||||
allow(importer.user_finder)
|
||||
.to receive(:author_id_for)
|
||||
.with(issue)
|
||||
.and_return([user.id, true])
|
||||
end
|
||||
|
||||
context 'when the issue author could be found' do
|
||||
|
@ -172,6 +177,23 @@ describe Gitlab::GithubImport::Importer::IssueImporter, :clean_gitlab_redis_cach
|
|||
|
||||
expect(importer.create_issue).to be_a_kind_of(Numeric)
|
||||
end
|
||||
|
||||
it 'triggers internal_id functionality to track greatest iids' do
|
||||
allow(importer.user_finder)
|
||||
.to receive(:author_id_for)
|
||||
.with(issue)
|
||||
.and_return([user.id, true])
|
||||
|
||||
issue = build_stubbed(:issue, project: project)
|
||||
allow(Gitlab::GithubImport)
|
||||
.to receive(:insert_and_return_id)
|
||||
.and_return(issue.id)
|
||||
allow(project.issues).to receive(:find).with(issue.id).and_return(issue)
|
||||
|
||||
expect(issue).to receive(:ensure_project_iid!)
|
||||
|
||||
importer.create_issue
|
||||
end
|
||||
end
|
||||
|
||||
describe '#create_assignees' do
|
||||
|
|
Loading…
Reference in a new issue