2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
RSpec.describe 'Projects > Show > Collaboration links', :js do
|
2020-03-13 15:44:24 +05:30
|
|
|
using RSpec::Parameterized::TableSyntax
|
|
|
|
|
|
|
|
let(:project) { create(:project, :repository, :public) }
|
2018-05-09 12:01:36 +05:30
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
end
|
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
def find_new_menu_toggle
|
|
|
|
find('#js-onboarding-new-project-link')
|
|
|
|
end
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
context 'with developer user' do
|
|
|
|
before do
|
|
|
|
project.add_developer(user)
|
|
|
|
end
|
2018-05-09 12:01:36 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
it 'shows all the expected links' do
|
|
|
|
visit project_path(project)
|
2019-12-26 22:10:19 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
# The navigation bar
|
|
|
|
page.within('.header-new') do
|
2021-09-04 01:27:46 +05:30
|
|
|
find_new_menu_toggle.click
|
2019-12-26 22:10:19 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
aggregate_failures 'dropdown links in the navigation bar' do
|
|
|
|
expect(page).to have_link('New issue')
|
|
|
|
expect(page).to have_link('New merge request')
|
|
|
|
expect(page).to have_link('New snippet', href: new_project_snippet_path(project))
|
|
|
|
end
|
2018-05-09 12:01:36 +05:30
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
find_new_menu_toggle.click
|
2020-03-13 15:44:24 +05:30
|
|
|
end
|
2019-12-26 22:10:19 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
# The dropdown above the tree
|
|
|
|
page.within('.repo-breadcrumb') do
|
|
|
|
find('.qa-add-to-tree').click
|
|
|
|
|
|
|
|
aggregate_failures 'dropdown links above the repo tree' do
|
|
|
|
expect(page).to have_link('New file')
|
|
|
|
expect(page).to have_link('Upload file')
|
|
|
|
expect(page).to have_link('New directory')
|
|
|
|
expect(page).to have_link('New branch')
|
|
|
|
expect(page).to have_link('New tag')
|
|
|
|
end
|
2018-05-09 12:01:36 +05:30
|
|
|
end
|
2020-03-13 15:44:24 +05:30
|
|
|
|
|
|
|
# The Web IDE
|
|
|
|
expect(page).to have_link('Web IDE')
|
2018-05-09 12:01:36 +05:30
|
|
|
end
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
it 'hides the links when the project is archived' do
|
|
|
|
project.update!(archived: true)
|
2018-05-09 12:01:36 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
visit project_path(project)
|
2018-05-09 12:01:36 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
page.within('.header-new') do
|
2021-09-04 01:27:46 +05:30
|
|
|
find_new_menu_toggle.click
|
2018-05-09 12:01:36 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
aggregate_failures 'dropdown links' do
|
|
|
|
expect(page).not_to have_link('New issue')
|
|
|
|
expect(page).not_to have_link('New merge request')
|
|
|
|
expect(page).not_to have_link('New snippet', href: new_project_snippet_path(project))
|
|
|
|
end
|
2019-12-26 22:10:19 +05:30
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
find_new_menu_toggle.click
|
2018-05-09 12:01:36 +05:30
|
|
|
end
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
expect(page).not_to have_selector('.qa-add-to-tree')
|
|
|
|
|
|
|
|
expect(page).not_to have_link('Web IDE')
|
2018-05-09 12:01:36 +05:30
|
|
|
end
|
2020-03-13 15:44:24 +05:30
|
|
|
end
|
2018-05-09 12:01:36 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
context "Web IDE link" do
|
|
|
|
where(:merge_requests_access_level, :user_level, :expect_ide_link) do
|
|
|
|
::ProjectFeature::DISABLED | :guest | false
|
|
|
|
::ProjectFeature::DISABLED | :developer | true
|
|
|
|
::ProjectFeature::PRIVATE | :guest | false
|
|
|
|
::ProjectFeature::PRIVATE | :developer | true
|
|
|
|
::ProjectFeature::ENABLED | :guest | true
|
|
|
|
::ProjectFeature::ENABLED | :developer | true
|
|
|
|
end
|
2019-12-26 22:10:19 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
with_them do
|
|
|
|
before do
|
|
|
|
project.project_feature.update!({ merge_requests_access_level: merge_requests_access_level })
|
|
|
|
project.add_user(user, user_level)
|
|
|
|
visit project_path(project)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "updates Web IDE link" do
|
|
|
|
expect(page.has_link?('Web IDE')).to be(expect_ide_link)
|
|
|
|
end
|
|
|
|
end
|
2018-05-09 12:01:36 +05:30
|
|
|
end
|
|
|
|
end
|