Fix validation to allow updates to description/color of project label
This commit is contained in:
parent
fc59d35720
commit
cece77f273
|
@ -14,7 +14,7 @@ class ProjectLabel < Label
|
||||||
private
|
private
|
||||||
|
|
||||||
def title_must_not_exist_at_group_level
|
def title_must_not_exist_at_group_level
|
||||||
return unless group.present?
|
return unless group.present? && title_changed?
|
||||||
|
|
||||||
if group.labels.with_title(self.title).exists?
|
if group.labels.with_title(self.title).exists?
|
||||||
errors.add(:title, :label_already_exists_at_group_level, group: group.name)
|
errors.add(:title, :label_already_exists_at_group_level, group: group.name)
|
||||||
|
|
|
@ -40,6 +40,16 @@ describe ProjectLabel, models: true do
|
||||||
|
|
||||||
expect(label.errors[:title]).to be_empty
|
expect(label.errors[:title]).to be_empty
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'does not returns error when title does not change' do
|
||||||
|
project_label = create(:label, project: project, name: 'Security')
|
||||||
|
create(:group_label, group: group, name: 'Security')
|
||||||
|
project_label.description = 'Security related stuff.'
|
||||||
|
|
||||||
|
project_label.valid?
|
||||||
|
|
||||||
|
expect(project_label .errors[:title]).to be_empty
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue