symlinks_spec.rb revision c18eca06bdaab35372205f3ed1779cabc5897709
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksarequire 'spec_helper'
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksadescribe Repository::Symlinks do
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa context 'public repository' do
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa let(:repository) { create :repository }
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa shared_examples 'symlink_creation' do |category|
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa let(:link_path) { repository.symlink_path(category) }
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa let(:link_target) { File.readlink(link_path) }
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa it "symlink for #{category} created" do
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa expect(link_target).to eq(repository.local_path.to_s)
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa end
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa context 'repository destroy' do
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa before { repository.destroy }
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa it "symlink for #{category} removed" do
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa expect(repository.symlink_path(category).exist?).to be(false)
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa end
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa end
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa end
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa include_examples('symlink_creation', :git_daemon)
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa include_examples('symlink_creation', :git_ssh)
c18eca06bdaab35372205f3ed1779cabc5897709Eugen Kuksa
c18eca06bdaab35372205f3ed1779cabc5897709Eugen Kuksa context 'made private' do
c18eca06bdaab35372205f3ed1779cabc5897709Eugen Kuksa before do
c18eca06bdaab35372205f3ed1779cabc5897709Eugen Kuksa repository.access = 'private_rw'
c18eca06bdaab35372205f3ed1779cabc5897709Eugen Kuksa repository.save!
c18eca06bdaab35372205f3ed1779cabc5897709Eugen Kuksa end
c18eca06bdaab35372205f3ed1779cabc5897709Eugen Kuksa
c18eca06bdaab35372205f3ed1779cabc5897709Eugen Kuksa it 'deletes the git_daemon symlink' do
c18eca06bdaab35372205f3ed1779cabc5897709Eugen Kuksa expect(repository.symlink_path(:git_daemon).exist?).to be(false)
c18eca06bdaab35372205f3ed1779cabc5897709Eugen Kuksa end
c18eca06bdaab35372205f3ed1779cabc5897709Eugen Kuksa
c18eca06bdaab35372205f3ed1779cabc5897709Eugen Kuksa it 'keeps the git_ssh symlink' do
c18eca06bdaab35372205f3ed1779cabc5897709Eugen Kuksa expect(repository.symlink_path(:git_ssh).exist?).to be(true)
c18eca06bdaab35372205f3ed1779cabc5897709Eugen Kuksa end
c18eca06bdaab35372205f3ed1779cabc5897709Eugen Kuksa end
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa end
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa context 'private repository' do
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa let(:repository) { create :repository, access: 'private_rw' }
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa context 'git_daemon' do
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa let(:category) { :git_daemon }
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa let(:link_path) { repository.symlink_path(category) }
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa let(:link_target) { File.readlink(link_path) }
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa it "symlink for git_daemon not created" do
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa expect(repository.symlink_path(category).exist?).to be(false)
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa end
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa
c18eca06bdaab35372205f3ed1779cabc5897709Eugen Kuksa context 'made public' do
c18eca06bdaab35372205f3ed1779cabc5897709Eugen Kuksa before do
c18eca06bdaab35372205f3ed1779cabc5897709Eugen Kuksa repository.access = 'public_r'
c18eca06bdaab35372205f3ed1779cabc5897709Eugen Kuksa repository.save!
c18eca06bdaab35372205f3ed1779cabc5897709Eugen Kuksa end
c18eca06bdaab35372205f3ed1779cabc5897709Eugen Kuksa
c18eca06bdaab35372205f3ed1779cabc5897709Eugen Kuksa it 'creates the symlink' do
c18eca06bdaab35372205f3ed1779cabc5897709Eugen Kuksa expect(repository.symlink_path(category).exist?).to be(true)
c18eca06bdaab35372205f3ed1779cabc5897709Eugen Kuksa end
c18eca06bdaab35372205f3ed1779cabc5897709Eugen Kuksa end
c18eca06bdaab35372205f3ed1779cabc5897709Eugen Kuksa
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa context 'repository destroy' do
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa before { repository.destroy }
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa it "symlink for git_daemon removed" do
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa expect(repository.symlink_path(category).exist?).to be(false)
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa end
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa end
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa end
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa context 'git_ssh' do
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa let(:category) { :git_ssh }
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa let(:link_path) { repository.symlink_path(category) }
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa let(:link_target) { File.readlink(link_path) }
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa it "symlink for git_ssh created" do
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa expect(link_target).to eq(repository.local_path.to_s)
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa end
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa context 'repository destroy' do
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa before { repository.destroy }
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa it "symlink for git_ssh removed" do
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa expect(repository.symlink_path(category).exist?).to be(false)
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa end
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa end
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa end
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksa end
314227c349d7c3a2aec4b39e11d6770b3db8a652Eugen Kuksaend