summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-10-19 13:38:27 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-10-19 13:38:27 +0000
commit18d7766e9e65a0966fd91b0959f49c96f8ad5845 (patch)
tree93bea1b4d4fb571a34ec92198d6844e481eaa7af
parente23e7bc48165be175d7078d5e6fee002057046fd (diff)
downloadgitlab-ce-18d7766e9e65a0966fd91b0959f49c96f8ad5845.tar.gz
Add latest changes from gitlab-org/gitlab@15-4-stable-ee
-rw-r--r--app/helpers/appearances_helper.rb8
-rw-r--r--app/models/issue.rb6
-rw-r--r--app/views/layouts/devise.html.haml4
-rw-r--r--lib/gitlab/closing_issue_extractor.rb3
-rw-r--r--locale/gitlab.pot3
-rw-r--r--spec/factories/projects.rb6
-rw-r--r--spec/helpers/appearances_helper_spec.rb58
-rw-r--r--spec/lib/gitlab/closing_issue_extractor_spec.rb30
-rw-r--r--spec/models/issue_spec.rb7
-rw-r--r--spec/views/layouts/devise.html.haml_spec.rb18
10 files changed, 111 insertions, 32 deletions
diff --git a/app/helpers/appearances_helper.rb b/app/helpers/appearances_helper.rb
index 6dbd0f7bd7b..957c2afb6d2 100644
--- a/app/helpers/appearances_helper.rb
+++ b/app/helpers/appearances_helper.rb
@@ -14,7 +14,13 @@ module AppearancesHelper
end
def brand_image
- image_tag(current_appearance.logo_path) if current_appearance&.logo?
+ image_tag(brand_image_path, alt: brand_title, class: 'gl-w-10')
+ end
+
+ def brand_image_path
+ return current_appearance.logo_path if current_appearance&.logo?
+
+ image_path('logo.svg')
end
def brand_text
diff --git a/app/models/issue.rb b/app/models/issue.rb
index 153747c75df..754591b8017 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -160,7 +160,7 @@ class Issue < ApplicationRecord
scope :with_api_entity_associations, -> {
preload(:timelogs, :closed_by, :assignees, :author, :labels, :issuable_severity,
milestone: { project: [:route, { namespace: :route }] },
- project: [:route, { namespace: :route }],
+ project: [:project_feature, :route, { namespace: :route }],
duplicated_to: { project: [:project_feature] })
}
scope :with_issue_type, ->(types) { where(issue_type: types) }
@@ -612,7 +612,9 @@ class Issue < ApplicationRecord
# for performance reasons, check commit: 002ad215818450d2cbbc5fa065850a953dc7ada8
# Make sure to sync this method with issue_policy.rb
def readable_by?(user)
- if user.can_read_all_resources?
+ if !project.issues_enabled?
+ false
+ elsif user.can_read_all_resources?
true
elsif project.personal? && project.team.owner?(user)
true
diff --git a/app/views/layouts/devise.html.haml b/app/views/layouts/devise.html.haml
index 6650e07be2a..3532c6638ce 100644
--- a/app/views/layouts/devise.html.haml
+++ b/app/views/layouts/devise.html.haml
@@ -13,9 +13,9 @@
= render "layouts/flash"
.mt-3
.col-sm-12.gl-text-center
- %img.gl-w-10{ :alt => _("GitLab Logo"), :src => image_path('logo.svg') }
+ = brand_image
%h1.mb-3.gl-font-size-h2
- = current_appearance&.title.presence || _('GitLab')
+ = brand_title
- if current_appearance&.description?
= brand_text
= render_if_exists 'layouts/devise_help_text'
diff --git a/lib/gitlab/closing_issue_extractor.rb b/lib/gitlab/closing_issue_extractor.rb
index 7104de2a3c3..b06cb4f10e2 100644
--- a/lib/gitlab/closing_issue_extractor.rb
+++ b/lib/gitlab/closing_issue_extractor.rb
@@ -27,8 +27,7 @@ module Gitlab
@extractor.issues.reject do |issue|
@extractor.project.forked_from?(issue.project) ||
- !issue.project.autoclose_referenced_issues ||
- !issue.project.issues_enabled?
+ !issue.project.autoclose_referenced_issues
end
end
end
diff --git a/locale/gitlab.pot b/locale/gitlab.pot
index 4569a1b447b..a494df7b1ff 100644
--- a/locale/gitlab.pot
+++ b/locale/gitlab.pot
@@ -17794,9 +17794,6 @@ msgstr ""
msgid "GitLab KAS"
msgstr ""
-msgid "GitLab Logo"
-msgstr ""
-
msgid "GitLab Pages"
msgstr ""
diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb
index 871917a725e..93ed68a4573 100644
--- a/spec/factories/projects.rb
+++ b/spec/factories/projects.rb
@@ -427,6 +427,12 @@ FactoryBot.define do
error_tracking_setting { association :project_error_tracking_setting }
end
+ trait :with_jira_integration do
+ has_external_issue_tracker { true }
+
+ jira_integration
+ end
+
# Project with empty repository
#
# This is a case when you just created a project
diff --git a/spec/helpers/appearances_helper_spec.rb b/spec/helpers/appearances_helper_spec.rb
index edd704ce739..2206c1ce2ae 100644
--- a/spec/helpers/appearances_helper_spec.rb
+++ b/spec/helpers/appearances_helper_spec.rb
@@ -3,6 +3,8 @@
require 'spec_helper'
RSpec.describe AppearancesHelper do
+ let_it_be(:gitlab_logo) { ActionController::Base.helpers.image_path('logo.svg') }
+
before do
user = create(:user)
allow(helper).to receive(:current_user).and_return(user)
@@ -59,23 +61,59 @@ RSpec.describe AppearancesHelper do
end
describe '#brand_image' do
- let!(:appearance) { create(:appearance, :with_logo) }
-
context 'when there is a logo' do
+ let!(:appearance) { create(:appearance, :with_logo) }
+
it 'returns a path' do
- expect(helper.brand_image).to match(%r(img data-src="/uploads/-/system/appearance/.*png))
+ expect(helper.brand_image).to match(%r(img .* data-src="/uploads/-/system/appearance/.*png))
+ end
+
+ context 'when there is no associated upload' do
+ before do
+ # Legacy attachments were not tracked in the uploads table
+ appearance.logo.upload.destroy!
+ appearance.reload
+ end
+
+ it 'falls back to using the original path' do
+ expect(helper.brand_image).to match(%r(img .* data-src="/uploads/-/system/appearance/.*png))
+ end
end
end
- context 'when there is a logo but no associated upload' do
- before do
- # Legacy attachments were not tracked in the uploads table
- appearance.logo.upload.destroy!
- appearance.reload
+ context 'when there is no logo' do
+ it 'returns path of GitLab logo' do
+ expect(helper.brand_image).to match(%r(img .* data-src="#{gitlab_logo}))
+ end
+ end
+
+ context 'when there is a title' do
+ let!(:appearance) { create(:appearance, title: 'My title') }
+
+ it 'returns the title' do
+ expect(helper.brand_image).to match(%r(img alt="My title"))
end
+ end
+
+ context 'when there is no title' do
+ it 'returns the default title' do
+ expect(helper.brand_image).to match(%r(img alt="GitLab))
+ end
+ end
+ end
+
+ describe '#brand_image_path' do
+ context 'with a custom logo' do
+ let!(:appearance) { create(:appearance, :with_logo) }
+
+ it 'returns path of custom logo' do
+ expect(helper.brand_image_path).to match(%r(/uploads/-/system/appearance/.*/dk.png))
+ end
+ end
- it 'falls back to using the original path' do
- expect(helper.brand_image).to match(%r(img data-src="/uploads/-/system/appearance/.*png))
+ context 'with no custom logo' do
+ it 'returns path of GitLab logo' do
+ expect(helper.brand_image_path).to eq(gitlab_logo)
end
end
end
diff --git a/spec/lib/gitlab/closing_issue_extractor_spec.rb b/spec/lib/gitlab/closing_issue_extractor_spec.rb
index 1422f83c629..d49c53fe448 100644
--- a/spec/lib/gitlab/closing_issue_extractor_spec.rb
+++ b/spec/lib/gitlab/closing_issue_extractor_spec.rb
@@ -297,14 +297,21 @@ RSpec.describe Gitlab::ClosingIssueExtractor do
end
context 'with an external issue tracker reference' do
+ let_it_be_with_reload(:jira_project) { create(:project, :with_jira_integration, name: 'JIRA_EXT1') }
+
+ let(:jira_issue) { ExternalIssue.new("#{jira_project.name}-1", project: jira_project) }
+ let(:message) { "Resolve #{jira_issue.to_reference}" }
+
+ subject { described_class.new(jira_project, jira_project.creator) }
+
it 'extracts the referenced issue' do
- jira_project = create(:jira_project, name: 'JIRA_EXT1')
- jira_project.add_maintainer(jira_project.creator)
- jira_issue = ExternalIssue.new("#{jira_project.name}-1", project: jira_project)
- closing_issue_extractor = described_class.new(jira_project, jira_project.creator)
- message = "Resolve #{jira_issue.to_reference}"
+ expect(subject.closed_by_message(message)).to eq([jira_issue])
+ end
- expect(closing_issue_extractor.closed_by_message(message)).to eq([jira_issue])
+ it 'extracts the referenced issue even if GitLab issues are disabled for the project' do
+ jira_project.update!(issues_enabled: false)
+
+ expect(subject.closed_by_message(message)).to eq([jira_issue])
end
end
end
@@ -346,6 +353,17 @@ RSpec.describe Gitlab::ClosingIssueExtractor do
end
end
+ context 'when target project has issues disabled' do
+ before do
+ project2.update!(issues_enabled: false)
+ end
+
+ it 'omits the issue reference' do
+ message = "Closes #{cross_reference}"
+ expect(subject.closed_by_message(message)).to be_empty
+ end
+ end
+
context "with an invalid URL" do
it do
message = "Closes https://google.com#{urls.project_issue_path(issue2.project, issue2)}"
diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb
index 17c3cd17364..e7b2212ebff 100644
--- a/spec/models/issue_spec.rb
+++ b/spec/models/issue_spec.rb
@@ -971,16 +971,11 @@ RSpec.describe Issue do
context 'with a project' do
it 'returns false when feature is disabled' do
+ project.add_developer(user)
project.project_feature.update_attribute(:issues_access_level, ProjectFeature::DISABLED)
is_expected.to eq(false)
end
-
- it 'returns false when restricted for members' do
- project.project_feature.update_attribute(:issues_access_level, ProjectFeature::PRIVATE)
-
- is_expected.to eq(false)
- end
end
context 'without a user' do
diff --git a/spec/views/layouts/devise.html.haml_spec.rb b/spec/views/layouts/devise.html.haml_spec.rb
index e69cf93cfb4..b37bdeceb7e 100644
--- a/spec/views/layouts/devise.html.haml_spec.rb
+++ b/spec/views/layouts/devise.html.haml_spec.rb
@@ -4,4 +4,22 @@ require 'spec_helper'
RSpec.describe 'layouts/devise' do
it_behaves_like 'a layout which reflects the application theme setting'
+
+ describe 'logo' do
+ it 'renders GitLab logo' do
+ render
+
+ expect(rendered).to have_selector('img[alt^="GitLab"]')
+ end
+
+ context 'with custom logo' do
+ let_it_be(:appearance) { create(:appearance, logo: fixture_file_upload('spec/fixtures/dk.png')) }
+
+ it 'renders custom logo' do
+ render
+
+ expect(rendered).to have_selector('img[data-src$="dk.png"]')
+ end
+ end
+ end
end