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-06-16 21:09:42 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-06-16 21:09:42 +0300
commitc44eade0d7b09c9d80c42aba6d1974ce9cd3146b (patch)
treeda0710de0a519f225755737cf5ffd93c75d1da8f /spec
parent0c87da93750c6428328a3e3cd2ebd0882f6294e3 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/frontend/design_management/components/design_notes/__snapshots__/design_note_spec.js.snap2
-rw-r--r--spec/frontend/lib/utils/secret_detection_spec.js2
-rw-r--r--spec/frontend/repository/components/blob_viewers/geo_json/geo_json_viewer_spec.js40
-rw-r--r--spec/frontend/repository/components/blob_viewers/geo_json/utils_spec.js68
-rw-r--r--spec/lib/gitlab/database/migrations/constraints_helpers_spec.rb39
-rw-r--r--spec/lib/gitlab/git/repository_spec.rb37
-rw-r--r--spec/lib/gitlab/gitaly_client/commit_service_spec.rb281
-rw-r--r--spec/models/group_spec.rb8
-rw-r--r--spec/models/user_spec.rb18
-rw-r--r--spec/support/helpers/test_env.rb22
10 files changed, 476 insertions, 41 deletions
diff --git a/spec/frontend/design_management/components/design_notes/__snapshots__/design_note_spec.js.snap b/spec/frontend/design_management/components/design_notes/__snapshots__/design_note_spec.js.snap
index 30793c95cbd..9bb85ecf569 100644
--- a/spec/frontend/design_management/components/design_notes/__snapshots__/design_note_spec.js.snap
+++ b/spec/frontend/design_management/components/design_notes/__snapshots__/design_note_spec.js.snap
@@ -53,7 +53,7 @@ exports[`Design note component should match the snapshot 1`] = `
/>
<gllink-stub
- class="note-timestamp system-note-separator gl-display-block gl-mb-2"
+ class="note-timestamp system-note-separator gl-display-block gl-mb-2 gl-font-sm"
href="#note_123"
>
<timeagotooltip-stub
diff --git a/spec/frontend/lib/utils/secret_detection_spec.js b/spec/frontend/lib/utils/secret_detection_spec.js
index 8815c40e3e3..3213ecf3fe1 100644
--- a/spec/frontend/lib/utils/secret_detection_spec.js
+++ b/spec/frontend/lib/utils/secret_detection_spec.js
@@ -26,6 +26,8 @@ describe('containsSensitiveToken', () => {
'token: glpat-cgyKc1k_AsnEpmP-5fRL',
'token: GlPat-abcdefghijklmnopqrstuvwxyz',
'token: feed_token=ABCDEFGHIJKLMNOPQRSTUVWXYZ',
+ 'token: feed_token=glft-ABCDEFGHIJKLMNOPQRSTUVWXYZ',
+ 'token: feed_token=glft-a8cc74ccb0de004d09a968705ba49099229b288b3de43f26c473a9d8d7fb7693-1234',
'https://example.com/feed?feed_token=123456789_abcdefghij',
'glpat-1234567890 and feed_token=ABCDEFGHIJKLMNOPQRSTUVWXYZ',
];
diff --git a/spec/frontend/repository/components/blob_viewers/geo_json/geo_json_viewer_spec.js b/spec/frontend/repository/components/blob_viewers/geo_json/geo_json_viewer_spec.js
new file mode 100644
index 00000000000..15918b4d8d5
--- /dev/null
+++ b/spec/frontend/repository/components/blob_viewers/geo_json/geo_json_viewer_spec.js
@@ -0,0 +1,40 @@
+import { nextTick } from 'vue';
+import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
+import GeoJsonViewer from '~/repository/components/blob_viewers/geo_json/geo_json_viewer.vue';
+import { initLeafletMap } from '~/repository/components/blob_viewers/geo_json/utils';
+import { RENDER_ERROR_MSG } from '~/repository/components/blob_viewers/geo_json/constants';
+import { createAlert } from '~/alert';
+
+jest.mock('~/repository/components/blob_viewers/geo_json/utils');
+jest.mock('~/alert');
+
+describe('GeoJson Viewer', () => {
+ let wrapper;
+
+ const GEO_JSON_MOCK_DATA = '{ "type": "FeatureCollection" }';
+
+ const createComponent = (rawTextBlob = GEO_JSON_MOCK_DATA) => {
+ wrapper = shallowMountExtended(GeoJsonViewer, {
+ propsData: { blob: { rawTextBlob } },
+ });
+ };
+
+ beforeEach(() => createComponent());
+
+ const findMapWrapper = () => wrapper.findByTestId('map');
+
+ it('calls a the initLeafletMap util', () => {
+ const mapWrapper = findMapWrapper();
+
+ expect(initLeafletMap).toHaveBeenCalledWith(mapWrapper.element, JSON.parse(GEO_JSON_MOCK_DATA));
+ expect(mapWrapper.exists()).toBe(true);
+ });
+
+ it('displays an error if invalid json is provided', async () => {
+ createComponent('invalid JSON');
+ await nextTick();
+
+ expect(createAlert).toHaveBeenCalledWith({ message: RENDER_ERROR_MSG });
+ expect(findMapWrapper().exists()).toBe(false);
+ });
+});
diff --git a/spec/frontend/repository/components/blob_viewers/geo_json/utils_spec.js b/spec/frontend/repository/components/blob_viewers/geo_json/utils_spec.js
new file mode 100644
index 00000000000..c80a83c0ca0
--- /dev/null
+++ b/spec/frontend/repository/components/blob_viewers/geo_json/utils_spec.js
@@ -0,0 +1,68 @@
+import { map, tileLayer, geoJson, featureGroup, Icon } from 'leaflet';
+import * as utils from '~/repository/components/blob_viewers/geo_json/utils';
+import {
+ OPEN_STREET_TILE_URL,
+ MAP_ATTRIBUTION,
+ OPEN_STREET_COPYRIGHT_LINK,
+ ICON_CONFIG,
+} from '~/repository/components/blob_viewers/geo_json/constants';
+
+jest.mock('leaflet', () => ({
+ featureGroup: () => ({ getBounds: jest.fn() }),
+ Icon: { Default: { mergeOptions: jest.fn() } },
+ tileLayer: jest.fn(),
+ map: jest.fn().mockReturnValue({ fitBounds: jest.fn() }),
+ geoJson: jest.fn().mockReturnValue({ addTo: jest.fn() }),
+}));
+
+describe('GeoJson utilities', () => {
+ const mockWrapper = document.createElement('div');
+ const mockData = { test: 'data' };
+
+ describe('initLeafletMap', () => {
+ describe('valid params', () => {
+ beforeEach(() => utils.initLeafletMap(mockWrapper, mockData));
+
+ it('sets the correct icon', () => {
+ expect(Icon.Default.mergeOptions).toHaveBeenCalledWith(ICON_CONFIG);
+ });
+
+ it('inits the leaflet map', () => {
+ const attribution = `${MAP_ATTRIBUTION} ${OPEN_STREET_COPYRIGHT_LINK}`;
+
+ expect(tileLayer).toHaveBeenCalledWith(OPEN_STREET_TILE_URL, { attribution });
+ expect(map).toHaveBeenCalledWith(mockWrapper, { layers: [] });
+ });
+
+ it('adds geojson data to the leaflet map', () => {
+ expect(geoJson().addTo).toHaveBeenCalledWith(map());
+ });
+
+ it('fits the map to the correct bounds', () => {
+ expect(map().fitBounds).toHaveBeenCalledWith(featureGroup().getBounds());
+ });
+
+ it('generates popup content containing the metaData', () => {
+ const popupContent = utils.popupContent(mockData);
+
+ expect(popupContent).toContain(Object.keys(mockData)[0]);
+ expect(popupContent).toContain(mockData.test);
+ });
+ });
+
+ describe('invalid params', () => {
+ it.each([
+ [null, null],
+ [null, mockData],
+ [mockWrapper, null],
+ ])('does nothing (returns early) if any of the params are not provided', (wrapper, data) => {
+ utils.initLeafletMap(wrapper, data);
+ expect(Icon.Default.mergeOptions).not.toHaveBeenCalled();
+ expect(tileLayer).not.toHaveBeenCalled();
+ expect(map).not.toHaveBeenCalled();
+ expect(geoJson().addTo).not.toHaveBeenCalled();
+ expect(map().fitBounds).not.toHaveBeenCalled();
+ });
+ });
+ });
+});
diff --git a/spec/lib/gitlab/database/migrations/constraints_helpers_spec.rb b/spec/lib/gitlab/database/migrations/constraints_helpers_spec.rb
index 07d913cf5cc..476b5f3a784 100644
--- a/spec/lib/gitlab/database/migrations/constraints_helpers_spec.rb
+++ b/spec/lib/gitlab/database/migrations/constraints_helpers_spec.rb
@@ -679,4 +679,43 @@ RSpec.describe Gitlab::Database::Migrations::ConstraintsHelpers do
end
end
end
+
+ describe '#switch_constraint_names' do
+ before do
+ ActiveRecord::Migration.connection.create_table(:_test_table) do |t|
+ t.references :supplier, foreign_key: { to_table: :_test_table, name: :supplier_fk }
+ t.references :customer, foreign_key: { to_table: :_test_table, name: :customer_fk }
+ end
+ end
+
+ context 'when inside a transaction' do
+ it 'raises an error' do
+ expect(model).to receive(:transaction_open?).and_return(true)
+
+ expect do
+ model.switch_constraint_names(:_test_table, :supplier_fk, :customer_fk)
+ end.to raise_error(RuntimeError)
+ end
+ end
+
+ context 'when outside a transaction' do
+ before do
+ allow(model).to receive(:transaction_open?).and_return(false)
+ end
+
+ it 'executes the statement to swap the constraint names' do
+ expect { model.switch_constraint_names(:_test_table, :supplier_fk, :customer_fk) }
+ .to change { constrained_column_for(:customer_fk) }.from(:customer_id).to(:supplier_id)
+ .and change { constrained_column_for(:supplier_fk) }.from(:supplier_id).to(:customer_id)
+ end
+
+ def constrained_column_for(fk_name)
+ Gitlab::Database::PostgresForeignKey
+ .find_by!(referenced_table_name: :_test_table, name: fk_name)
+ .constrained_columns
+ .first
+ .to_sym
+ end
+ end
+ end
end
diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb
index 78a2470b808..b137157f2d5 100644
--- a/spec/lib/gitlab/git/repository_spec.rb
+++ b/spec/lib/gitlab/git/repository_spec.rb
@@ -1454,7 +1454,7 @@ RSpec.describe Gitlab::Git::Repository, feature_category: :source_code_managemen
it "returns the number of commits in the whole repository" do
options = { all: true }
- expect(repository.count_commits(options)).to eq(316)
+ expect(repository.count_commits(options)).to eq(322)
end
end
@@ -1675,6 +1675,41 @@ RSpec.describe Gitlab::Git::Repository, feature_category: :source_code_managemen
expect(collection).to be_a(Enumerable)
expect(collection.to_a).to be_empty
end
+
+ describe 'merge_commit_diff_mode argument' do
+ let(:gitaly_commit_client) { double('Gitlab::GitalyClient::CommitService') }
+
+ before do
+ allow(repository).to receive(:gitaly_commit_client).and_return(gitaly_commit_client)
+ allow(gitaly_commit_client).to receive(:find_changed_paths)
+ end
+
+ context 'when omitted' do
+ before do
+ repository.find_changed_paths(['sha'])
+ end
+
+ it 'defaults to nil' do
+ expect(gitaly_commit_client)
+ .to have_received(:find_changed_paths)
+ .with(['sha'], merge_commit_diff_mode: nil)
+ end
+ end
+
+ context 'when included' do
+ let(:passed_value) { 'foobar' }
+
+ before do
+ repository.find_changed_paths(['sha'], merge_commit_diff_mode: passed_value)
+ end
+
+ it 'passes the value on to the commit client' do
+ expect(gitaly_commit_client)
+ .to have_received(:find_changed_paths)
+ .with(['sha'], merge_commit_diff_mode: passed_value)
+ end
+ end
+ end
end
describe "#ls_files" do
diff --git a/spec/lib/gitlab/gitaly_client/commit_service_spec.rb b/spec/lib/gitlab/gitaly_client/commit_service_spec.rb
index ddec335a54a..70c4a2a71ff 100644
--- a/spec/lib/gitlab/gitaly_client/commit_service_spec.rb
+++ b/spec/lib/gitlab/gitaly_client/commit_service_spec.rb
@@ -168,34 +168,171 @@ RSpec.describe Gitlab::GitalyClient::CommitService, feature_category: :gitaly do
end
describe '#find_changed_paths' do
- let(:commits) { %w[1a0b36b3cdad1d2ee32457c102a8c0b7056fa863 cfe32cf61b73a0d5e9f13e774abde7ff789b1660] }
+ let(:mapped_merge_commit_diff_mode) { described_class::MERGE_COMMIT_DIFF_MODES[merge_commit_diff_mode] }
+ let(:commits) do
+ %w[
+ ade1c0b4b116209ed2a9958436b26f89085ec383
+ 594937c22df7a093888ff13af518f2b683f5f719
+ 760c58db5a6f3b64ad7e3ff6b3c4a009da7d9b33
+ 2b298117a741cdb06eb48df2c33f1390cf89f7e8
+ c41e12c387b4e0e41bfc17208252d6a6430f2fcd
+ 1ada92f78a19f27cb442a0a205f1c451a3a15432
+ ]
+ end
+
let(:requests) do
- [
+ commits.map do |commit|
Gitaly::FindChangedPathsRequest::Request.new(
- commit_request: Gitaly::FindChangedPathsRequest::Request::CommitRequest.new(commit_revision: '1a0b36b3cdad1d2ee32457c102a8c0b7056fa863')
- ),
- Gitaly::FindChangedPathsRequest::Request.new(
- commit_request: Gitaly::FindChangedPathsRequest::Request::CommitRequest.new(commit_revision: 'cfe32cf61b73a0d5e9f13e774abde7ff789b1660')
+ commit_request: Gitaly::FindChangedPathsRequest::Request::CommitRequest.new(commit_revision: commit)
)
- ]
+ end
end
- it 'sends an RPC request and returns the stats' do
- request = Gitaly::FindChangedPathsRequest.new(repository: repository_message, requests: requests)
+ let(:request) do
+ Gitaly::FindChangedPathsRequest.new(repository: repository_message, requests: requests, merge_commit_diff_mode: merge_commit_diff_mode)
+ end
+
+ subject { described_class.new(repository).find_changed_paths(commits, merge_commit_diff_mode: merge_commit_diff_mode).as_json }
+
+ before do
+ allow(Gitaly::FindChangedPathsRequest).to receive(:new).and_call_original
+ end
+
+ shared_examples 'includes paths different in any parent' do
+ let(:changed_paths) do
+ [
+ { path: 'files/locked/foo.lfs', status: 'ADDED' },
+ { path: 'files/locked/foo.lfs', status: 'MODIFIED' },
+ { path: 'files/locked/bar.lfs', status: 'ADDED' },
+ { path: 'files/locked/foo.lfs', status: 'MODIFIED' },
+ { path: 'files/locked/bar.lfs', status: 'ADDED' },
+ { path: 'files/locked/bar.lfs', status: 'MODIFIED' },
+ { path: 'files/locked/bar.lfs', status: 'MODIFIED' },
+ { path: 'files/locked/baz.lfs', status: 'ADDED' },
+ { path: 'files/locked/baz.lfs', status: 'ADDED' }
+ ].as_json
+ end
+
+ it 'returns all paths, including ones from merge commits' do
+ is_expected.to eq(changed_paths)
+ end
+ end
+
+ shared_examples 'includes paths different in all parents' do
+ let(:changed_paths) do
+ [
+ { path: 'files/locked/foo.lfs', status: 'ADDED' },
+ { path: 'files/locked/foo.lfs', status: 'MODIFIED' },
+ { path: 'files/locked/bar.lfs', status: 'ADDED' },
+ { path: 'files/locked/bar.lfs', status: 'MODIFIED' },
+ { path: 'files/locked/baz.lfs', status: 'ADDED' },
+ { path: 'files/locked/baz.lfs', status: 'ADDED' }
+ ].as_json
+ end
+
+ it 'returns only paths different in all parents' do
+ is_expected.to eq(changed_paths)
+ end
+ end
+
+ shared_examples 'uses requests format' do
+ it 'passes the revs via the requests kwarg as CommitRequest objects' do
+ subject
+ expect(Gitaly::FindChangedPathsRequest)
+ .to have_received(:new).with(
+ repository: repository_message,
+ requests: requests,
+ merge_commit_diff_mode: mapped_merge_commit_diff_mode
+ )
+ end
+ end
+
+ context 'when merge_commit_diff_mode is nil' do
+ let(:merge_commit_diff_mode) { nil }
+
+ include_examples 'includes paths different in any parent'
+
+ include_examples 'uses requests format'
+ end
+
+ context 'when merge_commit_diff_mode is :unspecified' do
+ let(:merge_commit_diff_mode) { :unspecified }
+
+ include_examples 'includes paths different in any parent'
+
+ include_examples 'uses requests format'
+ end
+
+ context 'when merge_commit_diff_mode is :include_merges' do
+ let(:merge_commit_diff_mode) { :include_merges }
+
+ include_examples 'includes paths different in any parent'
+
+ include_examples 'uses requests format'
+ end
+
+ context 'when merge_commit_diff_mode is invalid' do
+ let(:merge_commit_diff_mode) { 'invalid' }
+
+ include_examples 'includes paths different in any parent'
+
+ include_examples 'uses requests format'
+ end
+
+ context 'when merge_commit_diff_mode is :all_parents' do
+ let(:merge_commit_diff_mode) { :all_parents }
+
+ include_examples 'includes paths different in all parents'
+
+ include_examples 'uses requests format'
+ end
+
+ context 'when feature flag "merge_commit_diff_modes" is disabled' do
+ let(:mapped_merge_commit_diff_mode) { nil }
+
+ before do
+ stub_feature_flags(merge_commit_diff_modes: false)
+ end
+
+ context 'when merge_commit_diff_mode is nil' do
+ let(:merge_commit_diff_mode) { nil }
+
+ include_examples 'includes paths different in any parent'
+
+ include_examples 'uses requests format'
+ end
+
+ context 'when merge_commit_diff_mode is :unspecified' do
+ let(:merge_commit_diff_mode) { :unspecified }
+
+ include_examples 'includes paths different in any parent'
+
+ include_examples 'uses requests format'
+ end
+
+ context 'when merge_commit_diff_mode is :include_merges' do
+ let(:merge_commit_diff_mode) { :include_merges }
+
+ include_examples 'includes paths different in any parent'
- changed_paths_response = Gitaly::FindChangedPathsResponse.new(
- paths: [{
- path: "app/assets/javascripts/boards/components/project_select.vue",
- status: :MODIFIED
- }])
+ include_examples 'uses requests format'
+ end
+
+ context 'when merge_commit_diff_mode is invalid' do
+ let(:merge_commit_diff_mode) { 'invalid' }
- expect_any_instance_of(Gitaly::DiffService::Stub).to receive(:find_changed_paths)
- .with(request, kind_of(Hash)).and_return([changed_paths_response])
+ include_examples 'includes paths different in any parent'
+
+ include_examples 'uses requests format'
+ end
- returned_value = described_class.new(repository).find_changed_paths(commits)
- mapped_expected_value = changed_paths_response.paths.map { |path| Gitlab::Git::ChangedPath.new(status: path.status, path: path.path) }
+ context 'when merge_commit_diff_mode is :all_parents' do
+ let(:merge_commit_diff_mode) { :all_parents }
- expect(returned_value.as_json).to eq(mapped_expected_value.as_json)
+ include_examples 'includes paths different in any parent'
+
+ include_examples 'uses requests format'
+ end
end
context 'when feature flag "find_changed_paths_new_format" is disabled' do
@@ -203,22 +340,104 @@ RSpec.describe Gitlab::GitalyClient::CommitService, feature_category: :gitaly do
stub_feature_flags(find_changed_paths_new_format: false)
end
- it 'sends an RPC request and returns the stats' do
- request = Gitaly::FindChangedPathsRequest.new(repository: repository_message, commits: commits)
+ shared_examples 'uses commits format' do
+ it do
+ subject
+ expect(Gitaly::FindChangedPathsRequest)
+ .to have_received(:new).with(
+ repository: repository_message,
+ commits: commits,
+ merge_commit_diff_mode: mapped_merge_commit_diff_mode
+ )
+ end
+ end
+
+ context 'when merge_commit_diff_mode is nil' do
+ let(:merge_commit_diff_mode) { nil }
+
+ include_examples 'includes paths different in any parent'
+
+ include_examples 'uses commits format'
+ end
+
+ context 'when merge_commit_diff_mode is :unspecified' do
+ let(:merge_commit_diff_mode) { :unspecified }
+
+ include_examples 'includes paths different in any parent'
+
+ include_examples 'uses commits format'
+ end
+
+ context 'when merge_commit_diff_mode is :include_merges' do
+ let(:merge_commit_diff_mode) { :include_merges }
- changed_paths_response = Gitaly::FindChangedPathsResponse.new(
- paths: [{
- path: "app/assets/javascripts/boards/components/project_select.vue",
- status: :MODIFIED
- }])
+ include_examples 'includes paths different in any parent'
- expect_any_instance_of(Gitaly::DiffService::Stub).to receive(:find_changed_paths)
- .with(request, kind_of(Hash)).and_return([changed_paths_response])
+ include_examples 'uses commits format'
+ end
- returned_value = described_class.new(repository).find_changed_paths(commits)
- mapped_expected_value = changed_paths_response.paths.map { |path| Gitlab::Git::ChangedPath.new(status: path.status, path: path.path) }
+ context 'when merge_commit_diff_mode is invalid' do
+ let(:merge_commit_diff_mode) { 'invalid' }
+
+ include_examples 'includes paths different in any parent'
+
+ include_examples 'uses commits format'
+ end
- expect(returned_value.as_json).to eq(mapped_expected_value.as_json)
+ context 'when merge_commit_diff_mode is :all_parents' do
+ let(:merge_commit_diff_mode) { :all_parents }
+
+ include_examples 'includes paths different in all parents'
+
+ include_examples 'uses commits format'
+ end
+
+ context 'when feature flag "merge_commit_diff_modes" is disabled' do
+ let(:mapped_merge_commit_diff_mode) { nil }
+
+ before do
+ stub_feature_flags(merge_commit_diff_modes: false)
+ end
+
+ context 'when merge_commit_diff_mode is nil' do
+ let(:merge_commit_diff_mode) { nil }
+
+ include_examples 'includes paths different in any parent'
+
+ include_examples 'uses commits format'
+ end
+
+ context 'when merge_commit_diff_mode is :unspecified' do
+ let(:merge_commit_diff_mode) { :unspecified }
+
+ include_examples 'includes paths different in any parent'
+
+ include_examples 'uses commits format'
+ end
+
+ context 'when merge_commit_diff_mode is :include_merges' do
+ let(:merge_commit_diff_mode) { :include_merges }
+
+ include_examples 'includes paths different in any parent'
+
+ include_examples 'uses commits format'
+ end
+
+ context 'when merge_commit_diff_mode is invalid' do
+ let(:merge_commit_diff_mode) { 'invalid' }
+
+ include_examples 'includes paths different in any parent'
+
+ include_examples 'uses commits format'
+ end
+
+ context 'when merge_commit_diff_mode is :all_parents' do
+ let(:merge_commit_diff_mode) { :all_parents }
+
+ include_examples 'includes paths different in any parent'
+
+ include_examples 'uses commits format'
+ end
end
end
end
diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb
index b1f66c76f95..527ee96ca86 100644
--- a/spec/models/group_spec.rb
+++ b/spec/models/group_spec.rb
@@ -10,10 +10,11 @@ RSpec.describe Group, feature_category: :groups_and_projects do
describe 'associations' do
it { is_expected.to have_many :projects }
+ it { is_expected.to have_many(:all_group_members).dependent(:destroy) }
it { is_expected.to have_many(:group_members).dependent(:destroy) }
it { is_expected.to have_many(:namespace_members) }
it { is_expected.to have_many(:users).through(:group_members) }
- it { is_expected.to have_many(:owners).through(:group_members) }
+ it { is_expected.to have_many(:owners).through(:all_group_members) }
it { is_expected.to have_many(:requesters).dependent(:destroy) }
it { is_expected.to have_many(:namespace_requesters) }
it { is_expected.to have_many(:members_and_requesters) }
@@ -1448,10 +1449,9 @@ RSpec.describe Group, feature_category: :groups_and_projects do
let(:developer) { create(:user) }
it 'returns the owners of a Group' do
- group.add_owner(owner)
- group.add_developer(developer)
+ members = setup_group_members(group)
- expect(group.owners).to eq([owner])
+ expect(group.owners).to eq([members[:owner]])
end
end
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 768198bc826..690c0be3b7a 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -2090,7 +2090,7 @@ RSpec.describe User, feature_category: :user_profile do
user = create(:user)
- expect(user.incoming_email_token).to eql('gitlab')
+ expect(user.incoming_email_token).to eql("glimt-gitlab")
end
end
@@ -2137,6 +2137,12 @@ RSpec.describe User, feature_category: :user_profile do
expect(user.reload.feed_token).to eq feed_token
end
+ it 'returns feed tokens with a prefix' do
+ user = create(:user)
+
+ expect(user.feed_token).to start_with('glft-')
+ end
+
it 'ensures no feed token when disabled' do
allow(Gitlab::CurrentSettings).to receive(:disable_feed_token).and_return(true)
@@ -2184,7 +2190,7 @@ RSpec.describe User, feature_category: :user_profile do
describe 'enabled_static_object_token' do
let_it_be(:static_object_token) { 'ilqx6jm1u945macft4eff0nw' }
- it 'returns incoming email token when supported' do
+ it 'returns static object token when supported' do
allow(Gitlab::CurrentSettings).to receive(:static_objects_external_storage_enabled?).and_return(true)
user = create(:user, static_object_token: static_object_token)
@@ -2212,6 +2218,14 @@ RSpec.describe User, feature_category: :user_profile do
expect(user.enabled_incoming_email_token).to eq(incoming_email_token)
end
+ it 'returns incoming mail tokens with a prefix' do
+ allow(Gitlab::Email::IncomingEmail).to receive(:supports_issue_creation?).and_return(true)
+
+ user = create(:user)
+
+ expect(user.enabled_incoming_email_token).to start_with('glimt-')
+ end
+
it 'returns `nil` when not supported' do
allow(Gitlab::Email::IncomingEmail).to receive(:supports_issue_creation?).and_return(false)
diff --git a/spec/support/helpers/test_env.rb b/spec/support/helpers/test_env.rb
index c45b48e27f8..da4954c1a5f 100644
--- a/spec/support/helpers/test_env.rb
+++ b/spec/support/helpers/test_env.rb
@@ -9,7 +9,24 @@ module TestEnv
ComponentFailedToInstallError = Class.new(StandardError)
- # When developing the seed repository, comment out the branch you will modify.
+ # https://gitlab.com/gitlab-org/gitlab-test is used to seed your local gdk
+ # GitLab application and is also used in rspec tests. Because of this, when
+ # building and testing features that require a specific type of file, you can
+ # add them to the gitlab-test repo in order to access that blob during
+ # development or testing.
+ #
+ # To add new branches
+ #
+ # 1. Push a new branch to gitlab-org/gitlab-test.
+ # 2. Execute rm -rf tmp/tests in your gitlab repo.
+ # 3. Add your branch and its HEAD commit sha to the BRANCH_SHA hash
+ #
+ # To add new commits to an existing branch
+ #
+ # 1. Push a new commit to a branch in gitlab-org/gitlab-test.
+ # 2. Execute rm -rf tmp/tests in your gitlab repo.
+ # 3. Update the HEAD sha value in the BRANCH_SHA hash
+ #
BRANCH_SHA = {
'signed-commits' => 'c7794c1',
'gpg-signed' => '8a852d5',
@@ -94,7 +111,8 @@ module TestEnv
'smime-signed-commits' => 'ed775cc',
'Ääh-test-utf-8' => '7975be0',
'ssh-signed-commit' => '7b5160f',
- 'changes-with-whitespace' => 'f2d141fadb33ceaafc95667c1a0a308ad5edc5f9'
+ 'changes-with-whitespace' => 'f2d141fadb33ceaafc95667c1a0a308ad5edc5f9',
+ 'lock-detection' => '1ada92f78a19f27cb442a0a205f1c451a3a15432'
}.freeze
# gitlab-test-fork is a fork of gitlab-fork, but we don't necessarily