repositories_controller_spec.rb revision 7ca38d75d045fade73b81bff6fdf34f4755d75fb
3f4d0b5eb524cbdf9341960fec2155f8be471425Julian Kornbergerrequire 'spec_helper'
3fd79b62dab08e18fedc1c3a5ea3fdaa79b9dd50henning mueller
3fd79b62dab08e18fedc1c3a5ea3fdaa79b9dd50henning muellerdescribe RepositoriesController do
9be412edc76c81a2c6f0251cb4c12bc3a170bc4bJulian Kornberger context 'deleting a repository' do
3f4d0b5eb524cbdf9341960fec2155f8be471425Julian Kornberger let(:ontology){ create :ontology }
9be412edc76c81a2c6f0251cb4c12bc3a170bc4bJulian Kornberger let(:repository){ ontology.repository }
3f4d0b5eb524cbdf9341960fec2155f8be471425Julian Kornberger let(:user){ create(:permission, role: 'owner', item: repository).subject }
3f4d0b5eb524cbdf9341960fec2155f8be471425Julian Kornberger
1437511287777e1ad0b2cfecd0c8022382d09b41Till Mossakowski context 'signed in' do
3fd79b62dab08e18fedc1c3a5ea3fdaa79b9dd50henning mueller before { sign_in user }
3fd79b62dab08e18fedc1c3a5ea3fdaa79b9dd50henning mueller
3fd79b62dab08e18fedc1c3a5ea3fdaa79b9dd50henning mueller context 'successful deletion' do
3fd79b62dab08e18fedc1c3a5ea3fdaa79b9dd50henning mueller before { delete :destroy, id: repository.to_param }
3fd79b62dab08e18fedc1c3a5ea3fdaa79b9dd50henning mueller
6c98f0a5b54fa293c658f6f93de6bd9cd25f9555Till Mossakowski it{ should respond_with :found }
3fd79b62dab08e18fedc1c3a5ea3fdaa79b9dd50henning mueller it{ response.should redirect_to Repository }
1437511287777e1ad0b2cfecd0c8022382d09b41Till Mossakowski end
1437511287777e1ad0b2cfecd0c8022382d09b41Till Mossakowski
1437511287777e1ad0b2cfecd0c8022382d09b41Till Mossakowski context 'unsuccessful deletion' do
3fd79b62dab08e18fedc1c3a5ea3fdaa79b9dd50henning mueller before do
aafe992249de15ae9a789342b4e33d2ab1a28923henning mueller importing_repository = create :repository
aafe992249de15ae9a789342b4e33d2ab1a28923henning mueller importing = create :ontology, repository: importing_repository
1437511287777e1ad0b2cfecd0c8022382d09b41Till Mossakowski create :import_mapping, target: importing, source: ontology
1437511287777e1ad0b2cfecd0c8022382d09b41Till Mossakowski delete :destroy, id: repository.to_param
1437511287777e1ad0b2cfecd0c8022382d09b41Till Mossakowski end
8712a741f8a8aa7a1287d9d1186ca5b1aac0c9b1Christoph Lange
3fd79b62dab08e18fedc1c3a5ea3fdaa79b9dd50henning mueller it 'sets the flash' do
3fd79b62dab08e18fedc1c3a5ea3fdaa79b9dd50henning mueller expect(flash[:error]).to match(/is imported/)
1bc34ba9381d6fe275afff5112b6875e0e961b8bSascha Graef end
1437511287777e1ad0b2cfecd0c8022382d09b41Till Mossakowski
3fd79b62dab08e18fedc1c3a5ea3fdaa79b9dd50henning mueller it{ should respond_with :found }
3fd79b62dab08e18fedc1c3a5ea3fdaa79b9dd50henning mueller it{ response.should redirect_to repository }
3fd79b62dab08e18fedc1c3a5ea3fdaa79b9dd50henning mueller end
8a0f5157a23c03ebf84a52cabf360331607af31eEugen Kuksa end
18367cb6c2f8e4885aa3124f08cf29636819c0b8Eugen Kuksa end
8a0f5157a23c03ebf84a52cabf360331607af31eEugen Kuksa
6b03dc1cf7da7a1e294db2f5d1969cf790cbfc60henning mueller context 'Repository instance' do
2a8317c651813585c2e37896ede11a29a786a137Julian Kornberger render_views
2a8317c651813585c2e37896ede11a29a786a137Julian Kornberger
2a8317c651813585c2e37896ede11a29a786a137Julian Kornberger let!(:repository) { create :repository }
b93ea904c4d59806150a385e50734d87d63c79c7Sascha Graef
2a8317c651813585c2e37896ede11a29a786a137Julian Kornberger context 'on GET to index' do
1bc34ba9381d6fe275afff5112b6875e0e961b8bSascha Graef before { get :index }
b93ea904c4d59806150a385e50734d87d63c79c7Sascha Graef
ba885be376b9fe51c8629f47cc6499e6488368a7Julian Kornberger it { should respond_with :success }
e4d0b8b9a363ea0f8cd85c452a2979a89a0506dfSascha Graef it { should render_template :index }
e4d0b8b9a363ea0f8cd85c452a2979a89a0506dfSascha Graef it { should render_template 'repositories/_repository' }
e4d0b8b9a363ea0f8cd85c452a2979a89a0506dfSascha Graef end
e4d0b8b9a363ea0f8cd85c452a2979a89a0506dfSascha Graef
e4d0b8b9a363ea0f8cd85c452a2979a89a0506dfSascha Graef context 'on GET to show' do
e4d0b8b9a363ea0f8cd85c452a2979a89a0506dfSascha Graef context 'requesting standard representation' do
3fd79b62dab08e18fedc1c3a5ea3fdaa79b9dd50henning mueller before { get :show, id: repository.path }
3fd79b62dab08e18fedc1c3a5ea3fdaa79b9dd50henning mueller
3fd79b62dab08e18fedc1c3a5ea3fdaa79b9dd50henning mueller it { should respond_with :success }
1437511287777e1ad0b2cfecd0c8022382d09b41Till Mossakowski it { should render_template :show }
33004b5db3f04ff81e7717782dda434ae0eb326ahardik end
1437511287777e1ad0b2cfecd0c8022382d09b41Till Mossakowski
3fd79b62dab08e18fedc1c3a5ea3fdaa79b9dd50henning mueller end
3fd79b62dab08e18fedc1c3a5ea3fdaa79b9dd50henning mueller end
b93ea904c4d59806150a385e50734d87d63c79c7Sascha Graef
b93ea904c4d59806150a385e50734d87d63c79c7Sascha Graef context 'creating a clone', :process_jobs_synchronously do
b93ea904c4d59806150a385e50734d87d63c79c7Sascha Graef context 'signed in' do
let(:user) { create :user }
let(:git_repository) { create :git_repository }
before do
sign_in user
end
context 'mirror' do
before do
post :create, repository: { name: 'repo',
source_address: "file://#{git_repository.path}",
remote_type: 'mirror' }
end
after do
FileUtils.rm_rf(git_repository.path)
end
it { should respond_with :found }
it { response.should redirect_to Repository.find_by_path('repo') }
it 'should have created a mirrored repository' do
expect(Repository.find_by_path('repo').mirror?).to be_truthy
end
end
context 'fork' do
before do
post :create, repository: { name: 'repo',
source_address: "file://#{git_repository.path}",
remote_type: 'fork' }
end
it { should respond_with :found }
it { response.should redirect_to Repository.find_by_path('repo') }
it 'should have created a non-mirrored repository' do
expect(Repository.find_by_path('repo').mirror?).to be_falsy
end
end
end
end
end