Commit 2a715242 authored by Thong Kuah's avatar Thong Kuah

Merge branch 'sh-fix-issue-404-epics' into 'master'

Fix 404 errors when "No epic" selected

Closes #226999

See merge request gitlab-org/gitlab!36137
parents fdc866a7 22d14c36
...@@ -26,7 +26,7 @@ module EE ...@@ -26,7 +26,7 @@ module EE
def find_epic(issue) def find_epic(issue)
id = params.delete(:epic_id) id = params.delete(:epic_id)
return unless id.present? return if id.to_i.zero?
group = issue.project.group group = issue.project.group
return unless group.present? return unless group.present?
......
---
title: Fix 404 errors when "No epic" selected
merge_request: 36137
author:
type: fixed
...@@ -3,16 +3,20 @@ ...@@ -3,16 +3,20 @@
require "spec_helper" require "spec_helper"
RSpec.describe "User creates issue", :js do RSpec.describe "User creates issue", :js do
let(:user) { create(:user) } let_it_be(:user) { create(:user) }
let(:group) { create(:group, :public) } let_it_be(:group) { create(:group, :public) }
let(:project) { create(:project_empty_repo, :public, namespace: group) } let_it_be(:project) { create(:project_empty_repo, :public, namespace: group) }
let!(:epic) { create(:epic, group: group, title: 'Sample epic', author: user) } let_it_be(:epic) { create(:epic, group: group, title: 'Sample epic', author: user) }
let(:issue_title) { '500 error on profile' }
before_all do
group.add_developer(user)
end
before do before do
stub_licensed_features(issue_weights: true) stub_licensed_features(issue_weights: true)
stub_licensed_features(epics: true) stub_licensed_features(epics: true)
group.add_developer(user)
sign_in(user) sign_in(user)
visit(new_project_issue_path(project)) visit(new_project_issue_path(project))
...@@ -20,7 +24,6 @@ RSpec.describe "User creates issue", :js do ...@@ -20,7 +24,6 @@ RSpec.describe "User creates issue", :js do
context "with weight set" do context "with weight set" do
it "creates issue" do it "creates issue" do
issue_title = "500 error on profile"
weight = "7" weight = "7"
fill_in("Title", with: issue_title) fill_in("Title", with: issue_title)
...@@ -36,19 +39,30 @@ RSpec.describe "User creates issue", :js do ...@@ -36,19 +39,30 @@ RSpec.describe "User creates issue", :js do
end end
end end
context "with epic set" do context 'with epics' do
it "creates issue" do before do
issue_title = "500 error on profile"
fill_in("Title", with: issue_title) fill_in("Title", with: issue_title)
page.within('.issue-epic .js-epic-block') do scroll_to(page.find('.epic-dropdown-container', visible: false))
page.find('.js-epic-select').click end
wait_for_requests
page.find('.dropdown-content .gl-link', text: epic.title).click it 'creates an issue with no epic' do
click_button 'Select epic'
click_link('No Epic')
click_button('Submit issue')
wait_for_all_requests
page.within(".js-epic-block .js-epic-label") do
expect(page).to have_content('None')
end end
click_button("Submit issue") expect(page).to have_content(issue_title)
end
it 'credates an issue with an epic' do
click_button 'Select epic'
click_link(epic.title)
click_button('Submit issue')
wait_for_all_requests wait_for_all_requests
......
...@@ -13,6 +13,17 @@ RSpec.shared_examples 'issue with epic_id parameter' do ...@@ -13,6 +13,17 @@ RSpec.shared_examples 'issue with epic_id parameter' do
end end
end end
context 'when epic_id is 0' do
let(:params) { { title: 'issue1', epic_id: 0 } }
it 'ignores epic_id' do
issue = execute
expect(issue).to be_persisted
expect(issue.epic).to be_nil
end
end
context 'when user can not add issues to the epic' do context 'when user can not add issues to the epic' do
before do before do
project.add_maintainer(user) project.add_maintainer(user)
......
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