diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-02-22 09:21:36 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-02-22 09:21:36 +0000 |
commit | a7a0873829ffbb9e69effd5803792cb2614d3581 (patch) | |
tree | 9e9787fda9f53373727248757286667d7846f38c | |
parent | 5a84b5fd7c5e281de7fad55a308ff35da64f50ca (diff) | |
parent | 7f67b6c210b201c409176e2a59db771b5fe9b28d (diff) | |
download | gitlab-ce-a7a0873829ffbb9e69effd5803792cb2614d3581.tar.gz |
Merge branch '27287-label-dropdown-error-messages' into 'master'
Fix form response errors not shown for create label dropdown.
See merge request !9058
-rw-r--r-- | app/assets/javascripts/create_label.js.es6 | 6 | ||||
-rw-r--r-- | changelogs/unreleased/27287-label-dropdown-error-messages.yml | 4 | ||||
-rw-r--r-- | spec/features/issues/issue_sidebar_spec.rb | 65 |
3 files changed, 43 insertions, 32 deletions
diff --git a/app/assets/javascripts/create_label.js.es6 b/app/assets/javascripts/create_label.js.es6 index 947c129d5b5..85384d98126 100644 --- a/app/assets/javascripts/create_label.js.es6 +++ b/app/assets/javascripts/create_label.js.es6 @@ -107,9 +107,9 @@ if (typeof label.message === 'string') { errors = label.message; } else { - errors = label.message.map(function (value, key) { - return key + " " + value[0]; - }).join("<br/>"); + errors = Object.keys(label.message).map(key => + `${gl.text.humanize(key)} ${label.message[key].join(', ')}` + ).join("<br/>"); } this.$newLabelError diff --git a/changelogs/unreleased/27287-label-dropdown-error-messages.yml b/changelogs/unreleased/27287-label-dropdown-error-messages.yml new file mode 100644 index 00000000000..dfd4102c324 --- /dev/null +++ b/changelogs/unreleased/27287-label-dropdown-error-messages.yml @@ -0,0 +1,4 @@ +--- +title: Fix displaying error messages for create label dropdown +merge_request: 9058 +author: Tom Koole diff --git a/spec/features/issues/issue_sidebar_spec.rb b/spec/features/issues/issue_sidebar_spec.rb index 1eb981942ea..7b9d4534ada 100644 --- a/spec/features/issues/issue_sidebar_spec.rb +++ b/spec/features/issues/issue_sidebar_spec.rb @@ -7,9 +7,9 @@ feature 'Issue Sidebar', feature: true do let(:project) { create(:project, :public) } let(:issue) { create(:issue, project: project) } let!(:user) { create(:user)} + let!(:label) { create(:label, project: project, title: 'bug') } before do - create(:label, project: project, title: 'bug') login_as(user) end @@ -50,16 +50,6 @@ feature 'Issue Sidebar', feature: true do visit_issue(project, issue) end - describe 'when clicking on edit labels', js: true do - it 'shows dropdown option to create a new label' do - find('.block.labels .edit-link').click - - page.within('.block.labels') do - expect(page).to have_content 'Create new' - end - end - end - context 'sidebar', js: true do it 'changes size when the screen size is smaller' do sidebar_selector = 'aside.right-sidebar.right-sidebar-collapsed' @@ -77,36 +67,53 @@ feature 'Issue Sidebar', feature: true do end end - context 'creating a new label', js: true do - it 'shows option to crate a new label is present' do + context 'editing issue labels', js: true do + before do page.within('.block.labels') do find('.edit-link').click + end + end + it 'shows option to create a new label' do + page.within('.block.labels') do expect(page).to have_content 'Create new' end end - it 'shows dropdown switches to "create label" section' do - page.within('.block.labels') do - find('.edit-link').click - click_link 'Create new' + context 'creating a new label', js: true do + before do + page.within('.block.labels') do + click_link 'Create new' + end + end - expect(page).to have_content 'Create new label' + it 'shows dropdown switches to "create label" section' do + page.within('.block.labels') do + expect(page).to have_content 'Create new label' + end end - end - it 'adds new label' do - page.within('.block.labels') do - find('.edit-link').click - sleep 1 - click_link 'Create new' + it 'adds new label' do + page.within('.block.labels') do + fill_in 'new_label_name', with: 'wontfix' + page.find(".suggest-colors a", match: :first).click + click_button 'Create' + + page.within('.dropdown-page-one') do + expect(page).to have_content 'wontfix' + end + end + end - fill_in 'new_label_name', with: 'wontfix' - page.find(".suggest-colors a", match: :first).click - click_button 'Create' + it 'shows error message if label title is taken' do + page.within('.block.labels') do + fill_in 'new_label_name', with: label.title + page.find('.suggest-colors a', match: :first).click + click_button 'Create' - page.within('.dropdown-page-one') do - expect(page).to have_content 'wontfix' + page.within('.dropdown-page-two') do + expect(page).to have_content 'Title has already been taken' + end end end end |