Commit f184a421 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'sh-fix-issue-9246' into 'master'

Don't validate Jenkins username if password is blank

Closes #9246

See merge request gitlab-org/gitlab-ee!9198
parents 951b41a9 0d40c074
...@@ -7,7 +7,7 @@ class JenkinsService < CiService ...@@ -7,7 +7,7 @@ class JenkinsService < CiService
validates :jenkins_url, presence: true, url: true, if: :activated? validates :jenkins_url, presence: true, url: true, if: :activated?
validates :project_name, presence: true, if: :activated? validates :project_name, presence: true, if: :activated?
validates :username, presence: true, if: ->(service) { service.activated? && service.password_touched? } validates :username, presence: true, if: ->(service) { service.activated? && service.password_touched? && service.password.present? }
default_value_for :push_events, true default_value_for :push_events, true
default_value_for :merge_requests_events, false default_value_for :merge_requests_events, false
......
---
title: Don't validate Jenkins username if password is blank
merge_request: 9198
author:
type: fixed
...@@ -60,6 +60,15 @@ describe JenkinsService do ...@@ -60,6 +60,15 @@ describe JenkinsService do
it { is_expected.to validate_presence_of :username } it { is_expected.to validate_presence_of :username }
end end
context 'when password is blank' do
it 'does not validate the username' do
expect(subject).not_to validate_presence_of :username
subject.password = ''
subject.save
end
end
end end
context 'when the service is inactive' do context 'when the service is inactive' 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