summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2018-01-04 12:17:20 +0000
committerYorick Peterse <yorickpeterse@gmail.com>2018-01-04 12:17:20 +0000
commit51562aafc782f7eb65152f0551d9cb41268aeae2 (patch)
treed8adb557377df2d51f6936b55b9d81fbd1c4da77 /spec
parenta0ae88613598a2b0fddad4e7a6f779827257f103 (diff)
parent57dc5a521bbdd94cc2eab34f22e2b6fac9e8bd55 (diff)
downloadgitlab-ce-51562aafc782f7eb65152f0551d9cb41268aeae2.tar.gz
Merge branch 'sh-validate-path-project-import' into 'master'
Avoid leaving a push event empty if payload cannot be created See merge request gitlab-org/gitlab-ce!16214
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/background_migration/migrate_events_to_push_event_payloads_spec.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/spec/lib/gitlab/background_migration/migrate_events_to_push_event_payloads_spec.rb b/spec/lib/gitlab/background_migration/migrate_events_to_push_event_payloads_spec.rb
index 7351d45336a..5432d270555 100644
--- a/spec/lib/gitlab/background_migration/migrate_events_to_push_event_payloads_spec.rb
+++ b/spec/lib/gitlab/background_migration/migrate_events_to_push_event_payloads_spec.rb
@@ -281,6 +281,17 @@ describe Gitlab::BackgroundMigration::MigrateEventsToPushEventPayloads, :migrati
migration.process_event(event)
end
+
+ it 'handles an error gracefully' do
+ event1 = create_push_event(project, author, { commits: [] })
+
+ expect(migration).to receive(:replicate_event).and_call_original
+ expect(migration).to receive(:create_push_event_payload).and_raise(ActiveRecord::InvalidForeignKey, 'invalid foreign key')
+
+ migration.process_event(event1)
+
+ expect(described_class::EventForMigration.all.count).to eq(0)
+ end
end
describe '#replicate_event' do
@@ -335,9 +346,8 @@ describe Gitlab::BackgroundMigration::MigrateEventsToPushEventPayloads, :migrati
it 'does not create push event payloads for removed events' do
allow(event).to receive(:id).and_return(-1)
- payload = migration.create_push_event_payload(event)
+ expect { migration.create_push_event_payload(event) }.to raise_error(ActiveRecord::InvalidForeignKey)
- expect(payload).to be_nil
expect(PushEventPayload.count).to eq(0)
end