2012-05-18 16:12:51 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe MassBuild do
|
2013-06-21 11:39:03 +01:00
|
|
|
before { stub_symlink_methods }
|
|
|
|
|
|
|
|
context 'ensures that validations and associations exist' do
|
|
|
|
before do
|
|
|
|
# Need for validate_uniqueness_of check
|
|
|
|
FactoryGirl.create(:mass_build)
|
|
|
|
end
|
|
|
|
|
|
|
|
it { should belong_to(:build_for_platform) }
|
|
|
|
it { should belong_to(:save_to_platform) }
|
|
|
|
it { should belong_to(:user) }
|
|
|
|
it { should have_many(:build_lists)}
|
|
|
|
|
|
|
|
it { should validate_presence_of(:save_to_platform_id)}
|
|
|
|
it { should validate_presence_of(:build_for_platform_id)}
|
|
|
|
it { should validate_presence_of(:user_id)}
|
|
|
|
it { should validate_presence_of(:arch_names)}
|
|
|
|
it { should validate_presence_of(:name)}
|
|
|
|
|
|
|
|
it { should validate_presence_of(:projects_list)}
|
|
|
|
it { should ensure_length_of(:projects_list).is_at_most(500_000) }
|
|
|
|
|
|
|
|
|
|
|
|
it { should_not allow_mass_assignment_of(:name) }
|
|
|
|
it { should_not allow_mass_assignment_of(:arch_names) }
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'ensures that projects_list contains unique projects' do
|
|
|
|
projects_list = %(at
|
2014-01-21 04:51:49 +00:00
|
|
|
at
|
|
|
|
ab
|
2013-06-21 11:39:03 +01:00
|
|
|
)
|
2014-01-21 04:51:49 +00:00
|
|
|
mass_build = FactoryGirl.create(:mass_build, projects_list: projects_list)
|
2013-06-21 11:39:03 +01:00
|
|
|
list = mass_build.projects_list.split(/[\r]*\n/)
|
|
|
|
list.should have(2).items
|
|
|
|
list.should include('at', 'ab')
|
|
|
|
end
|
2012-05-18 16:12:51 +01:00
|
|
|
end
|