Skip to content

Commit

Permalink
Fix validation to allow updates to description/color of project label
Browse files Browse the repository at this point in the history
  • Loading branch information
dbalexandre committed Oct 19, 2016
1 parent fc59d35 commit cece77f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/project_label.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def to_reference(target_project = nil, format: :id)
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)
Expand Down
10 changes: 10 additions & 0 deletions spec/models/project_label_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@

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

Expand Down

0 comments on commit cece77f

Please sign in to comment.