summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-01-20 21:49:26 +0100
committerJames Edwards-Jones <jedwardsjones@gitlab.com>2017-01-31 22:53:57 +0000
commitc4c8ca04052aaf7d37c2335066381b536df68427 (patch)
tree1f0187a87053be2390670548e96050f65496ee6f /spec
parent6e70870a2e80ea092f8528f727753184eb3265fb (diff)
downloadgitlab-ce-c4c8ca04052aaf7d37c2335066381b536df68427.tar.gz
Added support for zip archives in pages
The ZIP archive size is calculated from artifacts metadata that should get uploaded for new artifacts
Diffstat (limited to 'spec')
-rw-r--r--spec/fixtures/pages.zipbin0 -> 1851 bytes
-rw-r--r--spec/fixtures/pages.zip.metabin0 -> 225 bytes
-rw-r--r--spec/fixtures/pages_empty.zipbin0 -> 160 bytes
-rw-r--r--spec/fixtures/pages_empty.zip.metabin0 -> 116 bytes
-rw-r--r--spec/services/projects/update_pages_worker_spec.rb74
5 files changed, 42 insertions, 32 deletions
diff --git a/spec/fixtures/pages.zip b/spec/fixtures/pages.zip
new file mode 100644
index 00000000000..9558fcd4b94
--- /dev/null
+++ b/spec/fixtures/pages.zip
Binary files differ
diff --git a/spec/fixtures/pages.zip.meta b/spec/fixtures/pages.zip.meta
new file mode 100644
index 00000000000..1e6198a15f0
--- /dev/null
+++ b/spec/fixtures/pages.zip.meta
Binary files differ
diff --git a/spec/fixtures/pages_empty.zip b/spec/fixtures/pages_empty.zip
new file mode 100644
index 00000000000..db3f0334c12
--- /dev/null
+++ b/spec/fixtures/pages_empty.zip
Binary files differ
diff --git a/spec/fixtures/pages_empty.zip.meta b/spec/fixtures/pages_empty.zip.meta
new file mode 100644
index 00000000000..d0b93b3b9c0
--- /dev/null
+++ b/spec/fixtures/pages_empty.zip.meta
Binary files differ
diff --git a/spec/services/projects/update_pages_worker_spec.rb b/spec/services/projects/update_pages_worker_spec.rb
index 0607c025b9e..68e66866340 100644
--- a/spec/services/projects/update_pages_worker_spec.rb
+++ b/spec/services/projects/update_pages_worker_spec.rb
@@ -4,9 +4,7 @@ describe Projects::UpdatePagesService do
let(:project) { create :project }
let(:commit) { create :ci_commit, project: project, sha: project.commit('HEAD').sha }
let(:build) { create :ci_build, commit: commit, ref: 'HEAD' }
- let(:file) { fixture_file_upload(Rails.root + 'spec/fixtures/pages.tar.gz', 'application/octet-stream') }
- let(:empty_file) { fixture_file_upload(Rails.root + 'spec/fixtures/pages_empty.tar.gz', 'application/octet-stream') }
- let(:invalid_file) { fixture_file_upload(Rails.root + 'spec/fixtures/dk.png', 'application/octet-stream') }
+ let(:invalid_file) { fixture_file_upload(Rails.root + 'spec/fixtures/dk.png') }
subject { described_class.new(project, build) }
@@ -14,27 +12,50 @@ describe Projects::UpdatePagesService do
project.remove_pages
end
- context 'for valid file' do
- before { build.update_attributes(artifacts_file: file) }
+ %w(tar.gz zip).each do |format|
+ context "for valid #{format}" do
+ let(:file) { fixture_file_upload(Rails.root + "spec/fixtures/pages.#{format}") }
+ let(:empty_file) { fixture_file_upload(Rails.root + "spec/fixtures/pages_empty.#{format}") }
+ let(:metadata) do
+ filename = Rails.root + "spec/fixtures/pages.#{format}.meta"
+ fixture_file_upload(filename) if File.exists?(filename)
+ end
- it 'succeeds' do
- expect(project.pages_url).to be_nil
- expect(execute).to eq(:success)
- expect(project.pages_url).to_not be_nil
- end
+ before do
+ build.update_attributes(artifacts_file: file)
+ build.update_attributes(artifacts_metadata: metadata)
+ end
- it 'limits pages size' do
- stub_application_setting(max_pages_size: 1)
- expect(execute).to_not eq(:success)
- end
+ it 'succeeds' do
+ expect(project.pages_url).to be_nil
+ expect(execute).to eq(:success)
+ expect(project.pages_url).to_not be_nil
+ end
+
+ it 'limits pages size' do
+ stub_application_setting(max_pages_size: 1)
+ expect(execute).to_not eq(:success)
+ end
- it 'removes pages after destroy' do
- expect(PagesWorker).to receive(:perform_in)
- expect(project.pages_url).to be_nil
- expect(execute).to eq(:success)
- expect(project.pages_url).to_not be_nil
- project.destroy
- expect(Dir.exist?(project.public_pages_path)).to be_falsey
+ it 'removes pages after destroy' do
+ expect(PagesWorker).to receive(:perform_in)
+ expect(project.pages_url).to be_nil
+ expect(execute).to eq(:success)
+ expect(project.pages_url).to_not be_nil
+ project.destroy
+ expect(Dir.exist?(project.public_pages_path)).to be_falsey
+ end
+
+ it 'fails if sha on branch is not latest' do
+ commit.update_attributes(sha: 'old_sha')
+ build.update_attributes(artifacts_file: file)
+ expect(execute).to_not eq(:success)
+ end
+
+ it 'fails for empty file fails' do
+ build.update_attributes(artifacts_file: empty_file)
+ expect(execute).to_not eq(:success)
+ end
end
end
@@ -48,21 +69,10 @@ describe Projects::UpdatePagesService do
expect(execute).to_not eq(:success)
end
- it 'fails for empty file fails' do
- build.update_attributes(artifacts_file: empty_file)
- expect(execute).to_not eq(:success)
- end
-
it 'fails for invalid archive' do
build.update_attributes(artifacts_file: invalid_file)
expect(execute).to_not eq(:success)
end
-
- it 'fails if sha on branch is not latest' do
- commit.update_attributes(sha: 'old_sha')
- build.update_attributes(artifacts_file: file)
- expect(execute).to_not eq(:success)
- end
def execute
subject.execute[:status]