2021-04-07 14:09:45 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
RSpec.describe Repositories::BranchNamesFinder do
|
|
|
|
let(:project) { create(:project, :repository) }
|
|
|
|
|
|
|
|
describe '#execute' do
|
2021-05-07 14:10:21 -04:00
|
|
|
it 'returns all filtered branch names' do
|
|
|
|
expect(create_branch_names_finder(0, 100).execute).to contain_exactly(
|
|
|
|
'snippet/edit-file',
|
|
|
|
'snippet/multiple-files',
|
|
|
|
'snippet/no-files',
|
|
|
|
'snippet/rename-and-edit-file',
|
|
|
|
'snippet/single-file'
|
2021-04-07 14:09:45 -04:00
|
|
|
)
|
|
|
|
end
|
2021-05-07 14:10:21 -04:00
|
|
|
|
|
|
|
it 'returns a limited number of offset filtered branch names' do
|
|
|
|
starting_names = create_branch_names_finder(0, 3).execute
|
|
|
|
offset_names = create_branch_names_finder(3, 2).execute
|
|
|
|
|
|
|
|
expect(starting_names.count).to eq(3)
|
|
|
|
expect(offset_names.count).to eq(2)
|
|
|
|
|
|
|
|
expect(offset_names).not_to include(*starting_names)
|
|
|
|
|
|
|
|
all_names = create_branch_names_finder(0, 100).execute
|
|
|
|
expect(all_names).to contain_exactly(*starting_names, *offset_names)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def create_branch_names_finder(offset, limit)
|
|
|
|
described_class.new(project.repository, search: 'snippet/*', offset: offset, limit: limit)
|
|
|
|
end
|
2021-04-07 14:09:45 -04:00
|
|
|
end
|
|
|
|
end
|