Commit 65df166b authored by Toon Claes's avatar Toon Claes

Merge form_ee_spec.rb into ee/form_spec.rb

parent 4c1af6cc
......@@ -23,7 +23,80 @@ describe 'New/edit issue', :feature, :js do
context 'new issue' do
before do
visit new_namespace_project_issue_path(project.namespace, project)
visit new_project_issue_path(project)
end
describe 'shorten users API pagination limit' do
before do
# Using `allow_any_instance_of`/`and_wrap_original`, `original` would
# somehow refer to the very block we defined to _wrap_ that method, instead of
# the original method, resulting in infinite recurison when called.
# This is likely a bug with helper modules included into dynamically generated view classes.
# To work around this, we have to hold on to and call to the original implementation manually.
original_issue_dropdown_options = EE::FormHelper.instance_method(:issue_assignees_dropdown_options)
allow_any_instance_of(EE::FormHelper).to receive(:issue_assignees_dropdown_options).and_wrap_original do |original, *args|
options = original_issue_dropdown_options.bind(original.receiver).call(*args)
options[:data][:per_page] = 2
options
end
visit new_project_issue_path(project)
click_button 'Unassigned'
wait_for_requests
end
it 'should display selected users even if they are not part of the original API call' do
find('.dropdown-input-field').native.send_keys user2.name
page.within '.dropdown-menu-user' do
expect(page).to have_content user2.name
click_link user2.name
end
find('.js-dropdown-input-clear').click
page.within '.dropdown-menu-user' do
expect(page).to have_content user.name
expect(find('.dropdown-menu-user a.is-active').first(:xpath, '..')['data-user-id']).to eq(user2.id.to_s)
end
end
end
describe 'multiple assignees' do
before do
click_button 'Unassigned'
wait_for_requests
end
it 'unselects other assignees when unassigned is selected' do
page.within '.dropdown-menu-user' do
click_link user2.name
end
page.within '.dropdown-menu-user' do
click_link 'Unassigned'
end
expect(find('input[name="issue[assignee_ids][]"]', visible: false).value).to match('0')
end
it 'toggles assign to me when current user is selected and unselected' do
page.within '.dropdown-menu-user' do
click_link user.name
end
expect(find('a', text: 'Assign to me', visible: false)).not_to be_visible
page.within('.dropdown-menu-user') do
click_link user.name
end
expect(find('a', text: 'Assign to me')).to be_visible
end
end
it 'allows user to create new issue' do
......@@ -140,7 +213,7 @@ describe 'New/edit issue', :feature, :js do
context 'edit issue' do
before do
visit edit_namespace_project_issue_path(project.namespace, project, issue)
visit edit_project_issue_path(project, issue)
end
it 'allows user to update issue' do
......
require 'rails_helper'
describe 'New/edit issue (EE)', :feature, :js do
include GitlabRoutingHelper
include ActionView::Helpers::JavaScriptHelper
include FormHelper
let!(:project) { create(:project) }
let!(:user) { create(:user)}
let!(:user2) { create(:user)}
let!(:milestone) { create(:milestone, project: project) }
let!(:label) { create(:label, project: project) }
let!(:label2) { create(:label, project: project) }
let!(:issue) { create(:issue, project: project, assignees: [user], milestone: milestone) }
before do
project.team << [user, :master]
project.team << [user2, :master]
gitlab_sign_in(user)
end
context 'new issue' do
before do
visit new_project_issue_path(project)
end
describe 'shorten users API pagination limit' do
before do
# Using `allow_any_instance_of`/`and_wrap_original`, `original` would
# somehow refer to the very block we defined to _wrap_ that method, instead of
# the original method, resulting in infinite recurison when called.
# This is likely a bug with helper modules included into dynamically generated view classes.
# To work around this, we have to hold on to and call to the original implementation manually.
original_issue_dropdown_options = EE::FormHelper.instance_method(:issue_assignees_dropdown_options)
allow_any_instance_of(EE::FormHelper).to receive(:issue_assignees_dropdown_options).and_wrap_original do |original, *args|
options = original_issue_dropdown_options.bind(original.receiver).call(*args)
options[:data][:per_page] = 2
options
end
visit new_project_issue_path(project)
click_button 'Unassigned'
wait_for_requests
end
it 'should display selected users even if they are not part of the original API call' do
find('.dropdown-input-field').native.send_keys user2.name
page.within '.dropdown-menu-user' do
expect(page).to have_content user2.name
click_link user2.name
end
find('.js-dropdown-input-clear').click
page.within '.dropdown-menu-user' do
expect(page).to have_content user.name
expect(find('.dropdown-menu-user a.is-active').first(:xpath, '..')['data-user-id']).to eq(user2.id.to_s)
end
end
end
describe 'multiple assignees' do
before do
click_button 'Unassigned'
wait_for_requests
end
it 'unselects other assignees when unassigned is selected' do
page.within '.dropdown-menu-user' do
click_link user2.name
end
page.within '.dropdown-menu-user' do
click_link 'Unassigned'
end
expect(find('input[name="issue[assignee_ids][]"]', visible: false).value).to match('0')
end
it 'toggles assign to me when current user is selected and unselected' do
page.within '.dropdown-menu-user' do
click_link user.name
end
expect(find('a', text: 'Assign to me', visible: false)).not_to be_visible
page.within('.dropdown-menu-user') do
click_link user.name
end
expect(find('a', text: 'Assign to me')).to be_visible
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