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>2022-09-08 15:12:41 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-09-08 15:12:41 +0300
commit8fea353b907d1fd571f5450a757cafee73cfbfd0 (patch)
tree38cd1edddd3de94d6f743029c164fab5691a7241 /spec
parentdb5097a28b061ef273a058aa64845c79635ea4e7 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/features/admin/admin_settings_spec.rb2
-rw-r--r--spec/frontend/diffs/components/diff_gutter_avatars_spec.js6
-rw-r--r--spec/frontend/sidebar/components/sidebar_dropdown_widget_spec.js18
-rw-r--r--spec/helpers/application_settings_helper_spec.rb60
-rw-r--r--spec/requests/api/users_spec.rb25
-rw-r--r--spec/requests/jira_connect/oauth_callbacks_controller_spec.rb6
6 files changed, 109 insertions, 8 deletions
diff --git a/spec/features/admin/admin_settings_spec.rb b/spec/features/admin/admin_settings_spec.rb
index 0f5d9892e66..a5df142d188 100644
--- a/spec/features/admin/admin_settings_spec.rb
+++ b/spec/features/admin/admin_settings_spec.rb
@@ -562,7 +562,7 @@ RSpec.describe 'Admin updates settings' do
it 'change Prometheus settings' do
page.within('.as-prometheus') do
- check 'Enable health and performance metrics endpoint'
+ check 'Enable GitLab Prometheus metrics endpoint'
click_button 'Save changes'
end
diff --git a/spec/frontend/diffs/components/diff_gutter_avatars_spec.js b/spec/frontend/diffs/components/diff_gutter_avatars_spec.js
index e95d0656893..ee96b939ec6 100644
--- a/spec/frontend/diffs/components/diff_gutter_avatars_spec.js
+++ b/spec/frontend/diffs/components/diff_gutter_avatars_spec.js
@@ -1,6 +1,7 @@
import { shallowMount } from '@vue/test-utils';
import { nextTick } from 'vue';
import DiffGutterAvatars from '~/diffs/components/diff_gutter_avatars.vue';
+import { HIDE_COMMENTS } from '~/diffs/i18n';
import discussionsMockData from '../mock_data/diff_discussions';
const getDiscussionsMockData = () => [{ ...discussionsMockData }];
@@ -42,6 +43,11 @@ describe('DiffGutterAvatars', () => {
await nextTick();
expect(wrapper.emitted().toggleLineDiscussions).toBeDefined();
});
+
+ it('renders the proper title and aria-label ', () => {
+ expect(findCollapseButton().attributes('title')).toBe(HIDE_COMMENTS);
+ expect(findCollapseButton().attributes('aria-label')).toBe(HIDE_COMMENTS);
+ });
});
describe('when collapsed', () => {
diff --git a/spec/frontend/sidebar/components/sidebar_dropdown_widget_spec.js b/spec/frontend/sidebar/components/sidebar_dropdown_widget_spec.js
index 8ebd2dabfc2..6761731c093 100644
--- a/spec/frontend/sidebar/components/sidebar_dropdown_widget_spec.js
+++ b/spec/frontend/sidebar/components/sidebar_dropdown_widget_spec.js
@@ -238,6 +238,24 @@ describe('SidebarDropdownWidget', () => {
expect(findSelectedAttribute().text()).toBe('None');
});
});
+
+ describe("when user doesn't have permission to view current attribute", () => {
+ it('renders no permission text', () => {
+ createComponent({
+ data: {
+ hasCurrentAttribute: true,
+ currentAttribute: null,
+ },
+ queries: {
+ currentAttribute: { loading: false },
+ },
+ });
+
+ expect(findSelectedAttribute().text()).toBe(
+ `You don't have permission to view this ${wrapper.props('issuableAttribute')}.`,
+ );
+ });
+ });
});
describe('when a user can edit', () => {
diff --git a/spec/helpers/application_settings_helper_spec.rb b/spec/helpers/application_settings_helper_spec.rb
index fab1fed797c..1703727db21 100644
--- a/spec/helpers/application_settings_helper_spec.rb
+++ b/spec/helpers/application_settings_helper_spec.rb
@@ -297,6 +297,66 @@ RSpec.describe ApplicationSettingsHelper do
end
end
+ describe '.spam_check_endpoint_enabled?' do
+ subject { helper.spam_check_endpoint_enabled? }
+
+ context 'when spam check endpoint is enabled' do
+ before do
+ stub_application_setting(spam_check_endpoint_enabled: true)
+ end
+
+ it { is_expected.to be true }
+ end
+
+ context 'when spam check endpoint is disabled' do
+ before do
+ stub_application_setting(spam_check_endpoint_enabled: false)
+ end
+
+ it { is_expected.to be false }
+ end
+ end
+
+ describe '.anti_spam_service_enabled?' do
+ subject { helper.anti_spam_service_enabled? }
+
+ context 'when akismet is enabled and spam check endpoint is disabled' do
+ before do
+ stub_application_setting(spam_check_endpoint_enabled: false)
+ stub_application_setting(akismet_enabled: true)
+ end
+
+ it { is_expected.to be true }
+ end
+
+ context 'when akismet is disabled and spam check endpoint is enabled' do
+ before do
+ stub_application_setting(spam_check_endpoint_enabled: true)
+ stub_application_setting(akismet_enabled: false)
+ end
+
+ it { is_expected.to be true }
+ end
+
+ context 'when akismet and spam check endpoint are both enabled' do
+ before do
+ stub_application_setting(spam_check_endpoint_enabled: true)
+ stub_application_setting(akismet_enabled: true)
+ end
+
+ it { is_expected.to be true }
+ end
+
+ context 'when akismet and spam check endpoint are both disabled' do
+ before do
+ stub_application_setting(spam_check_endpoint_enabled: false)
+ stub_application_setting(akismet_enabled: false)
+ end
+
+ it { is_expected.to be false }
+ end
+ end
+
describe '#sidekiq_job_limiter_modes_for_select' do
subject { helper.sidekiq_job_limiter_modes_for_select }
diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb
index d28c25d8f3d..674d25d399e 100644
--- a/spec/requests/api/users_spec.rb
+++ b/spec/requests/api/users_spec.rb
@@ -3,6 +3,8 @@
require 'spec_helper'
RSpec.describe API::Users do
+ include WorkhorseHelpers
+
let_it_be(:admin) { create(:admin) }
let_it_be(:user, reload: true) { create(:user, username: 'user.withdot') }
let_it_be(:key) { create(:key, user: user) }
@@ -1180,6 +1182,22 @@ RSpec.describe API::Users do
expect(new_user.user_preference.view_diffs_file_by_file?).to eq(true)
end
+ it "creates user with avatar" do
+ workhorse_form_with_file(
+ api('/users', admin),
+ method: :post,
+ file_key: :avatar,
+ params: attributes_for(:user, avatar: fixture_file_upload('spec/fixtures/banana_sample.gif', 'image/gif'))
+ )
+
+ expect(response).to have_gitlab_http_status(:created)
+
+ new_user = User.find_by(id: json_response['id'])
+
+ expect(new_user).not_to eq(nil)
+ expect(json_response['avatar_url']).to include(new_user.avatar_path)
+ end
+
it "does not create user with invalid email" do
post api('/users', admin),
params: {
@@ -1478,7 +1496,12 @@ RSpec.describe API::Users do
end
it 'updates user with avatar' do
- put api("/users/#{user.id}", admin), params: { avatar: fixture_file_upload('spec/fixtures/banana_sample.gif', 'image/gif') }
+ workhorse_form_with_file(
+ api("/users/#{user.id}", admin),
+ method: :put,
+ file_key: :avatar,
+ params: { avatar: fixture_file_upload('spec/fixtures/banana_sample.gif', 'image/gif') }
+ )
user.reload
diff --git a/spec/requests/jira_connect/oauth_callbacks_controller_spec.rb b/spec/requests/jira_connect/oauth_callbacks_controller_spec.rb
index 1e4628e5d59..12b9429b648 100644
--- a/spec/requests/jira_connect/oauth_callbacks_controller_spec.rb
+++ b/spec/requests/jira_connect/oauth_callbacks_controller_spec.rb
@@ -5,12 +5,6 @@ require 'spec_helper'
RSpec.describe JiraConnect::OauthCallbacksController do
describe 'GET /-/jira_connect/oauth_callbacks' do
context 'when logged in' do
- let_it_be(:user) { create(:user) }
-
- before do
- sign_in(user)
- end
-
it 'renders a page prompting the user to close the window' do
get '/-/jira_connect/oauth_callbacks'