GitLab steht aufgrund wichtiger Wartungsarbeiten am Montag, den 8. März, zwischen 17:00 und 19:00 Uhr nicht zur Verfügung.

Commit 01ab6d70 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Use association search in issuable create service

parent 006d8b26
......@@ -57,10 +57,11 @@ def filter_assignee
end
def filter_milestone
return unless params[:milestone_id]
milestone_id = params[:milestone_id]
return unless milestone_id
if params[:milestone_id] == IssuableFinder::NONE ||
Milestone.find(params[:milestone_id]).try(:project) != project
if milestone_id == IssuableFinder::NONE ||
project.milestones.find_by(id: milestone_id).nil?
params[:milestone_id] = ''
end
end
......@@ -68,9 +69,8 @@ def filter_milestone
def filter_labels
return if params[:label_ids].to_a.empty?
params[:label_ids].select! do |label_id|
Label.find(label_id).try(:project) == project
end
params[:label_ids] =
project.labels.where(id: params[:label_ids]).pluck(:id)
end
def update(issuable)
......
......@@ -4,13 +4,13 @@
let(:project) { create(:empty_project) }
let(:user) { create(:user) }
describe :execute do
let(:issue) { Issues::CreateService.new(project, user, opts).execute }
describe '#execute' do
let(:issue) { described_class.new(project, user, opts).execute }
context 'valid params' do
context 'when params are valid' do
let(:assignee) { create(:user) }
let(:milestone) { create(:milestone, project: project) }
let(:labels) { create_list(:label, 4, project: project) }
let(:labels) { create_pair(:label, project: project) }
before do
project.team << [user, :master]
......@@ -45,7 +45,7 @@
expect(Todo.where(attributes).count).to eq 1
end
context 'label that belongs to different project' do
context 'when label belongs to different project' do
let(:label) { create(:label) }
let(:opts) do
......@@ -59,7 +59,7 @@
end
end
context 'milestone that belongs to different project' do
context 'when milestone belongs to different project' do
let(:milestone) { create(:milestone) }
let(:opts) do
......
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