diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-19 13:38:27 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-19 13:38:27 +0000 |
commit | 18d7766e9e65a0966fd91b0959f49c96f8ad5845 (patch) | |
tree | 93bea1b4d4fb571a34ec92198d6844e481eaa7af /spec | |
parent | e23e7bc48165be175d7078d5e6fee002057046fd (diff) | |
download | gitlab-ce-18d7766e9e65a0966fd91b0959f49c96f8ad5845.tar.gz |
Add latest changes from gitlab-org/gitlab@15-4-stable-ee
Diffstat (limited to 'spec')
-rw-r--r-- | spec/factories/projects.rb | 6 | ||||
-rw-r--r-- | spec/helpers/appearances_helper_spec.rb | 58 | ||||
-rw-r--r-- | spec/lib/gitlab/closing_issue_extractor_spec.rb | 30 | ||||
-rw-r--r-- | spec/models/issue_spec.rb | 7 | ||||
-rw-r--r-- | spec/views/layouts/devise.html.haml_spec.rb | 18 |
5 files changed, 97 insertions, 22 deletions
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 |