diff options
Diffstat (limited to 'spec/models/bulk_imports/entity_spec.rb')
-rw-r--r-- | spec/models/bulk_imports/entity_spec.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/models/bulk_imports/entity_spec.rb b/spec/models/bulk_imports/entity_spec.rb index b822786579b..ce143a1aa33 100644 --- a/spec/models/bulk_imports/entity_spec.rb +++ b/spec/models/bulk_imports/entity_spec.rb @@ -191,6 +191,24 @@ RSpec.describe BulkImports::Entity, type: :model, feature_category: :importers d expect(described_class.by_user_id(user.id)).to contain_exactly(entity_1, entity_2) end end + + describe '.stale' do + it 'returns entities that are stale' do + entity_1 = create(:bulk_import_entity, updated_at: 3.days.ago) + create(:bulk_import_entity) + + expect(described_class.stale).to contain_exactly(entity_1) + end + end + + describe '.order_by_updated_at_and_id' do + it 'returns entities ordered by updated_at and id' do + entity_1 = create(:bulk_import_entity, updated_at: 3.days.ago) + entity_2 = create(:bulk_import_entity, updated_at: 2.days.ago) + + expect(described_class.order_by_updated_at_and_id(:desc)).to eq([entity_2, entity_1]) + end + end end describe '.all_human_statuses' do @@ -444,6 +462,13 @@ RSpec.describe BulkImports::Entity, type: :model, feature_category: :importers d expect(entity.has_failures).to eq(true) end + + it 'sets the has_failures flag on the parent import' do + create(:bulk_import_failure, entity: entity) + + expect { entity.update_has_failures } + .to change { entity.bulk_import.has_failures? }.from(false).to(true) + end end context 'when entity does not have failures' do |