Commit f56aec0c authored by Toon Claes's avatar Toon Claes

Port CE specs back to EE

Make sure that EE acts as CE when there is no valid license.

So reactivate the original CE specs and put the licensed EE specs in
separate files.
parent fefa98c1
require 'rails_helper'
describe 'Issue Boards', feature: true, js: true do
let(:user) { create(:user) }
let(:user2) { create(:user) }
let(:project) { create(:empty_project, :public) }
let!(:milestone) { create(:milestone, project: project) }
let!(:development) { create(:label, project: project, name: 'Development') }
let!(:stretch) { create(:label, project: project, name: 'Stretch') }
let!(:issue1) { create(:labeled_issue, project: project, assignees: [user], milestone: milestone, labels: [development], relative_position: 2) }
let!(:issue2) { create(:labeled_issue, project: project, labels: [development, stretch], relative_position: 1) }
let(:board) { create(:board, project: project) }
let!(:list) { create(:list, board: board, label: development, position: 0) }
let(:card) { find('.board:nth-child(2)').first('.card') }
before do
Timecop.freeze
stub_licensed_features(multiple_issue_assignees: true)
project.team << [user, :master]
project.team.add_developer(user2)
gitlab_sign_in(user)
visit project_board_path(project, board)
wait_for_requests
end
after do
Timecop.return
end
context 'assignee' do
it 'updates the issues assignee' do
click_card(card)
page.within('.assignee') do
click_link 'Edit'
wait_for_requests
page.within('.dropdown-menu-user') do
click_link user.name
wait_for_requests
end
expect(page).to have_content(user.name)
end
expect(card).to have_selector('.avatar')
end
it 'adds multiple assignees' do
click_card(card)
page.within('.assignee') do
click_link 'Edit'
wait_for_requests
page.within('.dropdown-menu-user') do
click_link user.name
click_link user2.name
end
expect(page).to have_content(user.name)
expect(page).to have_content(user2.name)
end
expect(card.all('.avatar').length).to eq(2)
end
it 'removes the assignee' do
card_two = find('.board:nth-child(2)').find('.card:nth-child(2)')
click_card(card_two)
page.within('.assignee') do
click_link 'Edit'
wait_for_requests
page.within('.dropdown-menu-user') do
click_link 'Unassigned'
end
find('.dropdown-menu-toggle').click
wait_for_requests
expect(page).to have_content('No assignee')
end
expect(card_two).not_to have_selector('.avatar')
end
it 'assignees to current user' do
click_card(card)
page.within(find('.assignee')) do
expect(page).to have_content('No assignee')
click_button 'assign yourself'
wait_for_requests
expect(page).to have_content(user.name)
end
expect(card).to have_selector('.avatar')
end
it 'updates assignee dropdown' do
click_card(card)
page.within('.assignee') do
click_link 'Edit'
wait_for_requests
page.within('.dropdown-menu-user') do
click_link user.name
wait_for_requests
end
expect(page).to have_content(user.name)
end
page.within(find('.board:nth-child(2)')) do
find('.card:nth-child(2)').trigger('click')
end
page.within('.assignee') do
click_link 'Edit'
expect(find('.dropdown-menu')).to have_selector('.is-active')
end
end
end
def click_card(card)
page.within(card) do
first('.card-number').click
end
wait_for_sidebar
end
def wait_for_sidebar
# loop until the CSS transition is complete
Timeout.timeout(0.5) do
loop until evaluate_script('$(".right-sidebar").outerWidth()') == 290
end
end
end
......@@ -17,9 +17,9 @@ describe 'Issue Boards', feature: true, js: true do
before do
Timecop.freeze
TestLicense.destroy!
project.team << [user, :master]
project.team.add_developer(user2)
gitlab_sign_in(user)
......@@ -117,26 +117,6 @@ describe 'Issue Boards', feature: true, js: true do
expect(card).to have_selector('.avatar')
end
it 'adds multiple assignees' do
click_card(card)
page.within('.assignee') do
click_link 'Edit'
wait_for_requests
page.within('.dropdown-menu-user') do
click_link user.name
click_link user2.name
end
expect(page).to have_content(user.name)
expect(page).to have_content(user2.name)
end
expect(card.all('.avatar').length).to eq(2)
end
it 'removes the assignee' do
card_two = find('.board:nth-child(2)').find('.card:nth-child(2)')
click_card(card_two)
......@@ -150,8 +130,6 @@ describe 'Issue Boards', feature: true, js: true do
click_link 'Unassigned'
end
find('.dropdown-menu-toggle').click
wait_for_requests
expect(page).to have_content('No assignee')
......
require 'rails_helper'
describe 'New/edit issue', :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]
stub_licensed_features(multiple_issue_assignees: true)
gitlab_sign_in(user)
end
context 'new issue' do
before do
visit new_namespace_project_issue_path(project.namespace, project)
end
it 'allows user to create new issue' do
fill_in 'issue_title', with: 'title'
fill_in 'issue_description', with: 'title'
expect(find('a', text: 'Assign to me')).to be_visible
click_button 'Unassigned'
wait_for_requests
page.within '.dropdown-menu-user' do
click_link user2.name
end
expect(find('input[name="issue[assignee_ids][]"]', visible: false).value).to match(user2.id.to_s)
page.within '.js-assignee-search' do
expect(page).to have_content user2.name
end
expect(find('a', text: 'Assign to me')).to be_visible
click_link 'Assign to me'
assignee_ids = page.all('input[name="issue[assignee_ids][]"]', visible: false)
expect(assignee_ids[0].value).to match(user2.id.to_s)
expect(assignee_ids[1].value).to match(user.id.to_s)
page.within '.js-assignee-search' do
expect(page).to have_content "#{user2.name} + 1 more"
end
expect(find('a', text: 'Assign to me', visible: false)).not_to be_visible
click_button 'Milestone'
page.within '.issue-milestone' do
click_link milestone.title
end
expect(find('input[name="issue[milestone_id]"]', visible: false).value).to match(milestone.id.to_s)
page.within '.js-milestone-select' do
expect(page).to have_content milestone.title
end
click_button 'Labels'
page.within '.dropdown-menu-labels' do
click_link label.title
click_link label2.title
find('.dropdown-menu-close').click
end
page.within '.js-label-select' do
expect(page).to have_content label.title
end
expect(page.all('input[name="issue[label_ids][]"]', visible: false)[1].value).to match(label.id.to_s)
expect(page.all('input[name="issue[label_ids][]"]', visible: false)[2].value).to match(label2.id.to_s)
click_button 'Weight'
page.within '.dropdown-menu-weight' do
click_link '1'
end
click_button 'Submit issue'
page.within '.issuable-sidebar' do
page.within '.assignee' do
expect(page).to have_content "2 Assignees"
end
page.within '.milestone' do
expect(page).to have_content milestone.title
end
page.within '.labels' do
expect(page).to have_content label.title
expect(page).to have_content label2.title
end
page.within '.weight' do
expect(page).to have_content '1'
end
end
page.within '.issuable-meta' do
issue = Issue.find_by(title: 'title')
expect(page).to have_text("Issue #{issue.to_reference}")
# compare paths because the host differ in test
expect(find_link(issue.to_reference)[:href]).to end_with(issue_path(issue))
end
end
it 'correctly updates the selected user when changing assignee' do
click_button 'Unassigned'
wait_for_requests
page.within '.dropdown-menu-user' do
click_link user.name
end
expect(find('.js-assignee-search')).to have_content(user.name)
page.within '.dropdown-menu-user' do
click_link user2.name
end
expect(page.all('input[name="issue[assignee_ids][]"]', visible: false)[0].value).to match(user.id.to_s)
expect(page.all('input[name="issue[assignee_ids][]"]', visible: false)[1].value).to match(user2.id.to_s)
expect(page.all('.dropdown-menu-user a.is-active').length).to eq(2)
expect(page.all('.dropdown-menu-user a.is-active')[0].first(:xpath, '..')['data-user-id']).to eq(user.id.to_s)
expect(page.all('.dropdown-menu-user a.is-active')[1].first(:xpath, '..')['data-user-id']).to eq(user2.id.to_s)
end
end
context 'edit issue' do
before do
visit edit_namespace_project_issue_path(project.namespace, project, issue)
end
it 'allows user to update issue' do
expect(find('input[name="issue[assignee_ids][]"]', visible: false).value).to match(user.id.to_s)
expect(find('input[name="issue[milestone_id]"]', visible: false).value).to match(milestone.id.to_s)
expect(find('a', text: 'Assign to me', visible: false)).not_to be_visible
page.within '.js-user-search' do
expect(page).to have_content user.name
end
page.within '.js-milestone-select' do
expect(page).to have_content milestone.title
end
click_button 'Labels'
page.within '.dropdown-menu-labels' do
click_link label.title
click_link label2.title
end
page.within '.js-label-select' do
expect(page).to have_content label.title
end
expect(page.all('input[name="issue[label_ids][]"]', visible: false)[1].value).to match(label.id.to_s)
expect(page.all('input[name="issue[label_ids][]"]', visible: false)[2].value).to match(label2.id.to_s)
click_button 'Save changes'
page.within '.issuable-sidebar' do
page.within '.assignee' do
expect(page).to have_content user.name
end
page.within '.milestone' do
expect(page).to have_content milestone.title
end
page.within '.labels' do
expect(page).to have_content label.title
expect(page).to have_content label2.title
end
end
end
end
def before_for_selector(selector)
js = <<-JS.strip_heredoc
(function(selector) {
var el = document.querySelector(selector);
return window.getComputedStyle(el, '::before').getPropertyValue('content');
})("#{escape_javascript(selector)}")
JS
page.evaluate_script(js)
end
end
......@@ -13,6 +13,8 @@ describe 'New/edit issue', :feature, :js do
let!(:issue) { create(:issue, project: project, assignees: [user], milestone: milestone) }
before do
TestLicense.destroy!
project.team << [user, :master]
project.team << [user2, :master]
gitlab_sign_in(user)
......@@ -23,15 +25,15 @@ describe 'New/edit issue', :feature, :js do
visit new_project_issue_path(project)
end
xdescribe 'shorten users API pagination limit (CE)' do
describe 'shorten users API pagination limit (CE)' 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 = FormHelper.instance_method(:issue_dropdown_options)
allow_any_instance_of(FormHelper).to receive(:issue_dropdown_options).and_wrap_original do |original, *args|
original_issue_dropdown_options = FormHelper.instance_method(:issue_assignees_dropdown_options)
allow_any_instance_of(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
......@@ -63,7 +65,7 @@ describe 'New/edit issue', :feature, :js do
end
end
xdescribe 'single assignee (CE)' do
describe 'single assignee (CE)' do
before do
click_button 'Unassigned'
......@@ -122,11 +124,10 @@ describe 'New/edit issue', :feature, :js do
click_link 'Assign to me'
assignee_ids = page.all('input[name="issue[assignee_ids][]"]', visible: false)
expect(assignee_ids[0].value).to match(user2.id.to_s)
expect(assignee_ids[1].value).to match(user.id.to_s)
expect(assignee_ids[0].value).to match(user.id.to_s)
page.within '.js-assignee-search' do
expect(page).to have_content "#{user2.name} + 1 more"
expect(page).to have_content user.name
end
expect(find('a', text: 'Assign to me', visible: false)).not_to be_visible
......@@ -143,8 +144,6 @@ describe 'New/edit issue', :feature, :js do
page.within '.dropdown-menu-labels' do
click_link label.title
click_link label2.title
find('.dropdown-menu-close').click
end
page.within '.js-label-select' do
expect(page).to have_content label.title
......@@ -162,7 +161,7 @@ describe 'New/edit issue', :feature, :js do
page.within '.issuable-sidebar' do
page.within '.assignee' do
expect(page).to have_content "2 Assignees"
expect(page).to have_content "Assignee"
end
page.within '.milestone' do
......@@ -173,10 +172,6 @@ describe 'New/edit issue', :feature, :js do
expect(page).to have_content label.title
expect(page).to have_content label2.title
end
page.within '.weight' do
expect(page).to have_content '1'
end
end
page.within '.issuable-meta' do
......@@ -214,18 +209,13 @@ describe 'New/edit issue', :feature, :js do
end
expect(find('.js-assignee-search')).to have_content(user.name)
click_button user.name
page.within '.dropdown-menu-user' do
click_link user2.name
end
expect(page.all('input[name="issue[assignee_ids][]"]', visible: false)[0].value).to match(user.id.to_s)
expect(page.all('input[name="issue[assignee_ids][]"]', visible: false)[1].value).to match(user2.id.to_s)
expect(page.all('.dropdown-menu-user a.is-active').length).to eq(2)
expect(page.all('.dropdown-menu-user a.is-active')[0].first(:xpath, '..')['data-user-id']).to eq(user.id.to_s)
expect(page.all('.dropdown-menu-user a.is-active')[1].first(:xpath, '..')['data-user-id']).to eq(user2.id.to_s)
expect(find('.js-assignee-search')).to have_content(user2.name)
end
it 'description has autocomplete' do
......
......@@ -61,6 +61,8 @@ describe API::Issues do
before(:all) do
project.team << [user, :reporter]
project.team << [guest, :guest]
TestLicense.destroy!
end
describe "GET /issues" do
......@@ -773,6 +775,17 @@ describe API::Issues do
end
end
context 'CE restrictions' do
it 'creates a new project issue with no more than one assignee' do
post api("/projects/#{project.id}/issues", user),
title: 'new issue', assignee_ids: [user2.id, guest.id]
expect(response).to have_http_status(201)
expect(json_response['title']).to eq('new issue')
expect(json_response['assignees'].count).to eq(1)
end
end
it 'creates a new project issue' do
post api("/projects/#{project.id}/issues", user),
title: 'new issue', labels: 'label, label2', weight: 3,
......@@ -1113,6 +1126,17 @@ describe API::Issues do
expect(json_response['assignees'].first['name']).to eq(user2.name)
end
context 'CE restrictions' do
it 'updates an issue with several assignees but only one has been applied' do
put api("/projects/#{project.id}/issues/#{issue.iid}", user),
assignee_ids: [user2.id, guest.id]
expect(response).to have_http_status(200)
expect(json_response['assignees'].size).to eq(1)
end
end
end
describe 'PUT /projects/:id/issues/:issue_iid to update labels' do
......
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