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
path: root/spec
diff options
context:
space:
mode:
authorblackst0ne <blackst0ne.ru@gmail.com>2018-05-08 02:39:37 +0300
committerRobert Speicher <robert@gitlab.com>2018-05-08 02:39:37 +0300
commitd550211eb101d82da2887e1eccde5c338388669d (patch)
treeb33a6babbc531e23ff2bf2b3bb9ad170d1074624 /spec
parentf9fcd2b4100d54255c2508439e9f924543aed7a7 (diff)
Replace the `project/builds/artifacts.feature` spinach test with an rspec analog
Diffstat (limited to 'spec')
-rw-r--r--spec/features/projects/artifacts/browse_spec.rb67
-rw-r--r--spec/features/projects/artifacts/download_spec.rb61
-rw-r--r--spec/features/projects/artifacts/user_browses_artifacts_spec.rb110
-rw-r--r--spec/features/projects/artifacts/user_downloads_artifacts_spec.rb44
4 files changed, 154 insertions, 128 deletions
diff --git a/spec/features/projects/artifacts/browse_spec.rb b/spec/features/projects/artifacts/browse_spec.rb
deleted file mode 100644
index cb69aff8d5f..00000000000
--- a/spec/features/projects/artifacts/browse_spec.rb
+++ /dev/null
@@ -1,67 +0,0 @@
-require 'spec_helper'
-
-feature 'Browse artifact', :js do
- let(:project) { create(:project, :public) }
- let(:pipeline) { create(:ci_empty_pipeline, project: project) }
- let(:job) { create(:ci_build, :artifacts, pipeline: pipeline) }
- let(:browse_url) do
- browse_path('other_artifacts_0.1.2')
- end
-
- def browse_path(path)
- browse_project_job_artifacts_path(project, job, path)
- end
-
- context 'when visiting old URL' do
- before do
- visit browse_url.sub('/-/jobs', '/builds')
- end
-
- it "redirects to new URL" do
- expect(page.current_path).to eq(browse_url)
- end
- end
-
- context 'when browsing a directory with an text file' do
- let(:txt_entry) { job.artifacts_metadata_entry('other_artifacts_0.1.2/doc_sample.txt') }
-
- before do
- allow(Gitlab.config.pages).to receive(:enabled).and_return(true)
- allow(Gitlab.config.pages).to receive(:artifacts_server).and_return(true)
- end
-
- context 'when the project is public' do
- it "shows external link icon and styles" do
- visit browse_url
-
- link = first('.tree-item-file-external-link')
-
- expect(page).to have_link('doc_sample.txt', href: file_project_job_artifacts_path(project, job, path: txt_entry.blob.path))
- expect(link[:target]).to eq('_blank')
- expect(link[:rel]).to include('noopener')
- expect(link[:rel]).to include('noreferrer')
- expect(page).to have_selector('.js-artifact-tree-external-icon')
- end
- end
-
- context 'when the project is private' do
- let!(:private_project) { create(:project, :private) }
- let(:pipeline) { create(:ci_empty_pipeline, project: private_project) }
- let(:job) { create(:ci_build, :artifacts, pipeline: pipeline) }
- let(:user) { create(:user) }
-
- before do
- private_project.add_developer(user)
-
- sign_in(user)
- end
-
- it 'shows internal link styles' do
- visit browse_project_job_artifacts_path(private_project, job, 'other_artifacts_0.1.2')
-
- expect(page).to have_link('doc_sample.txt')
- expect(page).not_to have_selector('.js-artifact-tree-external-icon')
- end
- end
- end
-end
diff --git a/spec/features/projects/artifacts/download_spec.rb b/spec/features/projects/artifacts/download_spec.rb
deleted file mode 100644
index 6f76c14910b..00000000000
--- a/spec/features/projects/artifacts/download_spec.rb
+++ /dev/null
@@ -1,61 +0,0 @@
-require 'spec_helper'
-
-feature 'Download artifact' do
- let(:project) { create(:project, :public) }
- let(:pipeline) { create(:ci_empty_pipeline, status: :success, project: project) }
- let(:job) { create(:ci_build, :artifacts, :success, pipeline: pipeline) }
-
- shared_examples 'downloading' do
- it 'downloads the zip' do
- expect(page.response_headers['Content-Disposition'])
- .to eq(%Q{attachment; filename="#{job.artifacts_file.filename}"})
-
- # Check the content does match, but don't print this as error message
- expect(page.source.b == job.artifacts_file.file.read.b)
- end
- end
-
- context 'when downloading' do
- before do
- visit download_url
- end
-
- context 'via job id' do
- let(:download_url) do
- download_project_job_artifacts_path(project, job)
- end
-
- it_behaves_like 'downloading'
- end
-
- context 'via branch name and job name' do
- let(:download_url) do
- latest_succeeded_project_artifacts_path(project, "#{pipeline.ref}/download", job: job.name)
- end
-
- it_behaves_like 'downloading'
- end
- end
-
- context 'when visiting old URL' do
- before do
- visit download_url.sub('/-/jobs', '/builds')
- end
-
- context 'via job id' do
- let(:download_url) do
- download_project_job_artifacts_path(project, job)
- end
-
- it_behaves_like 'downloading'
- end
-
- context 'via branch name and job name' do
- let(:download_url) do
- latest_succeeded_project_artifacts_path(project, "#{pipeline.ref}/download", job: job.name)
- end
-
- it_behaves_like 'downloading'
- end
- end
-end
diff --git a/spec/features/projects/artifacts/user_browses_artifacts_spec.rb b/spec/features/projects/artifacts/user_browses_artifacts_spec.rb
new file mode 100644
index 00000000000..9ebbbaea911
--- /dev/null
+++ b/spec/features/projects/artifacts/user_browses_artifacts_spec.rb
@@ -0,0 +1,110 @@
+require "spec_helper"
+
+describe "User browses artifacts" do
+ let(:project) { create(:project, :public) }
+ let(:pipeline) { create(:ci_empty_pipeline, project: project) }
+ let(:job) { create(:ci_build, :artifacts, pipeline: pipeline) }
+ let(:browse_url) { browse_project_job_artifacts_path(project, job, "other_artifacts_0.1.2") }
+
+ context "when visiting old URL" do
+ it "redirects to new URL" do
+ visit(browse_url.sub("/-/jobs", "/builds"))
+
+ expect(page.current_path).to eq(browse_url)
+ end
+ end
+
+ context "when browsing artifacts root directory" do
+ before do
+ visit(browse_project_job_artifacts_path(project, job))
+ end
+
+ it "shows artifacts" do
+ expect(page).not_to have_selector(".build-sidebar")
+
+ page.within(".tree-table") do
+ expect(page).to have_no_content("..")
+ .and have_content("other_artifacts_0.1.2")
+ .and have_content("ci_artifacts.txt")
+ .and have_content("rails_sample.jpg")
+ end
+
+ page.within(".build-header") do
+ expect(page).to have_content("Job ##{job.id} in pipeline ##{pipeline.id} for #{pipeline.short_sha}")
+ end
+ end
+
+ it "shows an artifact" do
+ click_link("ci_artifacts.txt")
+
+ expect(page).to have_link("download it")
+ end
+ end
+
+ context "when browsing a directory with UTF-8 characters in its name" do
+ before do
+ visit(browse_project_job_artifacts_path(project, job))
+ end
+
+ it "shows correct content", :js do
+ page.within(".tree-table") do
+ click_link("tests_encoding")
+
+ expect(page).to have_no_content("non-utf8-dir")
+
+ click_link("utf8 test dir ✓")
+
+ expect(page).to have_content("..").and have_content("regular_file_2")
+ end
+ end
+ end
+
+ context "when browsing a directory with a text file" do
+ let(:txt_entry) { job.artifacts_metadata_entry("other_artifacts_0.1.2/doc_sample.txt") }
+
+ before do
+ allow(Gitlab.config.pages).to receive(:enabled).and_return(true)
+ allow(Gitlab.config.pages).to receive(:artifacts_server).and_return(true)
+ end
+
+ context "when the project is public" do
+ before do
+ visit(browse_url)
+ end
+
+ it "shows correct content" do
+ link = first(".tree-item-file-external-link")
+
+ expect(link[:target]).to eq("_blank")
+ expect(link[:rel]).to include("noopener").and include("noreferrer")
+ expect(page).to have_link("doc_sample.txt", href: file_project_job_artifacts_path(project, job, path: txt_entry.blob.path))
+ .and have_selector(".js-artifact-tree-external-icon")
+
+ page.within(".tree-table") do
+ expect(page).to have_content("..").and have_content("another-subdirectory")
+ end
+
+ page.within(".repo-breadcrumb") do
+ expect(page).to have_content("other_artifacts_0.1.2")
+ end
+ end
+ end
+
+ context "when the project is private" do
+ let!(:private_project) { create(:project, :private) }
+ let(:pipeline) { create(:ci_empty_pipeline, project: private_project) }
+ let(:job) { create(:ci_build, :artifacts, pipeline: pipeline) }
+ let(:user) { create(:user) }
+
+ before do
+ private_project.add_developer(user)
+
+ sign_in(user)
+
+ visit(browse_project_job_artifacts_path(private_project, job, "other_artifacts_0.1.2"))
+ end
+
+ it { expect(page).to have_link("doc_sample.txt").and have_no_selector(".js-artifact-tree-external-icon") }
+ end
+ end
+end
diff --git a/spec/features/projects/artifacts/user_downloads_artifacts_spec.rb b/spec/features/projects/artifacts/user_downloads_artifacts_spec.rb
new file mode 100644
index 00000000000..67ed2f18d76
--- /dev/null
+++ b/spec/features/projects/artifacts/user_downloads_artifacts_spec.rb
@@ -0,0 +1,44 @@
+require "spec_helper"
+
+describe "User downloads artifacts" do
+ set(:project) { create(:project, :public) }
+ set(:pipeline) { create(:ci_empty_pipeline, status: :success, project: project) }
+ set(:job) { create(:ci_build, :artifacts, :success, pipeline: pipeline) }
+
+ shared_examples "downloading" do
+ it "downloads the zip" do
+ expect(page.response_headers["Content-Disposition"]).to eq(%Q{attachment; filename="#{job.artifacts_file.filename}"})
+ expect(page.response_headers['Content-Transfer-Encoding']).to eq("binary")
+ expect(page.response_headers['Content-Type']).to eq("application/zip")
+ expect(page.source.b).to eq(job.artifacts_file.file.read.b)
+ end
+ end
+
+ context "when downloading" do
+ before do
+ visit(url)
+ end
+
+ context "via job id" do
+ set(:url) { download_project_job_artifacts_path(project, job) }
+
+ it_behaves_like "downloading"
+ end
+
+ context "via branch name and job name" do
+ set(:url) { latest_succeeded_project_artifacts_path(project, "#{pipeline.ref}/download", job: job.name) }
+
+ it_behaves_like "downloading"
+ end
+
+ context "via clicking the `Download` button" do
+ set(:url) { project_job_path(project, job) }
+
+ before do
+ click_link("Download")
+ end
+
+ it_behaves_like "downloading"
+ end
+ end
+end