#345: updated repository_spec
This commit is contained in:
parent
027a94e8bd
commit
cb8246d72f
|
@ -82,7 +82,7 @@ class Repository < ActiveRecord::Base
|
|||
begin
|
||||
name.chomp!; name.strip!
|
||||
next if name.blank?
|
||||
project_to_repositories.where(projects: { name: name }).joins(:project).destroy_all
|
||||
project_to_repositories.where(projects: { name: name }).joins(:project).readonly(false).destroy_all
|
||||
rescue RuntimeError, Exception
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,10 +3,12 @@ require 'spec_helper'
|
|||
describe Repository do
|
||||
before { stub_symlink_methods }
|
||||
|
||||
let(:repository) { FactoryGirl.create(:repository) }
|
||||
|
||||
context 'ensures that validations and associations exist' do
|
||||
before do
|
||||
# Need for validate_uniqueness_of check
|
||||
FactoryGirl.create(:repository)
|
||||
|
||||
it 'is valid given valid attributes' do
|
||||
repository.should be_true
|
||||
end
|
||||
|
||||
it { should belong_to(:platform) }
|
||||
|
@ -14,7 +16,12 @@ describe Repository do
|
|||
it { should have_many(:projects).through(:project_to_repositories) }
|
||||
|
||||
it { should validate_presence_of(:name) }
|
||||
|
||||
context 'uniqueness' do
|
||||
before { repository }
|
||||
it { should validate_uniqueness_of(:name).case_insensitive.scoped_to(:platform_id) }
|
||||
end
|
||||
|
||||
it { should allow_value('basic_repository-name-1234').for(:name) }
|
||||
it { should_not allow_value('.!').for(:name) }
|
||||
it { should_not allow_value('Main').for(:name) }
|
||||
|
@ -30,7 +37,7 @@ describe Repository do
|
|||
end
|
||||
|
||||
context '#sync_lock_file_exists?, #add_sync_lock_file, #remove_sync_lock_file, #add_repo_lock_file, #remove_repo_lock_file' do
|
||||
let(:repository) { FactoryGirl.create(:repository) }
|
||||
let(:repository) { FactoryGirl.build(:repository) }
|
||||
let(:path) { "#{repository.platform.path}/repository/SRPMS/#{repository.name}" }
|
||||
before { FileUtils.mkdir_p path }
|
||||
|
||||
|
|
Loading…
Reference in New Issue