diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/projects/merge_requests_controller_spec.rb | 188 | ||||
-rw-r--r-- | spec/factories/ci/pipelines.rb | 11 | ||||
-rw-r--r-- | spec/factories/merge_requests.rb | 12 | ||||
-rw-r--r-- | spec/features/merge_request/user_sees_merge_widget_spec.rb | 49 | ||||
-rw-r--r-- | spec/features/projects/pipelines/pipeline_spec.rb | 4 | ||||
-rw-r--r-- | spec/features/signed_commits_spec.rb | 30 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/config/entry/artifacts_spec.rb | 86 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/yaml_processor_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/ci/build_spec.rb | 37 | ||||
-rw-r--r-- | spec/models/merge_request_spec.rb | 57 | ||||
-rw-r--r-- | spec/serializers/merge_request_widget_entity_spec.rb | 22 | ||||
-rw-r--r-- | spec/services/ci/find_exposed_artifacts_service_spec.rb | 147 | ||||
-rw-r--r-- | spec/tasks/gitlab/shell_rake_spec.rb | 2 | ||||
-rw-r--r-- | spec/views/projects/show.html.haml_spec.rb | 41 | ||||
-rw-r--r-- | spec/views/projects/tree/show.html.haml_spec.rb | 45 |
15 files changed, 717 insertions, 16 deletions
diff --git a/spec/controllers/projects/merge_requests_controller_spec.rb b/spec/controllers/projects/merge_requests_controller_spec.rb index ea702792557..827b34b8850 100644 --- a/spec/controllers/projects/merge_requests_controller_spec.rb +++ b/spec/controllers/projects/merge_requests_controller_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' describe Projects::MergeRequestsController do include ProjectForksHelper + include Gitlab::Routing let(:project) { create(:project, :repository) } let(:user) { project.owner } @@ -206,7 +207,7 @@ describe Projects::MergeRequestsController do it 'redirects to last_page if page number is larger than number of pages' do get_merge_requests(last_page + 1) - expect(response).to redirect_to(namespace_project_merge_requests_path(page: last_page, state: controller.params[:state], scope: controller.params[:scope])) + expect(response).to redirect_to(project_merge_requests_path(project, page: last_page, state: controller.params[:state], scope: controller.params[:scope])) end it 'redirects to specified page' do @@ -227,7 +228,7 @@ describe Projects::MergeRequestsController do host: external_host } - expect(response).to redirect_to(namespace_project_merge_requests_path(page: last_page, state: controller.params[:state], scope: controller.params[:scope])) + expect(response).to redirect_to(project_merge_requests_path(project, page: last_page, state: controller.params[:state], scope: controller.params[:scope])) end end @@ -770,6 +771,189 @@ describe Projects::MergeRequestsController do end end + describe 'GET exposed_artifacts' do + let(:merge_request) do + create(:merge_request, + :with_merge_request_pipeline, + target_project: project, + source_project: project) + end + + let(:pipeline) do + create(:ci_pipeline, + :success, + project: merge_request.source_project, + ref: merge_request.source_branch, + sha: merge_request.diff_head_sha) + end + + let!(:job) { create(:ci_build, pipeline: pipeline, options: job_options) } + let!(:job_metadata) { create(:ci_job_artifact, :metadata, job: job) } + + before do + allow_any_instance_of(MergeRequest) + .to receive(:find_exposed_artifacts) + .and_return(report) + + allow_any_instance_of(MergeRequest) + .to receive(:actual_head_pipeline) + .and_return(pipeline) + end + + subject do + get :exposed_artifacts, params: { + namespace_id: project.namespace.to_param, + project_id: project, + id: merge_request.iid + }, + format: :json + end + + describe 'permissions on a public project with private CI/CD' do + let(:project) { create :project, :repository, :public, :builds_private } + let(:report) { { status: :parsed, data: [] } } + let(:job_options) { {} } + + context 'while signed out' do + before do + sign_out(user) + end + + it 'responds with a 404' do + subject + + expect(response).to have_gitlab_http_status(404) + expect(response.body).to be_blank + end + end + + context 'while signed in as an unrelated user' do + before do + sign_in(create(:user)) + end + + it 'responds with a 404' do + subject + + expect(response).to have_gitlab_http_status(404) + expect(response.body).to be_blank + end + end + end + + context 'when pipeline has jobs with exposed artifacts' do + let(:job_options) do + { + artifacts: { + paths: ['ci_artifacts.txt'], + expose_as: 'Exposed artifact' + } + } + end + + context 'when fetching exposed artifacts is in progress' do + let(:report) { { status: :parsing } } + + it 'sends polling interval' do + expect(Gitlab::PollingInterval).to receive(:set_header) + + subject + end + + it 'returns 204 HTTP status' do + subject + + expect(response).to have_gitlab_http_status(:no_content) + end + end + + context 'when fetching exposed artifacts is completed' do + let(:data) do + Ci::GenerateExposedArtifactsReportService.new(project, user) + .execute(nil, pipeline) + end + + let(:report) { { status: :parsed, data: data } } + + it 'returns exposed artifacts' do + subject + + expect(response).to have_gitlab_http_status(200) + expect(json_response['status']).to eq('parsed') + expect(json_response['data']).to eq([{ + 'job_name' => 'test', + 'job_path' => project_job_path(project, job), + 'url' => file_project_job_artifacts_path(project, job, 'ci_artifacts.txt'), + 'text' => 'Exposed artifact' + }]) + end + end + + context 'when something went wrong on our system' do + let(:report) { {} } + + it 'does not send polling interval' do + expect(Gitlab::PollingInterval).not_to receive(:set_header) + + subject + end + + it 'returns 500 HTTP status' do + subject + + expect(response).to have_gitlab_http_status(:internal_server_error) + expect(json_response).to eq({ 'status_reason' => 'Unknown error' }) + end + end + + context 'when feature flag :ci_expose_arbitrary_artifacts_in_mr is disabled' do + let(:job_options) do + { + artifacts: { + paths: ['ci_artifacts.txt'], + expose_as: 'Exposed artifact' + } + } + end + let(:report) { double } + + before do + stub_feature_flags(ci_expose_arbitrary_artifacts_in_mr: false) + end + + it 'does not send polling interval' do + expect(Gitlab::PollingInterval).not_to receive(:set_header) + + subject + end + + it 'returns 204 HTTP status' do + subject + + expect(response).to have_gitlab_http_status(:no_content) + end + end + end + + context 'when pipeline does not have jobs with exposed artifacts' do + let(:report) { double } + let(:job_options) do + { + artifacts: { + paths: ['ci_artifacts.txt'] + } + } + end + + it 'returns no content' do + subject + + expect(response).to have_gitlab_http_status(204) + expect(response.body).to be_empty + end + end + end + describe 'GET test_reports' do let(:merge_request) do create(:merge_request, diff --git a/spec/factories/ci/pipelines.rb b/spec/factories/ci/pipelines.rb index fefd89728e6..39ab574cc76 100644 --- a/spec/factories/ci/pipelines.rb +++ b/spec/factories/ci/pipelines.rb @@ -95,6 +95,17 @@ FactoryBot.define do end end + trait :with_exposed_artifacts do + status { :success } + + after(:build) do |pipeline, evaluator| + pipeline.builds << build(:ci_build, :artifacts, + pipeline: pipeline, + project: pipeline.project, + options: { artifacts: { expose_as: 'the artifact', paths: ['ci_artifacts.txt'] } }) + end + end + trait :with_job do after(:build) do |pipeline, evaluator| pipeline.builds << build(:ci_build, pipeline: pipeline, project: pipeline.project) diff --git a/spec/factories/merge_requests.rb b/spec/factories/merge_requests.rb index d16e0c10671..13612214e72 100644 --- a/spec/factories/merge_requests.rb +++ b/spec/factories/merge_requests.rb @@ -120,6 +120,18 @@ FactoryBot.define do end end + trait :with_exposed_artifacts do + after(:build) do |merge_request| + merge_request.head_pipeline = build( + :ci_pipeline, + :success, + :with_exposed_artifacts, + project: merge_request.source_project, + ref: merge_request.source_branch, + sha: merge_request.diff_head_sha) + end + end + trait :with_legacy_detached_merge_request_pipeline do after(:create) do |merge_request| merge_request.pipelines_for_merge_request << create(:ci_pipeline, diff --git a/spec/features/merge_request/user_sees_merge_widget_spec.rb b/spec/features/merge_request/user_sees_merge_widget_spec.rb index 6b6226ad1c5..9fadd46ed44 100644 --- a/spec/features/merge_request/user_sees_merge_widget_spec.rb +++ b/spec/features/merge_request/user_sees_merge_widget_spec.rb @@ -5,6 +5,7 @@ require 'spec_helper' describe 'Merge request > User sees merge widget', :js do include ProjectForksHelper include TestReportsHelper + include ReactiveCachingHelpers let(:project) { create(:project, :repository) } let(:project_only_mwps) { create(:project, :repository, only_allow_merge_if_pipeline_succeeds: true) } @@ -435,6 +436,54 @@ describe 'Merge request > User sees merge widget', :js do end end + context 'exposed artifacts' do + subject { visit project_merge_request_path(project, merge_request) } + + context 'when merge request has exposed artifacts' do + let(:merge_request) { create(:merge_request, :with_exposed_artifacts, source_project: project) } + let(:job) { merge_request.head_pipeline.builds.last } + let!(:artifacts_metadata) { create(:ci_job_artifact, :metadata, job: job) } + + context 'when result has not been parsed yet' do + it 'shows parsing status' do + subject + + expect(page).to have_content('Loading artifacts') + end + end + + context 'when result has been parsed' do + before do + allow_any_instance_of(MergeRequest).to receive(:find_exposed_artifacts).and_return( + status: :parsed, data: [ + { + text: "the artifact", + url: "/namespace1/project1/-/jobs/1/artifacts/file/ci_artifacts.txt", + job_path: "/namespace1/project1/-/jobs/1", + job_name: "test" + } + ]) + end + + it 'shows the parsed results' do + subject + + expect(page).to have_content('View exposed artifact') + end + end + end + + context 'when merge request does not have exposed artifacts' do + let(:merge_request) { create(:merge_request, source_project: project) } + + it 'does not show parsing status' do + subject + + expect(page).not_to have_content('Loading artifacts') + end + end + end + context 'when merge request has test reports' do let!(:head_pipeline) do create(:ci_pipeline, diff --git a/spec/features/projects/pipelines/pipeline_spec.rb b/spec/features/projects/pipelines/pipeline_spec.rb index 04adb1ec6af..66807eb1c17 100644 --- a/spec/features/projects/pipelines/pipeline_spec.rb +++ b/spec/features/projects/pipelines/pipeline_spec.rb @@ -778,10 +778,10 @@ describe 'Pipeline', :js do expect(page).to have_content(failed_build.stage) end - it 'does not show trace' do + it 'does not show log' do subject - expect(page).to have_content('No job trace') + expect(page).to have_content('No job log') end end diff --git a/spec/features/signed_commits_spec.rb b/spec/features/signed_commits_spec.rb index 70e6978a7b6..2615e8400a4 100644 --- a/spec/features/signed_commits_spec.rb +++ b/spec/features/signed_commits_spec.rb @@ -152,4 +152,34 @@ describe 'GPG signed commits' do end end end + + context 'view signed commit on the tree view', :js do + shared_examples 'a commit with a signature' do + before do + visit project_tree_path(project, 'signed-commits') + end + + it 'displays commit signature' do + expect(page).to have_button 'Unverified' + + click_on 'Unverified' + + within '.popover' do + expect(page).to have_content 'This commit was signed with an unverified signature' + end + end + end + + context 'with vue tree view enabled' do + it_behaves_like 'a commit with a signature' + end + + context 'with vue tree view disabled' do + before do + stub_feature_flags(vue_file_list: false) + end + + it_behaves_like 'a commit with a signature' + end + end end diff --git a/spec/lib/gitlab/ci/config/entry/artifacts_spec.rb b/spec/lib/gitlab/ci/config/entry/artifacts_spec.rb index a7f457e0f5e..513a9b8f2b4 100644 --- a/spec/lib/gitlab/ci/config/entry/artifacts_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/artifacts_spec.rb @@ -28,6 +28,14 @@ describe Gitlab::Ci::Config::Entry::Artifacts do expect(entry.value).to eq config end end + + context "when value includes 'expose_as' keyword" do + let(:config) { { paths: %w[results.txt], expose_as: "Test results" } } + + it 'returns general artifact and report-type artifacts configuration' do + expect(entry.value).to eq config + end + end end context 'when entry value is not correct' do @@ -58,6 +66,84 @@ describe Gitlab::Ci::Config::Entry::Artifacts do .to include 'artifacts reports should be a hash' end end + + context "when 'expose_as' is not a string" do + let(:config) { { paths: %w[results.txt], expose_as: 1 } } + + it 'reports error' do + expect(entry.errors) + .to include 'artifacts expose as should be a string' + end + end + + context "when 'expose_as' is too long" do + let(:config) { { paths: %w[results.txt], expose_as: 'A' * 101 } } + + it 'reports error' do + expect(entry.errors) + .to include 'artifacts expose as is too long (maximum is 100 characters)' + end + end + + context "when 'expose_as' is an empty string" do + let(:config) { { paths: %w[results.txt], expose_as: '' } } + + it 'reports error' do + expect(entry.errors) + .to include 'artifacts expose as ' + Gitlab::Ci::Config::Entry::Artifacts::EXPOSE_AS_ERROR_MESSAGE + end + end + + context "when 'expose_as' contains invalid characters" do + let(:config) do + { paths: %w[results.txt], expose_as: '<script>alert("xss");</script>' } + end + + it 'reports error' do + expect(entry.errors) + .to include 'artifacts expose as ' + Gitlab::Ci::Config::Entry::Artifacts::EXPOSE_AS_ERROR_MESSAGE + end + end + + context "when 'expose_as' is used without 'paths'" do + let(:config) { { expose_as: 'Test results' } } + + it 'reports error' do + expect(entry.errors) + .to include "artifacts paths can't be blank" + end + end + + context "when 'paths' includes '*' and 'expose_as' is defined" do + let(:config) { { expose_as: 'Test results', paths: ['test.txt', 'test*.txt'] } } + + it 'reports error' do + expect(entry.errors) + .to include "artifacts paths can't contain '*' when used with 'expose_as'" + end + end + end + + context 'when feature flag :ci_expose_arbitrary_artifacts_in_mr is disabled' do + before do + stub_feature_flags(ci_expose_arbitrary_artifacts_in_mr: false) + end + + context 'when syntax is correct' do + let(:config) { { expose_as: 'Test results', paths: ['test.txt'] } } + + it 'is valid' do + expect(entry.errors).to be_empty + end + end + + context 'when syntax for :expose_as is incorrect' do + let(:config) { { paths: %w[results.txt], expose_as: '' } } + + it 'is valid' do + expect(entry.errors).to be_empty + end + end end end end diff --git a/spec/lib/gitlab/ci/yaml_processor_spec.rb b/spec/lib/gitlab/ci/yaml_processor_spec.rb index cb5ebde16d7..c7a90d2a254 100644 --- a/spec/lib/gitlab/ci/yaml_processor_spec.rb +++ b/spec/lib/gitlab/ci/yaml_processor_spec.rb @@ -970,6 +970,7 @@ module Gitlab rspec: { artifacts: { paths: ["logs/", "binaries/"], + expose_as: "Exposed artifacts", untracked: true, name: "custom_name", expire_in: "7d" @@ -993,6 +994,7 @@ module Gitlab artifacts: { name: "custom_name", paths: ["logs/", "binaries/"], + expose_as: "Exposed artifacts", untracked: true, expire_in: "7d" } diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 058305bc04e..50b104c4095 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -206,6 +206,35 @@ describe Ci::Build do end end + describe '.with_exposed_artifacts' do + subject { described_class.with_exposed_artifacts } + + let!(:job1) { create(:ci_build) } + let!(:job2) { create(:ci_build, options: options) } + let!(:job3) { create(:ci_build) } + + context 'when some jobs have exposed artifacs and some not' do + let(:options) { { artifacts: { expose_as: 'test', paths: ['test'] } } } + + before do + job1.ensure_metadata.update!(has_exposed_artifacts: nil) + job3.ensure_metadata.update!(has_exposed_artifacts: false) + end + + it 'selects only the jobs with exposed artifacts' do + is_expected.to eq([job2]) + end + end + + context 'when job does not expose artifacts' do + let(:options) { nil } + + it 'returns an empty array' do + is_expected.to be_empty + end + end + end + describe '.with_reports' do subject { described_class.with_reports(Ci::JobArtifact.test_reports) } @@ -1844,6 +1873,14 @@ describe Ci::Build do expect(build.metadata.read_attribute(:config_options)).to be_nil end end + + context 'when options include artifacts:expose_as' do + let(:build) { create(:ci_build, options: { artifacts: { expose_as: 'test' } }) } + + it 'saves the presence of expose_as into build metadata' do + expect(build.metadata).to have_exposed_artifacts + end + end end describe '#other_manual_actions' do diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index ad79bee8801..b8d09f03fe6 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -1674,6 +1674,63 @@ describe MergeRequest do end end + describe '#find_exposed_artifacts' do + let(:project) { create(:project, :repository) } + let(:merge_request) { create(:merge_request, :with_test_reports, source_project: project) } + let(:pipeline) { merge_request.head_pipeline } + + subject { merge_request.find_exposed_artifacts } + + context 'when head pipeline has exposed artifacts' do + let!(:job) do + create(:ci_build, options: { artifacts: { expose_as: 'artifact', paths: ['ci_artifacts.txt'] } }, pipeline: pipeline) + end + + let!(:artifacts_metadata) { create(:ci_job_artifact, :metadata, job: job) } + + context 'when reactive cache worker is parsing results asynchronously' do + it 'returns status' do + expect(subject[:status]).to eq(:parsing) + end + end + + context 'when reactive cache worker is inline' do + before do + synchronous_reactive_cache(merge_request) + end + + it 'returns status and data' do + expect(subject[:status]).to eq(:parsed) + end + + context 'when an error occurrs' do + before do + expect_next_instance_of(Ci::FindExposedArtifactsService) do |service| + expect(service).to receive(:for_pipeline) + .and_raise(StandardError.new) + end + end + + it 'returns an error message' do + expect(subject[:status]).to eq(:error) + end + end + + context 'when cached results is not latest' do + before do + allow_next_instance_of(Ci::GenerateExposedArtifactsReportService) do |service| + allow(service).to receive(:latest?).and_return(false) + end + end + + it 'raises and InvalidateReactiveCache error' do + expect { subject }.to raise_error(ReactiveCaching::InvalidateReactiveCache) + end + end + end + end + end + describe '#compare_test_reports' do subject { merge_request.compare_test_reports } diff --git a/spec/serializers/merge_request_widget_entity_spec.rb b/spec/serializers/merge_request_widget_entity_spec.rb index 4872b23d26b..35940ac062e 100644 --- a/spec/serializers/merge_request_widget_entity_spec.rb +++ b/spec/serializers/merge_request_widget_entity_spec.rb @@ -358,4 +358,26 @@ describe MergeRequestWidgetEntity do end end end + + describe 'exposed_artifacts_path' do + context 'when merge request has exposed artifacts' do + before do + expect(resource).to receive(:has_exposed_artifacts?).and_return(true) + end + + it 'set the path to poll data' do + expect(subject[:exposed_artifacts_path]).to be_present + end + end + + context 'when merge request has no exposed artifacts' do + before do + expect(resource).to receive(:has_exposed_artifacts?).and_return(false) + end + + it 'set the path to poll data' do + expect(subject[:exposed_artifacts_path]).to be_nil + end + end + end end diff --git a/spec/services/ci/find_exposed_artifacts_service_spec.rb b/spec/services/ci/find_exposed_artifacts_service_spec.rb new file mode 100644 index 00000000000..f6309822fe0 --- /dev/null +++ b/spec/services/ci/find_exposed_artifacts_service_spec.rb @@ -0,0 +1,147 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Ci::FindExposedArtifactsService do + include Gitlab::Routing + + let(:metadata) do + Gitlab::Ci::Build::Artifacts::Metadata + .new(metadata_file_stream, path, { recursive: true }) + end + + let(:metadata_file_stream) do + File.open(Rails.root + 'spec/fixtures/ci_build_artifacts_metadata.gz') + end + + let_it_be(:project) { create(:project) } + let(:user) { nil } + + after do + metadata_file_stream&.close + end + + def create_job_with_artifacts(options) + create(:ci_build, pipeline: pipeline, options: options).tap do |job| + create(:ci_job_artifact, :metadata, job: job) + end + end + + describe '#for_pipeline' do + shared_examples 'finds a single match' do + it 'returns the artifact with exact location' do + expect(subject).to eq([{ + text: 'Exposed artifact', + url: file_project_job_artifacts_path(project, job, 'other_artifacts_0.1.2/doc_sample.txt'), + job_name: job.name, + job_path: project_job_path(project, job) + }]) + end + end + + shared_examples 'finds multiple matches' do + it 'returns the path to the artifacts browser' do + expect(subject).to eq([{ + text: 'Exposed artifact', + url: browse_project_job_artifacts_path(project, job), + job_name: job.name, + job_path: project_job_path(project, job) + }]) + end + end + + let_it_be(:pipeline) { create(:ci_pipeline, project: project) } + + subject { described_class.new(project, user).for_pipeline(pipeline) } + + context 'with jobs having at most 1 matching exposed artifact' do + let!(:job) do + create_job_with_artifacts(artifacts: { + expose_as: 'Exposed artifact', + paths: ['other_artifacts_0.1.2/doc_sample.txt', 'something-else.html'] + }) + end + + it_behaves_like 'finds a single match' + end + + context 'with jobs having more than 1 matching exposed artifacts' do + let!(:job) do + create_job_with_artifacts(artifacts: { + expose_as: 'Exposed artifact', + paths: [ + 'ci_artifacts.txt', + 'other_artifacts_0.1.2/doc_sample.txt', + 'something-else.html' + ] + }) + end + + it_behaves_like 'finds multiple matches' + end + + context 'with jobs having more than 1 matching exposed artifacts inside a directory' do + let!(:job) do + create_job_with_artifacts(artifacts: { + expose_as: 'Exposed artifact', + paths: ['tests_encoding/'] + }) + end + + it_behaves_like 'finds multiple matches' + end + + context 'with jobs having paths with glob expression' do + let!(:job) do + create_job_with_artifacts(artifacts: { + expose_as: 'Exposed artifact', + paths: ['other_artifacts_0.1.2/doc_sample.txt', 'tests_encoding/*.*'] + }) + end + + it_behaves_like 'finds a single match' # because those with * are ignored + end + + context 'limiting results' do + let!(:job1) do + create_job_with_artifacts(artifacts: { + expose_as: 'artifact 1', + paths: ['ci_artifacts.txt'] + }) + end + + let!(:job2) do + create_job_with_artifacts(artifacts: { + expose_as: 'artifact 2', + paths: ['tests_encoding/'] + }) + end + + let!(:job3) do + create_job_with_artifacts(artifacts: { + expose_as: 'should not be exposed', + paths: ['other_artifacts_0.1.2/doc_sample.txt'] + }) + end + + subject { described_class.new(project, user).for_pipeline(pipeline, limit: 2) } + + it 'returns first 2 results' do + expect(subject).to eq([ + { + text: 'artifact 1', + url: file_project_job_artifacts_path(project, job1, 'ci_artifacts.txt'), + job_name: job1.name, + job_path: project_job_path(project, job1) + }, + { + text: 'artifact 2', + url: browse_project_job_artifacts_path(project, job2), + job_name: job2.name, + job_path: project_job_path(project, job2) + } + ]) + end + end + end +end diff --git a/spec/tasks/gitlab/shell_rake_spec.rb b/spec/tasks/gitlab/shell_rake_spec.rb index abad16be580..08b3fea0c80 100644 --- a/spec/tasks/gitlab/shell_rake_spec.rb +++ b/spec/tasks/gitlab/shell_rake_spec.rb @@ -17,7 +17,7 @@ describe 'gitlab:shell rake tasks' do expect_any_instance_of(Gitlab::TaskHelpers).to receive(:checkout_or_clone_version) allow(Kernel).to receive(:system).with('bin/install', *storages).and_return(true) - allow(Kernel).to receive(:system).with('bin/compile').and_return(true) + allow(Kernel).to receive(:system).with('make', 'build').and_return(true) run_rake_task('gitlab:shell:install') end diff --git a/spec/views/projects/show.html.haml_spec.rb b/spec/views/projects/show.html.haml_spec.rb new file mode 100644 index 00000000000..820772b592f --- /dev/null +++ b/spec/views/projects/show.html.haml_spec.rb @@ -0,0 +1,41 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'projects/show' do + include Devise::Test::ControllerHelpers + + let(:user) { create(:admin) } + let(:project) { create(:project, :repository) } + + before do + presented_project = project.present(current_user: user) + + allow(presented_project).to receive(:default_view).and_return('customize_workflow') + allow(controller).to receive(:current_user).and_return(user) + + assign(:project, presented_project) + end + + context 'commit signatures' do + context 'with vue tree view disabled' do + before do + stub_feature_flags(vue_file_list: false) + end + + it 'rendered via js-signature-container' do + render + + expect(rendered).to have_css('.js-signature-container') + end + end + + context 'with vue tree view enabled' do + it 'are not rendered via js-signature-container' do + render + + expect(rendered).not_to have_css('.js-signature-container') + end + end + end +end diff --git a/spec/views/projects/tree/show.html.haml_spec.rb b/spec/views/projects/tree/show.html.haml_spec.rb index 960cf42a793..4307d1b49c9 100644 --- a/spec/views/projects/tree/show.html.haml_spec.rb +++ b/spec/views/projects/tree/show.html.haml_spec.rb @@ -7,6 +7,10 @@ describe 'projects/tree/show' do let(:project) { create(:project, :repository) } let(:repository) { project.repository } + let(:ref) { 'master' } + let(:commit) { repository.commit(ref) } + let(:path) { '' } + let(:tree) { repository.tree(commit.id, path) } before do stub_feature_flags(vue_file_list: false) @@ -19,26 +23,45 @@ describe 'projects/tree/show' do allow(view).to receive(:can_collaborate_with_project?).and_return(true) allow(view).to receive_message_chain('user_access.can_push_to_branch?').and_return(true) allow(view).to receive(:current_application_settings).and_return(Gitlab::CurrentSettings.current_application_settings) + allow(view).to receive(:current_user).and_return(project.creator) + + assign(:id, File.join(ref, path)) + assign(:ref, ref) + assign(:path, path) + assign(:last_commit, commit) + assign(:tree, tree) end context 'for branch names ending on .json' do let(:ref) { 'ends-with.json' } - let(:commit) { repository.commit(ref) } - let(:path) { '' } - let(:tree) { repository.tree(commit.id, path) } - - before do - assign(:id, File.join(ref, path)) - assign(:ref, ref) - assign(:path, path) - assign(:last_commit, commit) - assign(:tree, tree) - end it 'displays correctly' do render + expect(rendered).to have_css('.js-project-refs-dropdown .dropdown-toggle-text', text: ref) expect(rendered).to have_css('.readme-holder') end end + + context 'commit signatures' do + context 'with vue tree view disabled' do + it 'rendered via js-signature-container' do + render + + expect(rendered).to have_css('.js-signature-container') + end + end + + context 'with vue tree view enabled' do + before do + stub_feature_flags(vue_file_list: true) + end + + it 'are not rendered via js-signature-container' do + render + + expect(rendered).not_to have_css('.js-signature-container') + end + end + end end |