travis-api/spec/lib/services/find_branches_spec.rb
Aakriti Gupta 65f1a29d86 Move travis-core files from /vendor to /lib.
- Re-factor
- Remove code for notifications
- Remove addons
- Remove travis-core gem.
- Ignore logs directory only
- Move core tests to spec/lib
2016-07-20 11:22:25 +02:00

29 lines
983 B
Ruby

describe Travis::Services::FindBranches do
let(:repo) { Factory(:repository, :owner_name => 'travis-ci', :name => 'travis-core') }
let!(:build) { Factory(:build, :repository => repo, :state => :finished) }
let(:service) { described_class.new(stub('user'), params) }
attr_reader :params
it 'finds the last builds of the given repository grouped per branch' do
@params = { :repository_id => repo.id }
service.run.should include(build)
end
it 'scopes to the given repository' do
@params = { :repository_id => repo.id }
build = Factory(:build, :repository => Factory(:repository), :state => :finished)
service.run.should_not include(build)
end
it 'returns an empty build scope when the repository could not be found' do
@params = { :repository_id => repo.id + 1 }
service.run.should == Build.none
end
it 'finds branches by a given list of ids' do
@params = { :ids => [build.id] }
service.run.should == [build]
end
end