Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Vosmaer <contact@jacobvosmaer.nl>2015-07-07 20:03:29 +0300
committerJacob Vosmaer <contact@jacobvosmaer.nl>2015-07-07 20:03:29 +0300
commit0194dd4182778b6bbf6b02f5d57e995ecbb43066 (patch)
tree930c86f7ced2a9fd40a51deda58f6d141ca2b735 /spec/tasks
parentbb50b7fcd0161a7b9f0f87cb395e355a87a9dd17 (diff)
Add tests for custom backup archive file permissions
Diffstat (limited to 'spec/tasks')
-rw-r--r--spec/tasks/gitlab/backup_rake_spec.rb31
1 files changed, 27 insertions, 4 deletions
diff --git a/spec/tasks/gitlab/backup_rake_spec.rb b/spec/tasks/gitlab/backup_rake_spec.rb
index cdcfeba8d1f..e1f4a887dcc 100644
--- a/spec/tasks/gitlab/backup_rake_spec.rb
+++ b/spec/tasks/gitlab/backup_rake_spec.rb
@@ -60,7 +60,7 @@ describe 'gitlab:app namespace rake task' do
Dir.glob(File.join(Gitlab.config.backup.path, '*_gitlab_backup.tar'))
end
- before :all do
+ def create_backup
# Record the existing backup tars so we don't touch them
existing_tars = tars_glob
@@ -73,13 +73,36 @@ describe 'gitlab:app namespace rake task' do
@backup_tar = (tars_glob - existing_tars).first
end
+ before :all do
+ create_backup
+ end
+
after :all do
FileUtils.rm(@backup_tar)
end
- it 'should set correct permissions on the tar file' do
- expect(File.exist?(@backup_tar)).to be_truthy
- expect(File::Stat.new(@backup_tar).mode.to_s(8)).to eq('100600')
+ context 'archive file permissions' do
+ it 'should set correct permissions on the tar file' do
+ expect(File.exist?(@backup_tar)).to be_truthy
+ expect(File::Stat.new(@backup_tar).mode.to_s(8)).to eq('100600')
+ end
+
+ context 'with custom archive_permissions' do
+ before do
+ allow(Gitlab.config.backup).to receive(:archive_permissions).and_return(0651)
+ # We created a backup in a before(:all) so it got the default permissions.
+ # We now need to do some work to create a _new_ backup file using our stub.
+ FileUtils.rm(@backup_tar)
+ Rake::Task["gitlab:backup:db:create"].reenable
+ Rake::Task["gitlab:backup:repo:create"].reenable
+ Rake::Task["gitlab:backup:uploads:create"].reenable
+ create_backup
+ end
+
+ it 'uses the custom permissions' do
+ expect(File::Stat.new(@backup_tar).mode.to_s(8)).to eq('100651')
+ end
+ end
end
it 'should set correct permissions on the tar contents' do