Commit 3db2f327 authored by Winnie Hellmann's avatar Winnie Hellmann Committed by Rémy Coutable

Enable Capybara/FeatureMethods cop

parent baab4cdd
......@@ -10,10 +10,6 @@
Capybara/CurrentPathExpectation:
Enabled: false
# Offense count: 956
Capybara/FeatureMethods:
Enabled: false
# Offense count: 23
FactoryBot/DynamicAttributeDefinedStatically:
Exclude:
......
require 'securerandom'
module QA
feature 'API basics', :core do
describe 'API basics', :core do
before(:context) do
@api_client = Runtime::API::Client.new(:gitlab)
end
......@@ -9,7 +9,7 @@ module QA
let(:project_name) { "api-basics-#{SecureRandom.hex(8)}" }
let(:sanitized_project_path) { CGI.escape("#{Runtime::User.name}/#{project_name}") }
scenario 'user creates a project with a file and deletes them afterwards' do
it 'user creates a project with a file and deletes them afterwards' do
create_project_request = Runtime::API::Request.new(@api_client, '/projects')
post create_project_request.url, path: project_name, name: project_name
......
module QA
feature 'API users', :core do
describe 'API users', :core do
before(:context) do
@api_client = Runtime::API::Client.new(:gitlab)
end
......@@ -7,13 +7,13 @@ module QA
context 'when authenticated' do
let(:request) { Runtime::API::Request.new(@api_client, '/users') }
scenario 'get list of users' do
it 'get list of users' do
get request.url
expect_status(200)
end
scenario 'submit request with a valid user name' do
it 'submit request with a valid user name' do
get request.url, { params: { username: Runtime::User.name } }
expect_status(200)
......@@ -22,7 +22,7 @@ module QA
)
end
scenario 'submit request with an invalid user name' do
it 'submit request with an invalid user name' do
get request.url, { params: { username: SecureRandom.hex(10) } }
expect_status(200)
......@@ -30,7 +30,7 @@ module QA
end
end
scenario 'submit request with an invalid token' do
it 'submit request with an invalid token' do
request = Runtime::API::Request.new(@api_client, '/users', private_token: 'invalid')
get request.url
......
module QA
feature 'LDAP user login', :ldap do
describe 'LDAP user login', :ldap do
before do
Runtime::Env.user_type = 'ldap'
end
scenario 'user logs in using LDAP credentials' do
it 'user logs in using LDAP credentials' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
......
module QA
feature 'standard user login', :core do
scenario 'user logs in using credentials' do
describe 'standard user login', :core do
it 'user logs in using credentials' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
......
module QA
feature 'create a new group', :mattermost do
scenario 'creating a group with a mattermost team' do
describe 'create a new group', :mattermost do
it 'creating a group with a mattermost team' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
Page::Menu::Main.act { go_to_groups }
......
module QA
feature 'logging in to Mattermost', :mattermost do
scenario 'can use gitlab oauth' do
describe 'logging in to Mattermost', :mattermost do
it 'can use gitlab oauth' do
Runtime::Browser.visit(:gitlab, Page::Main::Login) do
Page::Main::Login.act { sign_in_using_credentials }
......
module QA
feature 'creates a merge request', :core do
scenario 'user creates a new merge request' do
describe 'creates a merge request', :core do
it 'user creates a new merge request' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
......
module QA
feature 'merge request rebase', :core do
scenario 'rebases source branch of merge request' do
describe 'merge request rebase', :core do
it 'rebases source branch of merge request' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
......
module QA
feature 'merge request squash commits', :core do
scenario 'when squash commits is marked before merge' do
describe 'merge request squash commits', :core do
it 'when squash commits is marked before merge' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
......
module QA
feature 'activity page', :core do
scenario 'push creates an event in the activity page' do
describe 'activity page', :core do
it 'push creates an event in the activity page' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
......
module QA
feature 'deploy keys support', :core do
scenario 'user adds a deploy key' do
describe 'deploy keys support', :core do
it 'user adds a deploy key' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
......
module QA
feature 'secret variables support', :core do
scenario 'user adds a secret variable' do
describe 'secret variables support', :core do
it 'user adds a secret variable' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
......
require 'pathname'
module QA
feature 'Auto Devops', :kubernetes do
describe 'Auto Devops', :kubernetes do
after do
@cluster&.remove!
end
scenario 'user creates a new project and runs auto devops' do
it 'user creates a new project and runs auto devops' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
......
module QA
feature 'creates issue', :core do
describe 'creates issue', :core do
let(:issue_title) { 'issue title' }
scenario 'user creates issue' do
it 'user creates issue' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
......
module QA
feature 'create a new project', :core do
scenario 'user creates a new project' do
describe 'create a new project', :core do
it 'user creates a new project' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
......
require 'digest/sha1'
module QA
feature 'cloning code using a deploy key', :core, :docker do
describe 'cloning code using a deploy key', :core, :docker do
def login
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
......@@ -39,7 +39,7 @@ module QA
]
keys.each do |(key_class, bits)|
scenario "user sets up a deploy key with #{key_class}(#{bits}) to clone code using pipelines" do
it "user sets up a deploy key with #{key_class}(#{bits}) to clone code using pipelines" do
key = key_class.new(*bits)
login
......
module QA
feature 'CI/CD Pipelines', :core, :docker do
describe 'CI/CD Pipelines', :core, :docker do
let(:executor) { "qa-runner-#{Time.now.to_i}" }
after do
Service::Runner.new(executor).remove!
end
scenario 'user registers a new specific runner' do
it 'user registers a new specific runner' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
......@@ -25,7 +25,7 @@ module QA
end
end
scenario 'users creates a new pipeline' do
it 'users creates a new pipeline' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
......
module QA
feature 'Wiki Functionality', :core do
describe 'Wiki Functionality', :core do
def login
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
......@@ -14,7 +14,7 @@ module QA
login
end
scenario 'User creates, edits, clones, and pushes to the wiki' do
it 'User creates, edits, clones, and pushes to the wiki' do
wiki = Factory::Resource::Wiki.fabricate! do |resource|
resource.title = 'Home'
resource.content = '# My First Wiki Content'
......
module QA
feature 'clone code from the repository', :core do
describe 'clone code from the repository', :core do
context 'with regular account over http' do
given(:location) do
let(:location) do
Page::Project::Show.act do
choose_repository_clone_http
repository_location
......@@ -31,7 +31,7 @@ module QA
end
end
scenario 'user performs a deep clone' do
it 'user performs a deep clone' do
Git::Repository.perform do |repository|
repository.uri = location.uri
repository.use_default_credentials
......@@ -42,7 +42,7 @@ module QA
end
end
scenario 'user performs a shallow clone' do
it 'user performs a shallow clone' do
Git::Repository.perform do |repository|
repository.uri = location.uri
repository.use_default_credentials
......
module QA
feature 'branch protection support', :core do
given(:branch_name) { 'protected-branch' }
given(:commit_message) { 'Protected push commit message' }
given(:project) do
describe 'branch protection support', :core do
let(:branch_name) { 'protected-branch' }
let(:commit_message) { 'Protected push commit message' }
let(:project) do
Factory::Resource::Project.fabricate! do |resource|
resource.name = 'protected-branch-project'
end
......@@ -27,7 +27,7 @@ module QA
context 'when developers and maintainers are allowed to push to a protected branch' do
let!(:protected_branch) { create_protected_branch(allow_to_push: true) }
scenario 'user with push rights successfully pushes to the protected branch' do
it 'user with push rights successfully pushes to the protected branch' do
expect(protected_branch.name).to have_content(branch_name)
expect(protected_branch.push_allowance).to have_content('Developers + Maintainers')
......@@ -38,7 +38,7 @@ module QA
end
context 'when developers and maintainers are not allowed to push to a protected branch' do
scenario 'user without push rights fails to push to the protected branch' do
it 'user without push rights fails to push to the protected branch' do
create_protected_branch(allow_to_push: false)
@push = push_new_file(branch_name)
......
module QA
feature 'push code to repository', :core do
describe 'push code to repository', :core do
context 'with regular account over http' do
scenario 'user pushes code to the repository' do
it 'user pushes code to the repository' do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
......
require 'spec_helper'
feature 'Abuse reports' do
describe 'Abuse reports' do
let(:another_user) { create(:user) }
before do
sign_in(create(:user))
end
scenario 'Report abuse' do
it 'Report abuse' do
visit user_path(another_user)
click_link 'Report abuse'
......
require 'spec_helper'
feature 'Admin Appearance' do
describe 'Admin Appearance' do
let!(:appearance) { create(:appearance) }
scenario 'Create new appearance' do
it 'Create new appearance' do
sign_in(create(:admin))
visit admin_appearances_path
......@@ -21,7 +21,7 @@ feature 'Admin Appearance' do
expect(page).to have_content 'Last edit'
end
scenario 'Preview sign-in page appearance' do
it 'Preview sign-in page appearance' do
sign_in(create(:admin))
visit admin_appearances_path
......@@ -30,7 +30,7 @@ feature 'Admin Appearance' do
expect_custom_sign_in_appearance(appearance)
end
scenario 'Preview new project page appearance' do
it 'Preview new project page appearance' do
sign_in(create(:admin))
visit admin_appearances_path
......@@ -39,20 +39,20 @@ feature 'Admin Appearance' do
expect_custom_new_project_appearance(appearance)
end
scenario 'Custom sign-in page' do
it 'Custom sign-in page' do
visit new_user_session_path
expect_custom_sign_in_appearance(appearance)
end
scenario 'Custom new project page' do
it 'Custom new project page' do
sign_in create(:user)
visit new_project_path
expect_custom_new_project_appearance(appearance)
end
scenario 'Appearance logo' do
it 'Appearance logo' do
sign_in(create(:admin))
visit admin_appearances_path
......@@ -64,7 +64,7 @@ feature 'Admin Appearance' do
expect(page).not_to have_css(logo_selector)
end
scenario 'Header logos' do
it 'Header logos' do
sign_in(create(:admin))
visit admin_appearances_path
......@@ -76,7 +76,7 @@ feature 'Admin Appearance' do
expect(page).not_to have_css(header_logo_selector)
end
scenario 'Favicon' do
it 'Favicon' do
sign_in(create(:admin))
visit admin_appearances_path
......
require 'spec_helper'
feature 'Admin Broadcast Messages' do
describe 'Admin Broadcast Messages' do
before do
sign_in(create(:admin))
create(:broadcast_message, :expired, message: 'Migration to new server')
visit admin_broadcast_messages_path
end
scenario 'See broadcast messages list' do
it 'See broadcast messages list' do
expect(page).to have_content 'Migration to new server'
end
scenario 'Create a customized broadcast message' do
it 'Create a customized broadcast message' do
fill_in 'broadcast_message_message', with: 'Application update from **4:00 CST to 5:00 CST**'
fill_in 'broadcast_message_color', with: '#f2dede'
fill_in 'broadcast_message_font', with: '#b94a48'
......@@ -24,7 +24,7 @@ feature 'Admin Broadcast Messages' do
expect(page).to have_selector %(div[style="background-color: #f2dede; color: #b94a48"])
end
scenario 'Edit an existing broadcast message' do
it 'Edit an existing broadcast message' do
click_link 'Edit'
fill_in 'broadcast_message_message', with: 'Application update RIGHT NOW'
click_button 'Update broadcast message'
......@@ -33,14 +33,14 @@ feature 'Admin Broadcast Messages' do
expect(page).to have_content 'Application update RIGHT NOW'
end
scenario 'Remove an existing broadcast message' do
it 'Remove an existing broadcast message' do
click_link 'Remove'
expect(current_path).to eq admin_broadcast_messages_path
expect(page).not_to have_content 'Migration to new server'
end
scenario 'Live preview a customized broadcast message', :js do
it 'Live preview a customized broadcast message', :js do
fill_in 'broadcast_message_message', with: "Live **Markdown** previews. :tada:"
page.within('.broadcast-message-preview') do
......
......@@ -7,7 +7,7 @@ describe 'Admin browse spam logs' do
sign_in(create(:admin))
end
scenario 'Browse spam logs' do
it 'Browse spam logs' do
visit admin_spam_logs_path
expect(page).to have_content('Spam Logs')
......
require 'rails_helper'
feature 'Admin cohorts page' do
describe 'Admin cohorts page' do
before do
sign_in(create(:admin))
end
scenario 'See users count per month' do
it 'See users count per month' do
2.times { create(:user) }
visit admin_cohorts_path
......
require 'rails_helper'
feature 'Admin disables Git access protocol' do
describe 'Admin disables Git access protocol' do
include StubENV
let(:project) { create(:project, :empty_repo) }
let(:admin) { create(:admin) }
background do
before do
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
sign_in(admin)
end
context 'with HTTP disabled' do
background do
before do
disable_http_protocol
end
scenario 'shows only SSH url' do
it 'shows only SSH url' do
visit_project
expect(page).to have_content("git clone #{project.ssh_url_to_repo}")
......@@ -25,11 +25,11 @@ feature 'Admin disables Git access protocol' do
end
context 'with SSH disabled' do
background do
before do
disable_ssh_protocol
end
scenario 'shows only HTTP url' do
it 'shows only HTTP url' do
visit_project
expect(page).to have_content("git clone #{project.http_url_to_repo}")
......@@ -38,11 +38,11 @@ feature 'Admin disables Git access protocol' do
end
context 'with nothing disabled' do
background do
before do
create(:personal_key, user: admin)
end
scenario 'shows default SSH url and protocol selection dropdown' do
it 'shows default SSH url and protocol selection dropdown' do
visit_project
expect(page).to have_content("git clone #{project.ssh_url_to_repo}")
......
require 'rails_helper'
feature 'Admin disables 2FA for a user' do
scenario 'successfully', :js do
describe 'Admin disables 2FA for a user' do
it 'successfully', :js do
sign_in(create(:admin))
user = create(:user, :two_factor)
......@@ -16,7 +16,7 @@ feature 'Admin disables 2FA for a user' do
end
end
scenario 'for a user without 2FA enabled' do
it 'for a user without 2FA enabled' do
sign_in(create(:admin))
user = create(:user)
......
require 'spec_helper'
feature 'Admin Groups' do
describe 'Admin Groups' do
include Select2Helper
let(:internal) { Gitlab::VisibilityLevel::INTERNAL }
......@@ -47,13 +47,13 @@ feature 'Admin Groups' do
expect(li_texts).to match group_description
end
scenario 'shows the visibility level radio populated with the default value' do
it 'shows the visibility level radio populated with the default value' do
visit new_admin_group_path
expect_selected_visibility(internal)
end
scenario 'when entered in group path, it auto filled the group name', :js do
it 'when entered in group path, it auto filled the group name', :js do
visit admin_groups_path
click_link "New group"
group_path = 'gitlab'
......@@ -64,7 +64,7 @@ feature 'Admin Groups' do
end
describe 'show a group' do
scenario 'shows the group' do
it 'shows the group' do
group = create(:group, :private)
visit admin_group_path(group)
......@@ -74,7 +74,7 @@ feature 'Admin Groups' do
end
describe 'group edit' do
scenario 'shows the visibility level radio populated with the group visibility_level value' do
it 'shows the visibility level radio populated with the group visibility_level value' do
group = create(:group, :private)
visit admin_group_edit_path(group)
......@@ -82,7 +82,7 @@ feature 'Admin Groups' do
expect_selected_visibility(group.visibility_level)
end
scenario 'edit group path does not change group name', :js do
it 'edit group path does not change group name', :js do
group = create(:group, :private)
visit admin_group_edit_path(group)
......
require 'spec_helper'
feature "Admin Health Check", :feature do
describe "Admin Health Check", :feature do
include StubENV
before do
......
require 'spec_helper'
feature 'Admin::HookLogs' do
describe 'Admin::HookLogs' do
let(:project) { create(:project) }
let(:system_hook) { create(:system_hook) }