summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-25 00:08:11 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-25 00:08:11 +0000
commit23bc19cb73aad969c9636b8b935111645e809e54 (patch)
tree887c9e014f8345f577769db4f75315ca59853b98 /spec
parentc4db541c1b2c97ab1eda354ea3899489fe5c33e5 (diff)
downloadgitlab-ce-23bc19cb73aad969c9636b8b935111645e809e54.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/finders/releases_finder_spec.rb12
-rw-r--r--spec/frontend/pages/projects/shared/permissions/components/settings_panel_spec.js62
-rw-r--r--spec/models/project_spec.rb29
-rw-r--r--spec/models/snippet_spec.rb18
-rw-r--r--spec/support/shared_examples/models/concerns/has_repository_shared_examples.rb33
5 files changed, 112 insertions, 42 deletions
diff --git a/spec/finders/releases_finder_spec.rb b/spec/finders/releases_finder_spec.rb
index b9c67361f45..3da5ee47b6b 100644
--- a/spec/finders/releases_finder_spec.rb
+++ b/spec/finders/releases_finder_spec.rb
@@ -52,6 +52,18 @@ describe ReleasesFinder do
subject
end
end
+
+ # See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/27716
+ context 'when tag is nil' do
+ before do
+ v1_0_0.update_column(:tag, nil)
+ end
+
+ it 'ignores rows with a nil tag' do
+ expect(subject.size).to eq(1)
+ expect(subject).to eq([v1_1_0])
+ end
+ end
end
end
end
diff --git a/spec/frontend/pages/projects/shared/permissions/components/settings_panel_spec.js b/spec/frontend/pages/projects/shared/permissions/components/settings_panel_spec.js
index c304dfd2048..76948f3ff4c 100644
--- a/spec/frontend/pages/projects/shared/permissions/components/settings_panel_spec.js
+++ b/spec/frontend/pages/projects/shared/permissions/components/settings_panel_spec.js
@@ -1,4 +1,4 @@
-import { shallowMount } from '@vue/test-utils';
+import { shallowMount, mount } from '@vue/test-utils';
import settingsPanel from '~/pages/projects/shared/permissions/components/settings_panel.vue';
import {
@@ -32,6 +32,8 @@ const defaultProps = {
registryHelpPath: '/help/user/packages/container_registry/index',
lfsAvailable: true,
lfsHelpPath: '/help/workflow/lfs/manage_large_binaries_with_git_lfs',
+ lfsObjectsExist: false,
+ lfsObjectsRemovalHelpPath: `/help/administration/lfs/manage_large_binaries_with_git_lfs#removing-objects-from-lfs`,
pagesAvailable: true,
pagesAccessControlEnabled: false,
pagesAccessControlForced: false,
@@ -43,21 +45,25 @@ const defaultProps = {
describe('Settings Panel', () => {
let wrapper;
- const mountComponent = customProps => {
- const propsData = { ...defaultProps, ...customProps };
- return shallowMount(settingsPanel, { propsData });
+ const mountComponent = (
+ { currentSettings = {}, ...customProps } = {},
+ mountFn = shallowMount,
+ ) => {
+ const propsData = {
+ ...defaultProps,
+ ...customProps,
+ currentSettings: { ...defaultProps.currentSettings, ...currentSettings },
+ };
+
+ return mountFn(settingsPanel, { propsData });
};
const overrideCurrentSettings = (currentSettingsProps, extraProps = {}) => {
- return mountComponent({
- ...extraProps,
- currentSettings: {
- ...defaultProps.currentSettings,
- ...currentSettingsProps,
- },
- });
+ return mountComponent({ ...extraProps, currentSettings: currentSettingsProps });
};
+ const findLFSSettingsMessage = () => wrapper.find({ ref: 'git-lfs-settings' }).find('p');
+
beforeEach(() => {
wrapper = mountComponent();
});
@@ -333,6 +339,40 @@ describe('Settings Panel', () => {
expect(wrapper.find('[name="project[lfs_enabled]"]').props().disabledInput).toEqual(true);
});
+
+ describe.each`
+ lfsObjectsExist | lfsEnabled | isShown
+ ${true} | ${true} | ${false}
+ ${true} | ${false} | ${true}
+ ${false} | ${true} | ${false}
+ ${false} | ${false} | ${false}
+ `(
+ 'with (lfsObjectsExist = $lfsObjectsExist, lfsEnabled = $lfsEnabled)',
+ ({ lfsObjectsExist, lfsEnabled, isShown }) => {
+ beforeEach(() => {
+ wrapper = mountComponent({ lfsObjectsExist, currentSettings: { lfsEnabled } }, mount);
+ });
+
+ if (isShown) {
+ it('shows warning message', () => {
+ const message = findLFSSettingsMessage();
+ const link = message.find('a');
+
+ expect(message.text()).toContain(
+ 'LFS objects from this repository are still available to forks',
+ );
+ expect(link.text()).toEqual('How do I remove them?');
+ expect(link.attributes('href')).toEqual(
+ '/help/administration/lfs/manage_large_binaries_with_git_lfs#removing-objects-from-lfs',
+ );
+ });
+ } else {
+ it('does not show warning message', () => {
+ expect(findLFSSettingsMessage().exists()).toEqual(false);
+ });
+ }
+ },
+ );
});
describe('Packages', () => {
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index f0423937710..2586289a699 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -1391,35 +1391,14 @@ describe Project do
context 'repository storage by default' do
let(:project) { build(:project) }
- before do
- storages = {
- 'default' => Gitlab::GitalyClient::StorageSettings.new('path' => 'tmp/tests/repositories'),
- 'picked' => Gitlab::GitalyClient::StorageSettings.new('path' => 'tmp/tests/repositories')
- }
- allow(Gitlab.config.repositories).to receive(:storages).and_return(storages)
- end
-
it 'picks storage from ApplicationSetting' do
- expect_any_instance_of(ApplicationSetting).to receive(:pick_repository_storage).and_return('picked')
+ expect_next_instance_of(ApplicationSetting) do |instance|
+ expect(instance).to receive(:pick_repository_storage).and_return('picked')
+ end
+ expect(described_class).to receive(:pick_repository_storage).and_call_original
expect(project.repository_storage).to eq('picked')
end
-
- it 'picks from the latest available storage', :request_store do
- stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
- Gitlab::CurrentSettings.current_application_settings
-
- settings = ApplicationSetting.last
- settings.repository_storages = %w(picked)
- settings.save!
-
- expect(Gitlab::CurrentSettings.repository_storages).to eq(%w(default))
-
- project
-
- expect(project.repository.storage).to eq('picked')
- expect(Gitlab::CurrentSettings.repository_storages).to eq(%w(picked))
- end
end
context 'shared runners by default' do
diff --git a/spec/models/snippet_spec.rb b/spec/models/snippet_spec.rb
index 533c10363ca..0e19dfc147b 100644
--- a/spec/models/snippet_spec.rb
+++ b/spec/models/snippet_spec.rb
@@ -655,10 +655,18 @@ describe Snippet do
describe '#repository_storage' do
let(:snippet) { create(:snippet) }
- it 'returns default repository storage' do
- expect(Gitlab::CurrentSettings).to receive(:pick_repository_storage)
+ subject { snippet.repository_storage }
- snippet.repository_storage
+ before do
+ expect_next_instance_of(ApplicationSetting) do |instance|
+ expect(instance).to receive(:pick_repository_storage).and_return('picked')
+ end
+ end
+
+ it 'returns repository storage from ApplicationSetting' do
+ expect(described_class).to receive(:pick_repository_storage).and_call_original
+
+ expect(subject).to eq 'picked'
end
context 'when snippet_project is already created' do
@@ -669,9 +677,7 @@ describe Snippet do
end
it 'returns repository_storage from snippet_project' do
- expect(Gitlab::CurrentSettings).not_to receive(:pick_repository_storage)
-
- expect(snippet.repository_storage).to eq 'foo'
+ expect(subject).to eq 'foo'
end
end
end
diff --git a/spec/support/shared_examples/models/concerns/has_repository_shared_examples.rb b/spec/support/shared_examples/models/concerns/has_repository_shared_examples.rb
index d5606e65981..5a5d7c8f038 100644
--- a/spec/support/shared_examples/models/concerns/has_repository_shared_examples.rb
+++ b/spec/support/shared_examples/models/concerns/has_repository_shared_examples.rb
@@ -168,4 +168,37 @@ RSpec.shared_examples 'model with repository' do
it { is_expected.to respond_to(:base_dir) }
it { is_expected.to respond_to(:disk_path) }
end
+
+ describe '.pick_repository_storage' do
+ subject { described_class.pick_repository_storage }
+
+ before do
+ storages = {
+ 'default' => Gitlab::GitalyClient::StorageSettings.new('path' => 'tmp/tests/repositories'),
+ 'picked' => Gitlab::GitalyClient::StorageSettings.new('path' => 'tmp/tests/repositories')
+ }
+ allow(Gitlab.config.repositories).to receive(:storages).and_return(storages)
+ end
+
+ it 'picks storage from ApplicationSetting' do
+ expect_next_instance_of(ApplicationSetting) do |instance|
+ expect(instance).to receive(:pick_repository_storage).and_return('picked')
+ end
+
+ expect(subject).to eq('picked')
+ end
+
+ it 'picks from the latest available storage', :request_store do
+ stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
+ Gitlab::CurrentSettings.current_application_settings
+
+ settings = ApplicationSetting.last
+ settings.repository_storages = %w(picked)
+ settings.save!
+
+ expect(Gitlab::CurrentSettings.repository_storages).to eq(%w(default))
+ expect(subject).to eq('picked')
+ expect(Gitlab::CurrentSettings.repository_storages).to eq(%w(picked))
+ end
+ end
end