rosa-build/spec/models/platform_content.rb

71 lines
2.4 KiB
Ruby
Raw Normal View History

2013-07-08 14:50:24 +01:00
require 'spec_helper'
describe PlatformContent do
subject { PlatformContent }
before { stub_symlink_methods }
let!(:platform) { FactoryGirl.create(:platform) }
context '#find_by_platform' do
before do
File.open(File.join(platform.path, 'test001'), "w")
File.open(File.join(platform.path, 'test002'), "w")
end
it 'ensures that finds files' do
# + /repository folder
2015-02-19 01:12:08 +00:00
expect(subject.find_by_platform(platform, '', '').count).to eq 3
2013-07-08 14:50:24 +01:00
end
context 'ensures that finds files by name' do
2015-02-19 01:12:08 +00:00
it { expect(subject.find_by_platform(platform, '', 'test').count).to eq 2 }
it { expect(subject.find_by_platform(platform, '', 'test001').count).to eq 1 }
it { expect(subject.find_by_platform(platform, 'repository', 'test').count).to eq 0 }
2013-07-08 14:50:24 +01:00
end
end
context '#is_folder?' do
it 'ensures that returns true for folder' do
subject.find_by_platform(platform, '', 'repository').first.is_folder?
2015-02-19 01:12:08 +00:00
.should be_truthy
2013-07-08 14:50:24 +01:00
end
it 'ensures that returns false for file' do
File.open(File.join(platform.path, 'test001'), "w")
subject.find_by_platform(platform, '', 'test').first.is_folder?
2015-02-19 01:12:08 +00:00
.should be_falsy
2013-07-08 14:50:24 +01:00
end
end
context '#build_list' do
2014-01-21 04:51:49 +00:00
let!(:package) { FactoryGirl.create(:build_list_package, actual: true) }
2013-07-08 14:50:24 +01:00
let(:platform) { package.build_list.save_to_platform }
let(:repository) { platform.repositories.first }
before do
File.open(File.join(platform.path, 'test001'), "w")
package.build_list.update_column(:status, BuildList::BUILD_PUBLISHED)
path = File.join platform.path, 'repository', 'SRPMS', repository.name, 'release'
FileUtils.mkdir_p path
File.open(File.join(path, package.fullname), "w")
path = File.join path, 'repodata'
FileUtils.mkdir_p path
File.open(File.join(path, package.fullname), "w")
end
context 'ensures that returns nil for simple file' do
it { subject.find_by_platform(platform, '', 'test').first.build_list.should be_nil }
it { subject.find_by_platform(platform, "repository/SRPMS/#{repository.name}/release/repodata", '').first.build_list.should be_nil }
end
it 'ensures that returns build_list for package' do
subject.find_by_platform(platform, "repository/SRPMS/#{repository.name}/release", package.fullname)
.first.build_list.should == package.build_list
end
end
end