Commit d1613be7 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch '13847-new-issue-epic' into 'master'

Accept epic_id param in IssuesController

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