Commit 5e8f3a30 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'add-grouplink-whitespace-validation' into 'master'

Strip whitespace from saml group link name

See merge request gitlab-org/gitlab!69406
parents 667c8fda adfce540
# frozen_string_literal: true
class SamlGroupLink < ApplicationRecord
include StripAttribute
belongs_to :group
enum access_level: ::Gitlab::Access.options_with_owner
strip_attributes! :saml_group_name
validates :group, :access_level, presence: true
validates :saml_group_name, presence: true, uniqueness: { scope: [:group_id] }, length: { maximum: 255 }
......
......@@ -21,6 +21,15 @@ RSpec.describe SamlGroupLink do
it { is_expected.to validate_uniqueness_of(:saml_group_name).scoped_to([:group_id]) }
end
context 'saml_group_name with whitespaces' do
it 'saves group link name without whitespace' do
saml_group_link = described_class.new(saml_group_name: ' group ')
saml_group_link.valid?
expect(saml_group_link.saml_group_name).to eq('group')
end
end
end
describe '.by_id_and_group_id' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment