Merge pull request #113 from abf/rosa-build:111-not-deleting-repository-when-delete-it-in-web-interface
#111: not deleting repository when delete it in web interface
This commit is contained in:
commit
962d8edd52
|
@ -17,7 +17,7 @@ class Repository < ActiveRecord::Base
|
||||||
|
|
||||||
scope :recent, order("#{table_name}.name ASC")
|
scope :recent, order("#{table_name}.name ASC")
|
||||||
|
|
||||||
before_destroy :detele_directory, :unless => lambda {Thread.current[:skip]}
|
before_destroy :detele_directory
|
||||||
|
|
||||||
attr_accessible :name, :description, :publish_without_qa
|
attr_accessible :name, :description, :publish_without_qa
|
||||||
attr_readonly :name, :platform_id
|
attr_readonly :name, :platform_id
|
||||||
|
|
|
@ -2,48 +2,49 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Platform do
|
describe Platform do
|
||||||
before(:all) do
|
before { stub_symlink_methods }
|
||||||
stub_symlink_methods
|
|
||||||
Platform.delete_all
|
context 'ensures that validations and associations exist' do
|
||||||
User.delete_all
|
before do
|
||||||
init_test_root
|
# Need for validate_uniqueness_of check
|
||||||
# Need for validate_uniqueness_of check
|
FactoryGirl.create(:platform)
|
||||||
FactoryGirl.create(:platform)
|
end
|
||||||
|
|
||||||
|
it { should belong_to(:owner) }
|
||||||
|
it { should have_many(:members)}
|
||||||
|
it { should have_many(:repositories)}
|
||||||
|
it { should have_many(:products)}
|
||||||
|
|
||||||
|
it { should validate_presence_of(:name)}
|
||||||
|
it { should validate_uniqueness_of(:name).case_insensitive }
|
||||||
|
it { should allow_value('Basic_platform-name-1234').for(:name) }
|
||||||
|
it { should_not allow_value('.!').for(:name) }
|
||||||
|
it { should validate_presence_of(:description) }
|
||||||
|
it { should validate_presence_of(:distrib_type) }
|
||||||
|
it { should validate_presence_of(:visibility) }
|
||||||
|
|
||||||
|
Platform::VISIBILITIES.each do |value|
|
||||||
|
it {should allow_value(value).for(:visibility)}
|
||||||
|
end
|
||||||
|
it {should_not allow_value('custom_status').for(:visibility)}
|
||||||
|
|
||||||
|
it { should have_readonly_attribute(:name) }
|
||||||
|
it { should have_readonly_attribute(:distrib_type) }
|
||||||
|
it { should have_readonly_attribute(:parent_platform_id) }
|
||||||
|
it { should have_readonly_attribute(:platform_type) }
|
||||||
|
|
||||||
|
it { should_not allow_mass_assignment_of(:repositories) }
|
||||||
|
it { should_not allow_mass_assignment_of(:products) }
|
||||||
|
it { should_not allow_mass_assignment_of(:members) }
|
||||||
|
it { should_not allow_mass_assignment_of(:parent) }
|
||||||
|
|
||||||
|
it {should_not allow_value("How do you do...\nmy_platform").for(:name)}
|
||||||
end
|
end
|
||||||
|
|
||||||
it { should belong_to(:owner) }
|
it 'ensures that folder of platform will be removed after destroy' do
|
||||||
it { should have_many(:members)}
|
platform = FactoryGirl.create(:platform)
|
||||||
it { should have_many(:repositories)}
|
FileUtils.mkdir_p platform.path
|
||||||
it { should have_many(:products)}
|
platform.destroy
|
||||||
|
Dir.exists?(platform.path).should be_false
|
||||||
it { should validate_presence_of(:name)}
|
|
||||||
it { should validate_uniqueness_of(:name).case_insensitive }
|
|
||||||
it { should validate_format_of(:name).with('Basic_platform-name-1234') }
|
|
||||||
it { should validate_format_of(:name).not_with('.!') }
|
|
||||||
it { should validate_presence_of(:description) }
|
|
||||||
it { should validate_presence_of(:distrib_type) }
|
|
||||||
it { should validate_presence_of(:visibility) }
|
|
||||||
|
|
||||||
Platform::VISIBILITIES.each do |value|
|
|
||||||
it {should allow_value(value).for(:visibility)}
|
|
||||||
end
|
|
||||||
it {should_not allow_value('custom_status').for(:visibility)}
|
|
||||||
|
|
||||||
it { should have_readonly_attribute(:name) }
|
|
||||||
it { should have_readonly_attribute(:distrib_type) }
|
|
||||||
it { should have_readonly_attribute(:parent_platform_id) }
|
|
||||||
it { should have_readonly_attribute(:platform_type) }
|
|
||||||
|
|
||||||
it { should_not allow_mass_assignment_of(:repositories) }
|
|
||||||
it { should_not allow_mass_assignment_of(:products) }
|
|
||||||
it { should_not allow_mass_assignment_of(:members) }
|
|
||||||
it { should_not allow_mass_assignment_of(:parent) }
|
|
||||||
|
|
||||||
it {should_not allow_value("How do you do...\nmy_platform").for(:name)}
|
|
||||||
|
|
||||||
after(:all) do
|
|
||||||
Platform.delete_all
|
|
||||||
User.delete_all
|
|
||||||
clear_test_root
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,10 +2,36 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Repository do
|
describe Repository do
|
||||||
|
before { stub_symlink_methods }
|
||||||
|
|
||||||
|
context 'ensures that validations and associations exist' do
|
||||||
|
before do
|
||||||
|
# Need for validate_uniqueness_of check
|
||||||
|
FactoryGirl.create(:repository)
|
||||||
|
end
|
||||||
|
|
||||||
|
it { should belong_to(:platform) }
|
||||||
|
it { should have_many(:project_to_repositories).validate(true) }
|
||||||
|
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 allow_value('basic_repository-name-1234').for(:name) }
|
||||||
|
it { should_not allow_value('.!').for(:name) }
|
||||||
|
it { should_not allow_value('Main').for(:name) }
|
||||||
|
it { should_not allow_value("!!\nbang_bang\n!!").for(:name) }
|
||||||
|
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) }
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
context 'when create with same owner that platform' do
|
context 'when create with same owner that platform' do
|
||||||
before (:each) do
|
before do
|
||||||
stub_symlink_methods
|
|
||||||
@platform = FactoryGirl.create(:platform)
|
@platform = FactoryGirl.create(:platform)
|
||||||
@params = {:name => 'tst_platform', :description => 'test platform'}
|
@params = {:name => 'tst_platform', :description => 'test platform'}
|
||||||
end
|
end
|
||||||
|
@ -16,39 +42,31 @@ describe Repository do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
before(:all) do
|
context 'ensures that folder of repository will be removed after destroy' do
|
||||||
stub_symlink_methods
|
let(:arch) { FactoryGirl.create(:arch) }
|
||||||
Platform.delete_all
|
let(:types) { ['SRPM', arch.name] }
|
||||||
User.delete_all
|
|
||||||
Repository.delete_all
|
|
||||||
init_test_root
|
|
||||||
# Need for validate_uniqueness_of check
|
|
||||||
FactoryGirl.create(:repository)
|
|
||||||
end
|
|
||||||
|
|
||||||
it { should belong_to(:platform) }
|
it "repository of main platform" do
|
||||||
it { should have_many(:project_to_repositories).validate(true) }
|
FactoryGirl.create(:arch)
|
||||||
it { should have_many(:projects).through(:project_to_repositories) }
|
r = FactoryGirl.create(:repository)
|
||||||
|
paths = types.
|
||||||
|
map{ |type| "#{r.platform.path}/repository/#{type}/#{r.name}" }.
|
||||||
|
each{ |path| FileUtils.mkdir_p path }
|
||||||
|
r.destroy
|
||||||
|
paths.each{ |path| Dir.exists?(path).should be_false }
|
||||||
|
end
|
||||||
|
|
||||||
it { should validate_presence_of(:name) }
|
it "repository of personal platform" do
|
||||||
it { should validate_uniqueness_of(:name).case_insensitive.scoped_to(:platform_id) }
|
FactoryGirl.create(:arch)
|
||||||
it { should validate_format_of(:name).with('basic_repository-name-1234') }
|
main_platform = FactoryGirl.create(:platform)
|
||||||
it { should validate_format_of(:name).not_with('.!') }
|
r = FactoryGirl.create(:personal_repository)
|
||||||
it { should validate_format_of(:name).not_with('Main') }
|
paths = types.
|
||||||
it { should validate_format_of(:name).not_with("!!\nbang_bang\n!!") }
|
map{ |type| "#{r.platform.path}/repository/#{main_platform.name}/#{type}/#{r.name}" }.
|
||||||
it { should validate_presence_of(:description) }
|
each{ |path| FileUtils.mkdir_p path }
|
||||||
|
r.destroy
|
||||||
|
paths.each{ |path| Dir.exists?(path).should be_false }
|
||||||
|
end
|
||||||
|
|
||||||
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
|
|
||||||
clear_test_root
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -28,6 +28,8 @@ RSpec.configure do |config|
|
||||||
|
|
||||||
config.filter_run_excluding :anonymous_access => !(APP_CONFIG['anonymous_access'])
|
config.filter_run_excluding :anonymous_access => !(APP_CONFIG['anonymous_access'])
|
||||||
|
|
||||||
|
config.before(:all) { init_test_root }
|
||||||
|
config.after(:all) { clear_test_root }
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_session_for(user=nil)
|
def set_session_for(user=nil)
|
||||||
|
@ -65,8 +67,6 @@ def stub_redis
|
||||||
stub(Resque).redis { @redis_instance }
|
stub(Resque).redis { @redis_instance }
|
||||||
end
|
end
|
||||||
|
|
||||||
init_test_root
|
|
||||||
|
|
||||||
def fill_project project
|
def fill_project project
|
||||||
%x(mkdir -p #{project.path} && cp -Rf #{Rails.root}/spec/tests.git/* #{project.path}) # maybe FIXME ?
|
%x(mkdir -p #{project.path} && cp -Rf #{Rails.root}/spec/tests.git/* #{project.path}) # maybe FIXME ?
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue