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