2017-06-07 16:11:43 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
describe 'Top Plus Menu', :js do
|
2017-07-21 17:07:59 -04:00
|
|
|
let(:user) { create(:user) }
|
2017-06-07 17:59:25 -04:00
|
|
|
let(:group) { create(:group) }
|
|
|
|
let(:project) { create(:project, :repository, creator: user, namespace: user.namespace) }
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:public_project) { create(:project, :public) }
|
2017-06-07 16:11:43 -04:00
|
|
|
|
|
|
|
before do
|
|
|
|
group.add_owner(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'used by full user' do
|
|
|
|
before do
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(user)
|
2017-06-07 16:11:43 -04:00
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'click on New project shows new project page' do
|
2017-06-07 16:11:43 -04:00
|
|
|
visit root_dashboard_path
|
|
|
|
|
|
|
|
click_topmenuitem("New project")
|
|
|
|
|
2018-09-08 02:03:00 -04:00
|
|
|
expect(page).to have_content('Project URL')
|
2017-06-07 16:11:43 -04:00
|
|
|
expect(page).to have_content('Project name')
|
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'click on New group shows new group page' do
|
2017-06-07 16:11:43 -04:00
|
|
|
visit root_dashboard_path
|
|
|
|
|
|
|
|
click_topmenuitem("New group")
|
|
|
|
|
|
|
|
expect(page).to have_content('Group path')
|
|
|
|
expect(page).to have_content('Group name')
|
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'click on New snippet shows new snippet page' do
|
2017-06-07 16:11:43 -04:00
|
|
|
visit root_dashboard_path
|
2017-07-21 17:07:59 -04:00
|
|
|
|
2017-06-07 16:11:43 -04:00
|
|
|
click_topmenuitem("New snippet")
|
|
|
|
|
|
|
|
expect(page).to have_content('New Snippet')
|
|
|
|
expect(page).to have_content('Title')
|
|
|
|
end
|
2017-06-07 16:49:22 -04:00
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'click on New issue shows new issue page' do
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_path(project)
|
2017-06-07 16:49:22 -04:00
|
|
|
|
|
|
|
click_topmenuitem("New issue")
|
|
|
|
|
|
|
|
expect(page).to have_content('New Issue')
|
|
|
|
expect(page).to have_content('Title')
|
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'click on New merge request shows new merge request page' do
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_path(project)
|
2017-06-07 16:49:22 -04:00
|
|
|
|
|
|
|
click_topmenuitem("New merge request")
|
|
|
|
|
|
|
|
expect(page).to have_content('New Merge Request')
|
|
|
|
expect(page).to have_content('Source branch')
|
|
|
|
expect(page).to have_content('Target branch')
|
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'click on New project snippet shows new snippet page' do
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_path(project)
|
2017-06-07 16:49:22 -04:00
|
|
|
|
|
|
|
page.within '.header-content' do
|
2017-06-17 02:08:27 -04:00
|
|
|
find('.header-new-dropdown-toggle').click
|
2018-04-20 14:15:09 -04:00
|
|
|
expect(page).to have_selector('.header-new.dropdown.show', count: 1)
|
2017-06-17 02:08:27 -04:00
|
|
|
find('.header-new-project-snippet a').click
|
2017-06-07 16:49:22 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).to have_content('New Snippet')
|
|
|
|
expect(page).to have_content('Title')
|
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'Click on New subgroup shows new group page', :nested_groups do
|
2017-06-07 16:49:22 -04:00
|
|
|
visit group_path(group)
|
|
|
|
|
|
|
|
click_topmenuitem("New subgroup")
|
|
|
|
|
|
|
|
expect(page).to have_content('Group path')
|
|
|
|
expect(page).to have_content('Group name')
|
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'Click on New project in group shows new project page' do
|
2017-06-07 16:49:22 -04:00
|
|
|
visit group_path(group)
|
|
|
|
|
|
|
|
page.within '.header-content' do
|
2017-06-17 02:08:27 -04:00
|
|
|
find('.header-new-dropdown-toggle').click
|
2018-04-20 14:15:09 -04:00
|
|
|
expect(page).to have_selector('.header-new.dropdown.show', count: 1)
|
2017-06-17 02:08:27 -04:00
|
|
|
find('.header-new-group-project a').click
|
2017-06-07 16:49:22 -04:00
|
|
|
end
|
|
|
|
|
2018-09-08 02:03:00 -04:00
|
|
|
expect(page).to have_content('Project URL')
|
2017-06-07 16:49:22 -04:00
|
|
|
expect(page).to have_content('Project name')
|
|
|
|
end
|
2017-06-07 16:11:43 -04:00
|
|
|
end
|
|
|
|
|
2017-06-07 17:59:25 -04:00
|
|
|
context 'used by guest user' do
|
2017-07-21 17:07:59 -04:00
|
|
|
let(:guest_user) { create(:user) }
|
|
|
|
|
2017-06-07 17:59:25 -04:00
|
|
|
before do
|
2017-07-21 17:07:59 -04:00
|
|
|
group.add_guest(guest_user)
|
|
|
|
project.add_guest(guest_user)
|
|
|
|
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(guest_user)
|
2017-06-07 17:59:25 -04:00
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'click on New issue shows new issue page' do
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_path(project)
|
2017-06-07 17:59:25 -04:00
|
|
|
|
|
|
|
click_topmenuitem("New issue")
|
|
|
|
|
|
|
|
expect(page).to have_content('New Issue')
|
|
|
|
expect(page).to have_content('Title')
|
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'has no New merge request menu item' do
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_path(project)
|
2017-06-07 17:59:25 -04:00
|
|
|
|
|
|
|
hasnot_topmenuitem("New merge request")
|
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'has no New project snippet menu item' do
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_path(project)
|
2017-06-07 17:59:25 -04:00
|
|
|
|
|
|
|
expect(find('.header-new.dropdown')).not_to have_selector('.header-new-project-snippet')
|
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'public project has no New merge request menu item' do
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_path(public_project)
|
2017-06-07 18:37:45 -04:00
|
|
|
|
|
|
|
hasnot_topmenuitem("New merge request")
|
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'public project has no New project snippet menu item' do
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_path(public_project)
|
2017-06-07 18:37:45 -04:00
|
|
|
|
|
|
|
expect(find('.header-new.dropdown')).not_to have_selector('.header-new-project-snippet')
|
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'has no New subgroup menu item' do
|
2017-06-07 17:59:25 -04:00
|
|
|
visit group_path(group)
|
|
|
|
|
|
|
|
hasnot_topmenuitem("New subgroup")
|
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'has no New project for group menu item' do
|
2017-06-07 17:59:25 -04:00
|
|
|
visit group_path(group)
|
2017-07-21 17:07:59 -04:00
|
|
|
|
2017-06-07 17:59:25 -04:00
|
|
|
expect(find('.header-new.dropdown')).not_to have_selector('.header-new-group-project')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-06-07 16:11:43 -04:00
|
|
|
def click_topmenuitem(item_name)
|
|
|
|
page.within '.header-content' do
|
2017-06-17 02:08:27 -04:00
|
|
|
find('.header-new-dropdown-toggle').click
|
2018-04-20 14:15:09 -04:00
|
|
|
expect(page).to have_selector('.header-new.dropdown.show', count: 1)
|
2017-06-07 16:11:43 -04:00
|
|
|
click_link item_name
|
|
|
|
end
|
|
|
|
end
|
2017-06-07 17:59:25 -04:00
|
|
|
|
|
|
|
def hasnot_topmenuitem(item_name)
|
2017-06-07 18:02:31 -04:00
|
|
|
expect(find('.header-new.dropdown')).not_to have_content(item_name)
|
2017-07-21 17:07:59 -04:00
|
|
|
end
|
2017-06-07 16:11:43 -04:00
|
|
|
end
|