diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-20 21:38:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-20 21:38:24 +0300 |
commit | 983a0bba5d2a042c4a3bbb22432ec192c7501d82 (patch) | |
tree | b153cd387c14ba23bd5a07514c7c01fddf6a78a0 /spec/models/project_import_state_spec.rb | |
parent | a2bddee2cdb38673df0e004d5b32d9f77797de64 (diff) |
Add latest changes from gitlab-org/gitlab@12-10-stable-ee
Diffstat (limited to 'spec/models/project_import_state_spec.rb')
-rw-r--r-- | spec/models/project_import_state_spec.rb | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/spec/models/project_import_state_spec.rb b/spec/models/project_import_state_spec.rb index 720dc4f435f..cb34d898a6e 100644 --- a/spec/models/project_import_state_spec.rb +++ b/spec/models/project_import_state_spec.rb @@ -3,7 +3,10 @@ require 'spec_helper' describe ProjectImportState, type: :model do - subject { create(:import_state) } + let_it_be(:correlation_id) { 'cid' } + let_it_be(:import_state, refind: true) { create(:import_state, correlation_id_value: correlation_id) } + + subject { import_state } describe 'associations' do it { is_expected.to belong_to(:project) } @@ -33,12 +36,24 @@ describe ProjectImportState, type: :model do end it 'records job and correlation IDs', :sidekiq_might_not_need_inline do - allow(Labkit::Correlation::CorrelationId).to receive(:current_or_new_id).and_return('abc') + allow(Labkit::Correlation::CorrelationId).to receive(:current_or_new_id).and_return(correlation_id) import_state.schedule expect(import_state.jid).to be_an_instance_of(String) - expect(import_state.correlation_id).to eq('abc') + expect(import_state.correlation_id).to eq(correlation_id) + end + end + + describe '#relation_hard_failures' do + let_it_be(:failures) { create_list(:import_failure, 2, :hard_failure, project: import_state.project, correlation_id_value: correlation_id) } + + it 'returns hard relation failures related to this import' do + expect(subject.relation_hard_failures(limit: 100)).to match_array(failures) + end + + it 'limits returned collection to given maximum' do + expect(subject.relation_hard_failures(limit: 1).size).to eq(1) end end |