diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-20 17:22:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-20 17:22:11 +0300 |
commit | 0c872e02b2c822e3397515ec324051ff540f0cd5 (patch) | |
tree | ce2fb6ce7030e4dad0f4118d21ab6453e5938cdd /spec/views/projects | |
parent | f7e05a6853b12f02911494c4b3fe53d9540d74fc (diff) |
Add latest changes from gitlab-org/gitlab@15-7-stable-eev15.7.0-rc42
Diffstat (limited to 'spec/views/projects')
8 files changed, 164 insertions, 21 deletions
diff --git a/spec/views/projects/_files.html.haml_spec.rb b/spec/views/projects/_files.html.haml_spec.rb new file mode 100644 index 00000000000..b6a8b4735b0 --- /dev/null +++ b/spec/views/projects/_files.html.haml_spec.rb @@ -0,0 +1,73 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'projects/_files' do + include ProjectForksHelper + + let_it_be(:user) { create(:user) } + let_it_be(:source_project) { create(:project, :repository, :public) } + + context 'when the project is a fork' do + let_it_be(:project) { fork_project(source_project, user, { repository: true }) } + + before do + assign(:project, project) + assign(:ref, project.default_branch) + assign(:path, '/') + assign(:id, project.commit.id) + + allow(view).to receive(:current_user).and_return(user) + end + + context 'when user can read fork source' do + before do + allow(view).to receive(:can?).with(user, :read_project, source_project).and_return(true) + end + + it 'shows the forked-from project' do + render + + expect(rendered).to have_content("Forked from #{source_project.full_name}") + expect(rendered).to have_content("Up to date with upstream repository") + end + + context 'when fork_divergence_counts is disabled' do + before do + stub_feature_flags(fork_divergence_counts: false) + end + + it 'does not show fork info' do + render + + expect(rendered).not_to have_content("Forked from #{source_project.full_name}") + expect(rendered).not_to have_content("Up to date with upstream repository") + end + end + end + + context 'when user cannot read fork source' do + before do + allow(view).to receive(:can?).with(user, :read_project, source_project).and_return(false) + end + + it 'does not show the forked-from project' do + render + + expect(rendered).to have_content("Forked from an inaccessible project") + end + + context 'when fork_divergence_counts is disabled' do + before do + stub_feature_flags(fork_divergence_counts: false) + end + + it 'does not show fork info' do + render + + expect(rendered).not_to have_content("Forked from an inaccessible project") + end + end + end + end +end diff --git a/spec/views/projects/_flash_messages.html.haml_spec.rb b/spec/views/projects/_flash_messages.html.haml_spec.rb index e1858229208..231aa12d920 100644 --- a/spec/views/projects/_flash_messages.html.haml_spec.rb +++ b/spec/views/projects/_flash_messages.html.haml_spec.rb @@ -12,10 +12,10 @@ RSpec.describe 'projects/_flash_messages' do before do allow(view).to receive(:current_user).and_return(user) - allow(view).to receive(:can?).with(user, :download_code, project).and_return(true) + allow(view).to receive(:can?).with(user, :read_code, project).and_return(true) end - context 'when current_user has download_code permission' do + context 'when current_user has read_code permission' do context 'when user has a terraform state' do let_it_be(:project) { create(:project) } let_it_be(:terraform_state) { create(:terraform_state, :locked, :with_version, project: project) } diff --git a/spec/views/projects/_home_panel.html.haml_spec.rb b/spec/views/projects/_home_panel.html.haml_spec.rb index 78131937d3c..6f6a2d9a04d 100644 --- a/spec/views/projects/_home_panel.html.haml_spec.rb +++ b/spec/views/projects/_home_panel.html.haml_spec.rb @@ -190,22 +190,50 @@ RSpec.describe 'projects/_home_panel' do end context 'user can read fork source' do - it 'shows the forked-from project' do + before do allow(view).to receive(:can?).with(user, :read_project, source_project).and_return(true) + end + it 'does not show the forked-from project' do render - expect(rendered).to have_content("Forked from #{source_project.full_name}") + expect(rendered).not_to have_content("Forked from #{source_project.full_name}") + end + + context 'when fork_divergence_counts is disabled' do + before do + stub_feature_flags(fork_divergence_counts: false) + end + + it 'shows the forked-from project' do + render + + expect(rendered).to have_content("Forked from #{source_project.full_name}") + end end end context 'user cannot read fork source' do - it 'does not show the forked-from project' do + before do allow(view).to receive(:can?).with(user, :read_project, source_project).and_return(false) + end + it 'shows the message that forked project is inaccessible' do render - expect(rendered).to have_content("Forked from an inaccessible project") + expect(rendered).not_to have_content("Forked from an inaccessible project") + end + + context 'when fork_divergence_counts is disabled' do + before do + stub_feature_flags(fork_divergence_counts: false) + end + + it 'shows the message that forked project is inaccessible' do + render + + expect(rendered).to have_content("Forked from an inaccessible project") + end end end end diff --git a/spec/views/projects/commit/show.html.haml_spec.rb b/spec/views/projects/commit/show.html.haml_spec.rb index 4d5c987ce37..1d9e5e782e5 100644 --- a/spec/views/projects/commit/show.html.haml_spec.rb +++ b/spec/views/projects/commit/show.html.haml_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'projects/commit/show.html.haml' do +RSpec.describe 'projects/commit/show.html.haml', feature_category: :source_code do let(:project) { create(:project, :repository) } let(:commit) { project.commit } @@ -76,4 +76,44 @@ RSpec.describe 'projects/commit/show.html.haml' do end end end + + context 'when commit is signed' do + let(:page) { Nokogiri::HTML.parse(rendered) } + let(:badge) { page.at('.gpg-status-box') } + let(:badge_attributes) { badge.attributes } + let(:title) { badge_attributes['data-title'].value } + let(:content) { badge_attributes['data-content'].value } + + before do + render + end + + context 'with GPG' do + let(:commit) { project.commit(GpgHelpers::SIGNED_COMMIT_SHA) } + + it 'renders unverified badge' do + expect(title).to include('This commit was signed with an <strong>unverified</strong> signature.') + expect(content).to include(commit.signature.gpg_key_primary_keyid) + end + end + + context 'with SSH' do + let(:commit) { project.commit('7b5160f9bb23a3d58a0accdbe89da13b96b1ece9') } + + it 'renders unverified badge' do + expect(title).to include('This commit was signed with an <strong>unverified</strong> signature.') + expect(content).to match(/SSH key fingerprint:[\s\S]+Unknown/) + end + end + + context 'with X.509' do + let(:commit) { project.commit('189a6c924013fc3fe40d6f1ec1dc20214183bc97') } + + it 'renders unverified badge' do + expect(title).to include('This commit was signed with an <strong>unverified</strong> signature.') + expect(content).to include(commit.signature.x509_certificate.subject_key_identifier.tr(":", " ")) + expect(content).to include(commit.signature.x509_certificate.email) + end + end + end end diff --git a/spec/views/projects/issues/_related_branches.html.haml_spec.rb b/spec/views/projects/issues/_related_branches.html.haml_spec.rb index ba6f7068024..deec2db6865 100644 --- a/spec/views/projects/issues/_related_branches.html.haml_spec.rb +++ b/spec/views/projects/issues/_related_branches.html.haml_spec.rb @@ -9,10 +9,13 @@ RSpec.describe 'projects/issues/_related_branches' do let(:status) { pipeline.detailed_status(build(:user)) } before do - assign(:related_branches, [ - { name: 'other', link: 'link-to-other', pipeline_status: nil }, - { name: 'feature', link: 'link-to-feature', pipeline_status: status } - ]) + assign(:related_branches, + [ + { name: 'other', link: 'link-to-other', pipeline_status: nil }, + { name: 'feature', link: 'link-to-feature', pipeline_status: status } + + ] + ) render end diff --git a/spec/views/projects/notes/_more_actions_dropdown.html.haml_spec.rb b/spec/views/projects/notes/_more_actions_dropdown.html.haml_spec.rb index 3776af9e757..7886a811c9a 100644 --- a/spec/views/projects/notes/_more_actions_dropdown.html.haml_spec.rb +++ b/spec/views/projects/notes/_more_actions_dropdown.html.haml_spec.rb @@ -17,7 +17,7 @@ RSpec.describe 'projects/notes/_more_actions_dropdown' do it 'shows Report abuse to admin button if not editable and not current users comment' do render 'projects/notes/more_actions_dropdown', current_user: not_author_user, note_editable: false, note: note - expect(rendered).to have_link('Report abuse to admin') + expect(rendered).to have_link('Report abuse to administrator') end it 'does not show the More actions button if not editable and current users comment' do @@ -26,10 +26,10 @@ RSpec.describe 'projects/notes/_more_actions_dropdown' do expect(rendered).not_to have_selector('.dropdown.more-actions') end - it 'shows Report abuse to admin and Delete buttons if editable and not current users comment' do + it 'shows Report abuse and Delete buttons if editable and not current users comment' do render 'projects/notes/more_actions_dropdown', current_user: not_author_user, note_editable: true, note: note - expect(rendered).to have_link('Report abuse to admin') + expect(rendered).to have_link('Report abuse to administrator') expect(rendered).to have_link('Delete comment') end diff --git a/spec/views/projects/pipelines/show.html.haml_spec.rb b/spec/views/projects/pipelines/show.html.haml_spec.rb index 7e300fb1e6e..b9c7da20d1a 100644 --- a/spec/views/projects/pipelines/show.html.haml_spec.rb +++ b/spec/views/projects/pipelines/show.html.haml_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -RSpec.describe 'projects/pipelines/show' do +RSpec.describe 'projects/pipelines/show', feature_category: :pipeline_authoring do include Devise::Test::ControllerHelpers let_it_be(:project) { create(:project, :repository) } let_it_be(:user) { create(:user) } @@ -13,7 +13,6 @@ RSpec.describe 'projects/pipelines/show' do before do assign(:project, project) assign(:pipeline, presented_pipeline) - stub_feature_flags(pipeline_tabs_vue: false) end context 'when pipeline has errors' do @@ -24,14 +23,14 @@ RSpec.describe 'projects/pipelines/show' do it 'shows errors' do render - expect(rendered).to have_content('Found errors in your .gitlab-ci.yml') + expect(rendered).to have_content('Unable to create pipeline') expect(rendered).to have_content('some errors') end it 'does not render the pipeline tabs' do render - expect(rendered).not_to have_css('ul.pipelines-tabs') + expect(rendered).not_to have_selector('#js-pipeline-tabs') end end @@ -39,13 +38,13 @@ RSpec.describe 'projects/pipelines/show' do it 'does not show errors' do render - expect(rendered).not_to have_content('Found errors in your .gitlab-ci.yml') + expect(rendered).not_to have_content('Unable to create pipeline') end it 'renders the pipeline tabs' do render - expect(rendered).to have_css('ul.pipelines-tabs') + expect(rendered).to have_selector('#js-pipeline-tabs') 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 62a52bcf83f..5a1ae715f8f 100644 --- a/spec/views/projects/tree/show.html.haml_spec.rb +++ b/spec/views/projects/tree/show.html.haml_spec.rb @@ -35,7 +35,7 @@ RSpec.describe 'projects/tree/show' do it 'displays correctly' do render - expect(rendered).to have_css('.js-project-refs-dropdown .dropdown-toggle-text', text: ref) + expect(rendered).to have_css('#js-tree-ref-switcher') end end end |