debian-mirror-gitlab/spec/finders/repositories/branch_names_finder_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

39 lines
1.1 KiB
Ruby
Raw Normal View History

2021-04-29 21:17:54 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Repositories::BranchNamesFinder do
let(:project) { create(:project, :repository) }
describe '#execute' do
2021-06-08 01:23:25 +05:30
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-29 21:17:54 +05:30
)
end
2021-06-08 01:23:25 +05:30
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-29 21:17:54 +05:30
end
end