diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
commit | 8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch) | |
tree | 544930fb309b30317ae9797a9683768705d664c4 /spec/models/bulk_imports/entity_spec.rb | |
parent | 4b1de649d0168371549608993deac953eb692019 (diff) |
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'spec/models/bulk_imports/entity_spec.rb')
-rw-r--r-- | spec/models/bulk_imports/entity_spec.rb | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/spec/models/bulk_imports/entity_spec.rb b/spec/models/bulk_imports/entity_spec.rb index ad6e3ec6f30..0732b671729 100644 --- a/spec/models/bulk_imports/entity_spec.rb +++ b/spec/models/bulk_imports/entity_spec.rb @@ -82,4 +82,68 @@ RSpec.describe BulkImports::Entity, type: :model do end end end + + describe "#update_tracker_for" do + let(:entity) { create(:bulk_import_entity) } + + it "inserts new tracker when it does not exist" do + expect do + entity.update_tracker_for(relation: :relation, has_next_page: false) + end.to change(BulkImports::Tracker, :count).by(1) + + tracker = entity.trackers.last + + expect(tracker.relation).to eq('relation') + expect(tracker.has_next_page).to eq(false) + expect(tracker.next_page).to eq(nil) + end + + it "updates the tracker if it already exist" do + create( + :bulk_import_tracker, + relation: :relation, + has_next_page: false, + entity: entity + ) + + expect do + entity.update_tracker_for(relation: :relation, has_next_page: true, next_page: 'nextPage') + end.not_to change(BulkImports::Tracker, :count) + + tracker = entity.trackers.last + + expect(tracker.relation).to eq('relation') + expect(tracker.has_next_page).to eq(true) + expect(tracker.next_page).to eq('nextPage') + end + end + + describe "#has_next_page?" do + it "queries for the given relation if it has more pages to be fetched" do + entity = create(:bulk_import_entity) + create( + :bulk_import_tracker, + relation: :relation, + has_next_page: false, + entity: entity + ) + + expect(entity.has_next_page?(:relation)).to eq(false) + end + end + + describe "#next_page_for" do + it "queries for the next page of the given relation" do + entity = create(:bulk_import_entity) + create( + :bulk_import_tracker, + relation: :relation, + has_next_page: false, + next_page: 'nextPage', + entity: entity + ) + + expect(entity.next_page_for(:relation)).to eq('nextPage') + end + end end |