From ddd268b03b6f35c68e5a89606dbfd516f72846fd Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Fri, 7 Feb 2020 03:08:59 +0000 Subject: [PATCH] Add latest changes from gitlab-org/gitlab@master --- app/controllers/registrations_controller.rb | 5 ++ .../vale/styles/gitlab/Substitutions.yml | 36 ++++++++++++ doc/user/clusters/management_project.md | 4 +- doc/user/project/service_desk.md | 5 ++ spec/services/spam/ham_service_spec.rb | 56 +++++++++++++++++++ 5 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 doc/.linting/vale/styles/gitlab/Substitutions.yml create mode 100644 spec/services/spam/ham_service_spec.rb diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 29b0c6b29ae..ed5e39478f1 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -13,6 +13,7 @@ class RegistrationsController < Devise::RegistrationsController before_action :whitelist_query_limiting, only: [:destroy] before_action :ensure_terms_accepted, if: -> { action_name == 'create' && Gitlab::CurrentSettings.current_application_settings.enforce_terms? } + before_action :load_recaptcha, only: :new def new if experiment_enabled?(:signup_flow) @@ -183,6 +184,10 @@ class RegistrationsController < Devise::RegistrationsController stored_location_for(user) || dashboard_projects_path end + def load_recaptcha + Gitlab::Recaptcha.load_configurations! + end + # Part of an experiment to build a new sign up flow. Will be resolved # with https://gitlab.com/gitlab-org/growth/engineering/issues/64 def choose_layout diff --git a/doc/.linting/vale/styles/gitlab/Substitutions.yml b/doc/.linting/vale/styles/gitlab/Substitutions.yml new file mode 100644 index 00000000000..d9ae1dfcb07 --- /dev/null +++ b/doc/.linting/vale/styles/gitlab/Substitutions.yml @@ -0,0 +1,36 @@ +--- +# `extends` indicates the Vale extension point being used. +# Full list of styles: https://errata-ai.github.io/vale/styles/ +extends: substitution + +# Substitution rules can display the matched and suggested strings in the +# message shown to the user. The first use of %s prints the suggested option, +# and the second use of %s displays what was found in the text. +message: Use "%s" instead of "%s." + +# Should a result be flagged as a suggestion, warning, or error? +# Results that fall below the MinAlertLevel set in +# https://gitlab.com/gitlab-org/gitlab/blob/master/.vale.ini won't be shown. +level: warning + +# Should a match be case-insensitive or case-sensitive? +# Acceptable values are 'true' or 'false' +ignorecase: true + +# Should this rule be limited to a specific scope? If yes, uncomment the line. +# Possible scopes: https://errata-ai.github.io/vale/formats/#available-scopes +# scope: heading + +# Should this rule ignore normal word boundaries, such as \b ? +# Acceptable values are 'true' or 'false' +nonword: true + +# What is the source for this rule? +link: https://about.gitlab.com/handbook/communication/#top-misused-terms + +# The 'swap' section provides a list of values, one per line, in the form of +# $bad: $good +swap: + GitLabber: GitLab team member + self hosted: self-managed + self-hosted: self-managed diff --git a/doc/user/clusters/management_project.md b/doc/user/clusters/management_project.md index 57a1f46ac6e..5a5ab4dce05 100644 --- a/doc/user/clusters/management_project.md +++ b/doc/user/clusters/management_project.md @@ -24,9 +24,9 @@ other projects will continue to receive [namespace scoped `edit` level privilege Management projects are restricted to the following: -- For project-level clusters, the management project must in the same +- For project-level clusters, the management project must be in the same namespace (or descendants) as the cluster's project. -- For group-level clusters, the management project must in the same +- For group-level clusters, the management project must be in the same group (or descendants) as as the cluster's group. - For instance-level clusters, there are no such restrictions. diff --git a/doc/user/project/service_desk.md b/doc/user/project/service_desk.md index 131e2413e5f..ad0e33207ce 100644 --- a/doc/user/project/service_desk.md +++ b/doc/user/project/service_desk.md @@ -108,6 +108,11 @@ You can use `%{ISSUE_ID}` placeholder which will be replaced by an issue iid in the email, `%{ISSUE_PATH}` placeholder which will be replaced by project path and the issue iid and `%{NOTE_TEXT}` placeholder which will be replaced by the note text. +### Using custom email display name + +You can customize the email display name. Emails sent from Service Desk will have +this name in the `From` header. The default display name is `GitLab Support Bot`. + ## Using Service Desk ### As an end user (issue creator) diff --git a/spec/services/spam/ham_service_spec.rb b/spec/services/spam/ham_service_spec.rb new file mode 100644 index 00000000000..9e60078edfe --- /dev/null +++ b/spec/services/spam/ham_service_spec.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Spam::HamService do + let_it_be(:user) { create(:user) } + let!(:spam_log) { create(:spam_log, user: user, submitted_as_ham: false) } + let(:fake_akismet_service) { double(:akismet_service) } + + subject { described_class.new(spam_log) } + + before do + allow(Spam::AkismetService).to receive(:new).and_return fake_akismet_service + end + + describe '#mark_as_ham!' do + context 'AkismetService returns false (Akismet cannot be reached, etc)' do + before do + allow(fake_akismet_service).to receive(:submit_ham).and_return false + end + + it 'returns false' do + expect(subject.mark_as_ham!).to be_falsey + end + + it 'does not update the record' do + expect { subject.mark_as_ham! }.not_to change { spam_log.submitted_as_ham } + end + + context 'if spam log record has already been marked as spam' do + before do + spam_log.update_attribute(:submitted_as_ham, true) + end + + it 'does not update the record' do + expect { subject.mark_as_ham! }.not_to change { spam_log.submitted_as_ham } + end + end + end + + context 'Akismet ham submission is successful' do + before do + spam_log.update_attribute(:submitted_as_ham, false) + allow(fake_akismet_service).to receive(:submit_ham).and_return true + end + + it 'returns true' do + expect(subject.mark_as_ham!).to be_truthy + end + + it 'updates the record' do + expect { subject.mark_as_ham! }.to change { spam_log.submitted_as_ham }.from(false).to(true) + end + end + end +end