2012-01-30 20:39:34 +00:00
|
|
|
# -*- encoding : utf-8 -*-
|
2011-03-11 16:08:41 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Repository do
|
2011-12-08 14:03:56 +00:00
|
|
|
|
|
|
|
context 'when create with same owner that platform' do
|
|
|
|
before (:each) do
|
2012-05-16 16:29:28 +01:00
|
|
|
stub_symlink_methods
|
2012-03-29 21:34:22 +01:00
|
|
|
@platform = FactoryGirl.create(:platform)
|
2011-12-08 14:03:56 +00:00
|
|
|
@params = {:name => 'tst_platform', :description => 'test platform'}
|
|
|
|
end
|
|
|
|
|
2012-02-20 23:13:05 +00:00
|
|
|
it 'it should increase Repository.count by 1' do
|
|
|
|
rep = Repository.create(@params) {|r| r.platform = @platform}
|
|
|
|
@platform.repositories.count.should eql(1)
|
2011-12-08 14:03:56 +00:00
|
|
|
end
|
|
|
|
end
|
2012-04-02 16:43:59 +01:00
|
|
|
|
|
|
|
before(:all) do
|
2012-05-16 16:29:28 +01:00
|
|
|
stub_symlink_methods
|
2012-04-02 16:43:59 +01:00
|
|
|
Platform.delete_all
|
|
|
|
User.delete_all
|
|
|
|
Repository.delete_all
|
|
|
|
FileUtils.rm_rf(APP_CONFIG['root_path'])
|
|
|
|
# Need for validate_uniqueness_of check
|
|
|
|
FactoryGirl.create(:repository)
|
|
|
|
end
|
|
|
|
|
|
|
|
it { should belong_to(:platform) }
|
|
|
|
it { should have_many(:project_to_repositories)}
|
|
|
|
it { should have_many(:projects).through(:project_to_repositories)}
|
|
|
|
|
|
|
|
it { should validate_presence_of(:name)}
|
|
|
|
it { should validate_uniqueness_of(:name).case_insensitive.scoped_to(:platform_id) }
|
|
|
|
it { should validate_format_of(:name).with('basic_repository-name-1234') }
|
|
|
|
it { should validate_format_of(:name).not_with('.!') }
|
|
|
|
it { should validate_format_of(:name).not_with('Main') }
|
|
|
|
it { should validate_presence_of(:description) }
|
|
|
|
|
|
|
|
it { should have_readonly_attribute(:name) }
|
|
|
|
it { should have_readonly_attribute(:platform_id) }
|
|
|
|
|
|
|
|
it { should_not allow_mass_assignment_of(:platform) }
|
|
|
|
it { should_not allow_mass_assignment_of(:platform_id) }
|
|
|
|
|
|
|
|
after(:all) do
|
|
|
|
Platform.delete_all
|
|
|
|
User.delete_all
|
|
|
|
Repository.delete_all
|
|
|
|
FileUtils.rm_rf(APP_CONFIG['root_path'])
|
|
|
|
end
|
|
|
|
|
2011-03-11 16:08:41 +00:00
|
|
|
end
|