Fix validation to allow updates to description/color of project label

parent fc59d357
...@@ -14,7 +14,7 @@ class ProjectLabel < Label ...@@ -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 ...@@ -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
......
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