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:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-01-23 18:10:34 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-01-23 18:10:34 +0300
commita8b96c3072b3bd4d45e6364931042b350bf7fa2e (patch)
tree70d8a5faa2171c82a0007364f89c11d2e45aeac5 /spec
parent8137303e47baaff97a36396cfb05efc0d99879a2 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/features/abuse_report_spec.rb2
-rw-r--r--spec/features/incidents/incident_details_spec.rb4
-rw-r--r--spec/features/incidents/incident_timeline_events_spec.rb2
-rw-r--r--spec/features/incidents/user_views_incident_spec.rb4
-rw-r--r--spec/features/issues/incident_issue_spec.rb2
-rw-r--r--spec/features/issues/issue_detail_spec.rb2
-rw-r--r--spec/helpers/issuables_helper_spec.rb28
-rw-r--r--spec/lib/gitlab/database_spec.rb29
-rw-r--r--spec/models/repository_spec.rb42
-rw-r--r--spec/tasks/migrate/schema_check_rake_spec.rb5
10 files changed, 100 insertions, 20 deletions
diff --git a/spec/features/abuse_report_spec.rb b/spec/features/abuse_report_spec.rb
index 31b86244dd1..1267025a7bf 100644
--- a/spec/features/abuse_report_spec.rb
+++ b/spec/features/abuse_report_spec.rb
@@ -56,7 +56,7 @@ RSpec.describe 'Abuse reports', :js, feature_category: :insider_threat do
let_it_be(:incident) { create(:incident, project: project, author: abusive_user) }
before do
- visit project_issues_incident_path(project, incident)
+ visit incident_project_issues_path(project, incident)
click_button 'Incident actions'
end
diff --git a/spec/features/incidents/incident_details_spec.rb b/spec/features/incidents/incident_details_spec.rb
index e1167285464..34f8dadcf11 100644
--- a/spec/features/incidents/incident_details_spec.rb
+++ b/spec/features/incidents/incident_details_spec.rb
@@ -19,7 +19,7 @@ RSpec.describe 'Incident details', :js, feature_category: :incident_management d
context 'when a developer+ displays the incident' do
before do
- visit project_issues_incident_path(project, incident)
+ visit incident_project_issues_path(project, incident)
wait_for_requests
end
@@ -108,7 +108,7 @@ RSpec.describe 'Incident details', :js, feature_category: :incident_management d
end
it 'routes the user to the issue details page when the `issue_type` is set to issue' do
- visit project_issues_incident_path(project, incident)
+ visit incident_project_issues_path(project, incident)
wait_for_requests
project_path = "/#{project.full_path}"
diff --git a/spec/features/incidents/incident_timeline_events_spec.rb b/spec/features/incidents/incident_timeline_events_spec.rb
index 80b46078389..45518671c57 100644
--- a/spec/features/incidents/incident_timeline_events_spec.rb
+++ b/spec/features/incidents/incident_timeline_events_spec.rb
@@ -14,7 +14,7 @@ RSpec.describe 'Incident timeline events', :js, feature_category: :incident_mana
before do
sign_in(developer)
- visit project_issues_incident_path(project, incident)
+ visit incident_project_issues_path(project, incident)
wait_for_requests
click_link s_('Incident|Timeline')
end
diff --git a/spec/features/incidents/user_views_incident_spec.rb b/spec/features/incidents/user_views_incident_spec.rb
index 49041d187dd..0265960fce7 100644
--- a/spec/features/incidents/user_views_incident_spec.rb
+++ b/spec/features/incidents/user_views_incident_spec.rb
@@ -19,7 +19,7 @@ RSpec.describe "User views incident", feature_category: :incident_management do
before do
sign_in(user)
- visit(project_issues_incident_path(project, incident))
+ visit(incident_project_issues_path(project, incident))
end
specify do
@@ -75,7 +75,7 @@ RSpec.describe "User views incident", feature_category: :incident_management do
describe 'user status' do
context 'when showing status of the author of the incident' do
- subject { visit(project_issues_incident_path(project, incident)) }
+ subject { visit(incident_project_issues_path(project, incident)) }
it_behaves_like 'showing user status' do
let(:user_with_status) { user }
diff --git a/spec/features/issues/incident_issue_spec.rb b/spec/features/issues/incident_issue_spec.rb
index 2fba1ca9141..41bbd79202f 100644
--- a/spec/features/issues/incident_issue_spec.rb
+++ b/spec/features/issues/incident_issue_spec.rb
@@ -29,7 +29,7 @@ RSpec.describe 'Incident Detail', :js, feature_category: :team_planning do
project.add_developer(user)
sign_in(user)
- visit project_issues_incident_path(project, incident)
+ visit incident_project_issues_path(project, incident)
wait_for_requests
end
diff --git a/spec/features/issues/issue_detail_spec.rb b/spec/features/issues/issue_detail_spec.rb
index 44e9bbad1ba..5af761ad7a4 100644
--- a/spec/features/issues/issue_detail_spec.rb
+++ b/spec/features/issues/issue_detail_spec.rb
@@ -130,7 +130,7 @@ RSpec.describe 'Issue Detail', :js, feature_category: :team_planning do
page.within('[data-testid="issuable-form"]') do
update_type_select('Issue', 'Incident')
- expect(page).to have_current_path(project_issues_incident_path(project, issue))
+ expect(page).to have_current_path(incident_project_issues_path(project, issue))
end
end
end
diff --git a/spec/helpers/issuables_helper_spec.rb b/spec/helpers/issuables_helper_spec.rb
index f2e3e401766..467c8d96cfb 100644
--- a/spec/helpers/issuables_helper_spec.rb
+++ b/spec/helpers/issuables_helper_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe IssuablesHelper do
+RSpec.describe IssuablesHelper, feature_category: :team_planning do
let(:label) { build_stubbed(:label) }
let(:label2) { build_stubbed(:label) }
@@ -387,6 +387,32 @@ RSpec.describe IssuablesHelper do
expect(helper.issuable_initial_data(issue)).to match(hash_including(expected_data))
end
+ context 'for incident tab' do
+ let(:incident) { create(:incident) }
+ let(:params) do
+ ActionController::Parameters.new({
+ controller: "projects/incidents",
+ action: "show",
+ namespace_id: "foo",
+ project_id: "bar",
+ id: incident.iid
+ }).permit!
+ end
+
+ it 'includes incident attributes' do
+ @project = incident.project
+ allow(helper).to receive(:safe_params).and_return(params)
+
+ expected_data = {
+ issueType: 'incident',
+ hasLinkedAlerts: false,
+ canUpdateTimelineEvent: true
+ }
+
+ expect(helper.issuable_initial_data(incident)).to match(hash_including(expected_data))
+ end
+ end
+
describe '#sentryIssueIdentifier' do
let(:issue) { create(:issue, author: user) }
diff --git a/spec/lib/gitlab/database_spec.rb b/spec/lib/gitlab/database_spec.rb
index 86bc8e71fd7..6423c93d1dc 100644
--- a/spec/lib/gitlab/database_spec.rb
+++ b/spec/lib/gitlab/database_spec.rb
@@ -516,4 +516,33 @@ RSpec.describe Gitlab::Database do
end
end
end
+
+ describe '.read_minimum_migration_version' do
+ before do
+ allow(Dir).to receive(:open).with(Rails.root.join('db/migrate')).and_return(migration_files)
+ end
+
+ context 'valid migration files exist' do
+ let(:migration_files) do
+ [
+ '20211004170422_init_schema.rb',
+ '20211005182304_add_users.rb'
+ ]
+ end
+
+ let(:valid_schema) { 20211004170422 }
+
+ it 'finds the correct ID' do
+ expect(described_class.read_minimum_migration_version).to eq valid_schema
+ end
+ end
+
+ context 'no valid migration files exist' do
+ let(:migration_files) { ['readme.txt', 'INSTALL'] }
+
+ it 'returns nil' do
+ expect(described_class.read_minimum_migration_version).to be_nil
+ end
+ end
+ end
end
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index a3d2f9a09fb..b7dcf9919c7 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -2572,28 +2572,52 @@ RSpec.describe Repository, feature_category: :source_code_management do
describe '#avatar' do
let(:project) { create(:project, :repository) }
- it 'returns nil if repo does not exist' do
- allow(repository).to receive(:root_ref).and_raise(Gitlab::Git::Repository::NoRepository)
+ it 'returns nil if repo is empty' do
+ allow(repository).to receive(:empty).and_return(true)
expect(repository.avatar).to be_nil
end
it 'returns the first avatar file found in the repository' do
- expect(repository).to receive(:file_on_head)
- .with(:avatar)
- .and_return(double(:tree, path: 'logo.png'))
+ expect(repository).to receive(:search_files_by_regexp).and_return(['logo.png'])
expect(repository.avatar).to eq('logo.png')
end
it 'caches the output' do
- expect(repository).to receive(:file_on_head)
- .with(:avatar)
- .once
- .and_return(double(:tree, path: 'logo.png'))
+ expect(repository).to receive(:search_files_by_regexp).once.and_return(['logo.png'])
2.times { expect(repository.avatar).to eq('logo.png') }
end
+
+ context 'when feature flag readme_from_gitaly is disabled' do
+ before do
+ stub_feature_flags(readme_from_gitaly: false)
+ end
+
+ it 'returns nil if repo does not exist' do
+ allow(repository).to receive(:root_ref).and_raise(Gitlab::Git::Repository::NoRepository)
+
+ expect(repository.avatar).to be_nil
+ end
+
+ it 'returns the first avatar file found in the repository' do
+ expect(repository).to receive(:file_on_head)
+ .with(:avatar)
+ .and_return(double(:tree, path: 'logo.png'))
+
+ expect(repository.avatar).to eq('logo.png')
+ end
+
+ it 'caches the output' do
+ expect(repository).to receive(:file_on_head)
+ .with(:avatar)
+ .once
+ .and_return(double(:tree, path: 'logo.png'))
+
+ 2.times { expect(repository.avatar).to eq('logo.png') }
+ end
+ end
end
describe '#expire_exists_cache' do
diff --git a/spec/tasks/migrate/schema_check_rake_spec.rb b/spec/tasks/migrate/schema_check_rake_spec.rb
index 1b60b63ad84..ede55f23ba8 100644
--- a/spec/tasks/migrate/schema_check_rake_spec.rb
+++ b/spec/tasks/migrate/schema_check_rake_spec.rb
@@ -5,6 +5,7 @@ require 'rake'
RSpec.describe 'schema_version_check rake task', :silence_stdout do
include StubENV
+ let(:valid_schema_version) { 20211004170422 }
before :all do
Rake.application.rake_require 'active_record/railties/databases'
@@ -15,8 +16,8 @@ RSpec.describe 'schema_version_check rake task', :silence_stdout do
end
before do
- allow(ActiveRecord::Migrator).to receive(:current_version).and_return(Gitlab::Database::MIN_SCHEMA_VERSION)
-
+ allow(ActiveRecord::Migrator).to receive(:current_version).and_return(valid_schema_version)
+ allow(Gitlab::Database).to receive(:read_minimum_migration_version).and_return(valid_schema_version)
# Ensure our check can re-run each time
Rake::Task[:schema_version_check].reenable
end