Commit 36359350 authored by Jarka Košanová's avatar Jarka Košanová

Accept epic_id param in IssuesController

parent 87cdcfa4
......@@ -47,6 +47,7 @@ module EE
def issue_params_attributes
attrs = super
attrs.unshift(:weight) if project.feature_available?(:issue_weights)
attrs.unshift(:epic_id) if project.group&.feature_available?(:epics)
attrs
end
......
......@@ -81,15 +81,16 @@ describe Projects::IssuesController do
end
end
describe 'issue weights' do
let(:project) { create(:project) }
describe 'licensed features' do
let(:project) { create(:project, group: namespace) }
let(:user) { create(:user) }
let(:epic) { create(:epic, group: namespace) }
let(:issue) { create(:issue, project: project, weight: 5) }
let(:issue2) { create(:issue, project: project, weight: 1) }
let(:new_issue) { build(:issue, project: project, weight: 5) }
before do
project.add_developer(user)
namespace.add_developer(user)
sign_in(user)
end
......@@ -99,7 +100,7 @@ describe Projects::IssuesController do
context 'licensed' do
before do
stub_licensed_features(issue_weights: true)
stub_licensed_features(issue_weights: true, epics: true)
end
describe '#index' do
......@@ -124,30 +125,32 @@ describe Projects::IssuesController do
end
describe '#update' do
it 'sets issue weight' do
perform :put, :update, id: issue.to_param, issue: { weight: 6 }, format: :json
it 'sets issue weight and epic' do
perform :put, :update, id: issue.to_param, issue: { weight: 6, epic_id: epic.id }, format: :json
expect(response).to have_gitlab_http_status(:ok)
expect(issue.reload.weight).to eq(6)
expect(issue.epic).to eq(epic)
end
end
describe '#create' do
it 'sets issue weight' do
perform :post, :create, issue: new_issue.attributes
it 'sets issue weight and epic' do
perform :post, :create, issue: new_issue.attributes.merge(epic_id: epic.id)
expect(response).to have_gitlab_http_status(:found)
expect(Issue.count).to eq(1)
issue = Issue.first
expect(issue.weight).to eq(new_issue.weight)
expect(issue.epic).to eq(epic)
end
end
end
context 'unlicensed' do
before do
stub_licensed_features(issue_weights: false)
stub_licensed_features(issue_weights: false, epics: false)
end
describe '#index' do
......@@ -172,14 +175,15 @@ describe Projects::IssuesController do
end
describe '#create' do
it 'does not set issue weight' do
it 'does not set issue weight ane epic' do
perform :post, :create, issue: new_issue.attributes
expect(response).to have_gitlab_http_status(:found)
expect(Issue.count).to eq(1)
issue = Issue.first
expect(issue.read_attribute(:weight)).to be_nil
expect(issue.weight).to be_nil
expect(issue.epic).to be_nil
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