Commit 643c6186 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'zj/gitlab-ce-unique-milestone-title-per-project'

parents e0f923a1 308c967d
......@@ -41,6 +41,7 @@ v 8.5.0 (unreleased)
- In seach autocomplete show only groups and projects you are member of
- Fix: init.d script not working on OS X
- Faster snippet search
- Title for milestones should be unique (Zeger-Jan van de Weg)
v 8.4.4
- Update omniauth-saml gem to 1.4.2
......
......@@ -34,7 +34,7 @@ class Milestone < ActiveRecord::Base
scope :closed, -> { with_state(:closed) }
scope :of_projects, ->(ids) { where(project_id: ids) }
validates :title, presence: true
validates :title, presence: true, uniqueness: { scope: :project_id }
validates :project, presence: true
strip_attributes :title
......
......@@ -33,6 +33,20 @@ describe Milestone, models: true do
let(:milestone) { create(:milestone) }
let(:issue) { create(:issue) }
describe "unique milestone title per project" do
it "shouldn't accept the same title in a project twice" do
new_milestone = Milestone.new(project: milestone.project, title: milestone.title)
expect(new_milestone).not_to be_valid
end
it "should accept the same title in another project" do
project = build(:project)
new_milestone = Milestone.new(project: project, title: milestone.title)
expect(new_milestone).to be_valid
end
end
describe "#percent_complete" do
it "should not count open issues" do
milestone.issues << issue
......
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