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

This commit is contained in:
Douglas Barbosa Alexandre 2016-10-13 17:45:39 -03:00
parent fc59d35720
commit cece77f273
2 changed files with 11 additions and 1 deletions

View File

@ -14,7 +14,7 @@ class ProjectLabel < Label
private
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?
errors.add(:title, :label_already_exists_at_group_level, group: group.name)

View File

@ -40,6 +40,16 @@ describe ProjectLabel, models: true do
expect(label.errors[:title]).to be_empty
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