8c899e0a18a27d8717479b84cadd1f0a7883f031Eugen Kuksarequire 'spec_helper'
8c899e0a18a27d8717479b84cadd1f0a7883f031Eugen Kuksa let(:repository_directory) { FactoryGirl.build :repository_directory }
8c899e0a18a27d8717479b84cadd1f0a7883f031Eugen Kuksa let(:repository) { repository_directory.repository }
8c899e0a18a27d8717479b84cadd1f0a7883f031Eugen Kuksa let(:user) { repository_directory.repository.user }
8c899e0a18a27d8717479b84cadd1f0a7883f031Eugen Kuksa expect(repository_directory.valid?).to be_truthy
8c899e0a18a27d8717479b84cadd1f0a7883f031Eugen Kuksa it 'should fail with target_directory but without a name' do
8c899e0a18a27d8717479b84cadd1f0a7883f031Eugen Kuksa let(:dirname) { "#{repository_directory.name}-other" }
1b6bde1f14614dff0f17325686d5c80b7ac37f1cTim Reddehase repository.save_file_only(file, filepath, 'message', user)
1b6bde1f14614dff0f17325686d5c80b7ac37f1cTim Reddehase expect { save_operation }.to change { Commit.all.length }.by(1)
1b6bde1f14614dff0f17325686d5c80b7ac37f1cTim Reddehase it 'should fail when path is the directory' do
1b6bde1f14614dff0f17325686d5c80b7ac37f1cTim Reddehase expect(repository_directory.valid?).to be_falsy
1b6bde1f14614dff0f17325686d5c80b7ac37f1cTim Reddehase it 'should fail when path is the file (with target_directory)' do
1b6bde1f14614dff0f17325686d5c80b7ac37f1cTim Reddehase repository_directory.target_directory = dirname
1b6bde1f14614dff0f17325686d5c80b7ac37f1cTim Reddehase expect(repository_directory.valid?).to be_falsy
1b6bde1f14614dff0f17325686d5c80b7ac37f1cTim Reddehase it 'should fail when path is beneath the file' do
1b6bde1f14614dff0f17325686d5c80b7ac37f1cTim Reddehase repository_directory.name = File.join(filepath, 'beneath')
1b6bde1f14614dff0f17325686d5c80b7ac37f1cTim Reddehase expect(repository_directory.valid?).to be_falsy
1b6bde1f14614dff0f17325686d5c80b7ac37f1cTim Reddehase it 'should fail when path is beneath the file (with target_directory)' do
1b6bde1f14614dff0f17325686d5c80b7ac37f1cTim Reddehase repository_directory.target_directory = filepath
1b6bde1f14614dff0f17325686d5c80b7ac37f1cTim Reddehase expect(repository_directory.valid?).to be_falsy
95a1bcea5bd4cddc4c3dbbdf4dbcf85020fbc8d5Eugen Kuksa let(:repository_directory) { FactoryGirl.build :repository_directory }
95a1bcea5bd4cddc4c3dbbdf4dbcf85020fbc8d5Eugen Kuksa it 'path should be target_directory plus name' do
95a1bcea5bd4cddc4c3dbbdf4dbcf85020fbc8d5Eugen Kuksa to eq(File.join(repository_directory.target_directory, repository_directory.name))
95a1bcea5bd4cddc4c3dbbdf4dbcf85020fbc8d5Eugen Kuksa let(:repository_directory) { FactoryGirl.build :repository_directory }
95a1bcea5bd4cddc4c3dbbdf4dbcf85020fbc8d5Eugen Kuksa let(:repository) { repository_directory.repository }
95a1bcea5bd4cddc4c3dbbdf4dbcf85020fbc8d5Eugen Kuksa let(:user) { repository_directory.repository.user }
95a1bcea5bd4cddc4c3dbbdf4dbcf85020fbc8d5Eugen Kuksa it 'should create the directory in the git repository' do
95a1bcea5bd4cddc4c3dbbdf4dbcf85020fbc8d5Eugen Kuksa expect(repository.path_exists?(repository_directory.target_path)).to be_falsy
95a1bcea5bd4cddc4c3dbbdf4dbcf85020fbc8d5Eugen Kuksa expect(repository.path_exists?(repository_directory.target_path)).to be_truthy
95a1bcea5bd4cddc4c3dbbdf4dbcf85020fbc8d5Eugen Kuksa it 'should create the directory in the git repository in a subdirectory' do
95a1bcea5bd4cddc4c3dbbdf4dbcf85020fbc8d5Eugen Kuksa expect(repository.path_exists?(repository_directory.target_path)).to be_falsy
95a1bcea5bd4cddc4c3dbbdf4dbcf85020fbc8d5Eugen Kuksa expect(repository.path_exists?(repository_directory.target_path)).to be_truthy