diff options
Diffstat (limited to 'spec/models/projects/import_export/relation_export_spec.rb')
-rw-r--r-- | spec/models/projects/import_export/relation_export_spec.rb | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/spec/models/projects/import_export/relation_export_spec.rb b/spec/models/projects/import_export/relation_export_spec.rb index 8643fbc7b46..c724f30250d 100644 --- a/spec/models/projects/import_export/relation_export_spec.rb +++ b/spec/models/projects/import_export/relation_export_spec.rb @@ -2,9 +2,7 @@ require 'spec_helper' -RSpec.describe Projects::ImportExport::RelationExport, type: :model do - subject { create(:project_relation_export) } - +RSpec.describe Projects::ImportExport::RelationExport, type: :model, feature_category: :importers do describe 'associations' do it { is_expected.to belong_to(:project_export_job) } it { is_expected.to have_one(:upload) } @@ -13,12 +11,16 @@ RSpec.describe Projects::ImportExport::RelationExport, type: :model do describe 'validations' do it { is_expected.to validate_presence_of(:project_export_job) } it { is_expected.to validate_presence_of(:relation) } - it { is_expected.to validate_uniqueness_of(:relation).scoped_to(:project_export_job_id) } it { is_expected.to validate_presence_of(:status) } it { is_expected.to validate_numericality_of(:status).only_integer } it { is_expected.to validate_length_of(:relation).is_at_most(255) } it { is_expected.to validate_length_of(:jid).is_at_most(255) } it { is_expected.to validate_length_of(:export_error).is_at_most(300) } + + it 'validates uniquness of the relation attribute' do + create(:project_relation_export) + expect(subject).to validate_uniqueness_of(:relation).scoped_to(:project_export_job_id) + end end describe '.by_relation' do @@ -52,4 +54,16 @@ RSpec.describe Projects::ImportExport::RelationExport, type: :model do expect(described_class.relation_names_list).not_to include('events', 'notes') end end + + describe '#mark_as_failed' do + it 'sets status to failed and sets the export error', :aggregate_failures do + relation_export = create(:project_relation_export) + + relation_export.mark_as_failed("Error message") + relation_export.reload + + expect(relation_export.failed?).to eq(true) + expect(relation_export.export_error).to eq("Error message") + end + end end |