Skip to content
Snippets Groups Projects
Verified Commit f2695aa8 authored by Matija Čupić's avatar Matija Čupić
Browse files

Include CI Variable Key in its uniqueness validation error message

parent c7dac22e
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -6,7 +6,10 @@ module Ci
 
belongs_to :group
 
validates :key, uniqueness: { scope: :group_id }
validates :key, uniqueness: {
scope: :group_id,
message: "(%{value}) has already been taken"
}
 
scope :unprotected, -> { where(protected: false) }
end
Loading
Loading
Loading
Loading
@@ -6,7 +6,10 @@ module Ci
 
belongs_to :project
 
validates :key, uniqueness: { scope: [:project_id, :environment_scope] }
validates :key, uniqueness: {
scope: [:project_id, :environment_scope],
message: "(%{value}) has already been taken"
}
 
scope :unprotected, -> { where(protected: false) }
end
Loading
Loading
Loading
Loading
@@ -5,7 +5,7 @@ describe Ci::GroupVariable do
 
it { is_expected.to include_module(HasVariable) }
it { is_expected.to include_module(Presentable) }
it { is_expected.to validate_uniqueness_of(:key).scoped_to(:group_id) }
it { is_expected.to validate_uniqueness_of(:key).scoped_to(:group_id).with_message(/\(\w+\) has already been taken/) }
 
describe '.unprotected' do
subject { described_class.unprotected }
Loading
Loading
Loading
Loading
@@ -6,7 +6,7 @@ describe Ci::Variable do
describe 'validations' do
it { is_expected.to include_module(HasVariable) }
it { is_expected.to include_module(Presentable) }
it { is_expected.to validate_uniqueness_of(:key).scoped_to(:project_id, :environment_scope) }
it { is_expected.to validate_uniqueness_of(:key).scoped_to(:project_id, :environment_scope).with_message(/\(\w+\) has already been taken/) }
end
 
describe '.unprotected' do
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment