Commit da361162 authored by Erick Banks's avatar Erick Banks Committed by Dan Davison

Initial refactor in test audit

Changed a couple tests to adhere to best practices like using
`let` and `before` block.
parent 2ff70c48
......@@ -5,11 +5,8 @@ require 'airborne'
module QA
RSpec.describe 'Manage' do
describe 'Users API' do
before(:context) do
@api_client = Runtime::API::Client.new(:gitlab)
end
let(:request) { Runtime::API::Request.new(@api_client, '/users') }
let(:api_client) { Runtime::API::Client.new(:gitlab) }
let(:request) { Runtime::API::Request.new(api_client, '/users') }
it 'GET /users' do
get request.url
......
......@@ -8,30 +8,33 @@ module QA
RSpec.describe 'Create' do
describe 'Compare archives of different user projects with the same name and check they\'re different' do
include Support::Api
let(:project_name) { "project-archive-download-#{SecureRandom.hex(8)}" }
before do
@project_name = "project-archive-download-#{SecureRandom.hex(8)}"
@archive_types = %w(tar.gz tar.bz2 tar zip)
@users = {
let(:archive_types) { %w(tar.gz tar.bz2 tar zip) }
let(:users) do
{
user1: { username: Runtime::Env.gitlab_qa_username_1, password: Runtime::Env.gitlab_qa_password_1 },
user2: { username: Runtime::Env.gitlab_qa_username_2, password: Runtime::Env.gitlab_qa_password_2 }
}
end
@users.each do |_, user_info|
before do
users.each do |_, user_info|
user_info[:user] = Resource::User.fabricate_or_use(user_info[:username], user_info[:password])
user_info[:api_client] = Runtime::API::Client.new(:gitlab, user: user_info[:user])
user_info[:api_client].personal_access_token
user_info[:project] = create_project(user_info[:user], user_info[:api_client], @project_name)
user_info[:project] = create_project(user_info[:user], user_info[:api_client], project_name)
end
end
it 'download archives of each user project then check they are different' do
archive_checksums = {}
@users.each do |user_key, user_info|
users.each do |user_key, user_info|
archive_checksums[user_key] = {}
@archive_types.each do |type|
archive_types.each do |type|
archive_path = download_project_archive_via_api(user_info[:api_client], user_info[:project], type).path
archive_checksums[user_key][type] = Digest::MD5.hexdigest(File.read(archive_path))
end
......
......@@ -3,22 +3,30 @@
module QA
RSpec.describe 'Manage' do
describe 'Project transfer between groups' do
it 'user transfers a project between groups' do
Flow::Login.sign_in
source_group = Resource::Group.fabricate_via_api! do |group|
let(:source_group) do
Resource::Group.fabricate_via_api! do |group|
group.path = 'source-group'
end
end
target_group = Resource::Group.fabricate_via_api! do |group|
let(:target_group) do
Resource::Group.fabricate_via_api! do |group|
group.path = 'target-group'
end
end
project = Resource::Project.fabricate_via_api! do |project|
let(:project) do
Resource::Project.fabricate_via_api! do |project|
project.group = source_group
project.name = 'transfer-project'
project.initialize_with_readme = true
end
end
let(:edited_readme_content) { 'Here is the edited content.' }
before do
Flow::Login.sign_in
project.visit!
......@@ -28,14 +36,14 @@ module QA
Page::File::Show.perform(&:click_edit)
edited_readme_content = 'Here is the edited content.'
Page::File::Edit.perform do |file|
file.remove_content
file.add_content(edited_readme_content)
file.commit_changes
end
end
it 'user transfers a project between groups' do
Page::File::Show.perform(&:go_to_general_settings)
Page::Project::Settings::Main.perform(&:expand_advanced_settings)
......
......@@ -3,27 +3,29 @@
module QA
RSpec.describe 'Create' do
describe 'Create a new merge request' do
before do
Flow::Login.sign_in
@project = Resource::Project.fabricate_via_api! do |project|
let(:project) do
Resource::Project.fabricate_via_api! do |project|
project.name = 'project'
end
end
@merge_request_title = 'One merge request to rule them all'
@merge_request_description = '... to find them, to bring them all, and in the darkness bind them'
let(:merge_request_title) { 'One merge request to rule them all' }
let(:merge_request_description) { '... to find them, to bring them all, and in the darkness bind them' }
before do
Flow::Login.sign_in
end
it 'creates a basic merge request' do
Resource::MergeRequest.fabricate_via_browser_ui! do |merge_request|
merge_request.project = @project
merge_request.title = @merge_request_title
merge_request.description = @merge_request_description
merge_request.project = project
merge_request.title = merge_request_title
merge_request.description = merge_request_description
end
Page::MergeRequest::Show.perform do |merge_request|
expect(merge_request).to have_title(@merge_request_title)
expect(merge_request).to have_description(@merge_request_description)
expect(merge_request).to have_title(merge_request_title)
expect(merge_request).to have_description(merge_request_description)
end
end
......@@ -31,26 +33,26 @@ module QA
gitlab_account_username = "@#{Runtime::User.username}"
milestone = Resource::ProjectMilestone.fabricate_via_api! do |milestone|
milestone.project = @project
milestone.project = project
end
label = Resource::Label.fabricate_via_api! do |label|
label.project = @project
label.project = project
label.title = 'label'
end
Resource::MergeRequest.fabricate_via_browser_ui! do |merge_request|
merge_request.title = @merge_request_title
merge_request.description = @merge_request_description
merge_request.project = @project
merge_request.title = merge_request_title
merge_request.description = merge_request_description
merge_request.project = project
merge_request.milestone = milestone
merge_request.assignee = 'me'
merge_request.labels.push(label)
end
Page::MergeRequest::Show.perform do |merge_request|
expect(merge_request).to have_title(@merge_request_title)
expect(merge_request).to have_description(@merge_request_description)
expect(merge_request).to have_title(merge_request_title)
expect(merge_request).to have_description(merge_request_description)
expect(merge_request).to have_assignee(gitlab_account_username)
expect(merge_request).to have_label(label.title)
expect(merge_request).to have_milestone(milestone.title)
......
......@@ -3,17 +3,14 @@
module QA
RSpec.describe 'Create' do
describe 'Merge request creation from fork' do
it 'user forks a project, submits a merge request and maintainer merges it' do
Flow::Login.sign_in
merge_request = Resource::MergeRequestFromFork.fabricate_via_browser_ui! do |merge_request|
let(:merge_request) do
Resource::MergeRequestFromFork.fabricate_via_api! do |merge_request|
merge_request.fork_branch = 'feature-branch'
end
end
merge_request.project.api_put(auto_devops_enabled: false)
Page::Main::Menu.perform(&:sign_out)
Page::Main::Login.perform(&:sign_in_using_credentials)
it 'can merge feature branch fork to mainline' do
Flow::Login.sign_in
merge_request.visit!
......
......@@ -3,17 +3,21 @@
module QA
RSpec.describe 'Create' do
describe 'Merge request squashing' do
it 'user squashes commits while merging' do
Flow::Login.sign_in
project = Resource::Project.fabricate_via_api! do |project|
let(:project) do
Resource::Project.fabricate_via_api! do |project|
project.name = "squash-before-merge"
end
end
merge_request = Resource::MergeRequest.fabricate! do |merge_request|
let(:merge_request) do
Resource::MergeRequest.fabricate_via_api! do |merge_request|
merge_request.project = project
merge_request.title = 'Squashing commits'
end
end
before do
Flow::Login.sign_in
Resource::Repository::ProjectPush.fabricate! do |push|
push.project = project
......@@ -25,7 +29,9 @@ module QA
end
merge_request.visit!
end
it 'user squashes commits while merging' do
Page::MergeRequest::Show.perform do |merge_request_page|
merge_request_page.retry_on_exception(reload: true) do
expect(merge_request_page).to have_text('to be squashed')
......
......@@ -5,8 +5,8 @@ module QA
describe 'File templates' do
include Runtime::Fixtures
before(:all) do
@project = Resource::Project.fabricate_via_api! do |project|
let(:project) do
Resource::Project.fabricate_via_api! do |project|
project.name = 'file-template-project'
project.description = 'Add file templates via the Files view'
project.initialize_with_readme = true
......@@ -46,7 +46,7 @@ module QA
Flow::Login.sign_in
@project.visit!
project.visit!
Page::Project::Show.perform(&:create_new_file!)
Page::File::Form.perform do |form|
......
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