Commit 5c5270ae authored by Tiffany Rea's avatar Tiffany Rea Committed by Sanad Liaquat

Fix file commit error for system cancels merge train spec

parent 3611732d
......@@ -5,7 +5,7 @@ require 'faker'
module QA
RSpec.describe 'Verify' do
describe 'Merge train', :runner, :requires_admin do
let(:file_name) { 'custom_file.txt' }
let(:file_name) { Faker::Lorem.word }
let(:mr_title) { Faker::Lorem.sentence }
let(:executor) { "qa-runner-#{Faker::Alphanumeric.alphanumeric(8)}" }
......@@ -23,25 +23,29 @@ module QA
end
end
let!(:ci_file) do
let!(:original_files) do
Resource::Repository::Commit.fabricate_via_api! do |commit|
commit.project = project
commit.commit_message = 'Add .gitlab-ci.yml'
commit.add_files(
[
{
file_path: '.gitlab-ci.yml',
content: <<~YAML
test_merge_train:
tags:
- #{executor}
script:
- sleep 3
- echo 'OK!'
only:
- merge_requests
YAML
}
{
file_path: '.gitlab-ci.yml',
content: <<~YAML
test_merge_train:
tags:
- #{executor}
script:
- sleep 3
- echo 'OK!'
only:
- merge_requests
YAML
},
{
file_path: file_name,
content: Faker::Lorem.sentence
}
]
)
end
......@@ -56,8 +60,15 @@ module QA
let(:user_api_client) { Runtime::API::Client.new(:gitlab, user: user) }
let(:admin_api_client) { Runtime::API::Client.as_admin }
let(:merge_request) do
Resource::MergeRequest.fabricate_via_api! do |merge_request|
before do
Runtime::Feature.enable(:invite_members_group_modal, project: project)
Flow::Login.sign_in
project.visit!
Flow::MergeRequest.enable_merge_trains
project.add_member(user, Resource::Members::AccessLevel::MAINTAINER)
merge_request = Resource::MergeRequest.fabricate_via_api! do |merge_request|
merge_request.api_client = user_api_client
merge_request.title = mr_title
merge_request.project = project
......@@ -66,30 +77,20 @@ module QA
merge_request.file_name = file_name
merge_request.file_content = Faker::Lorem.sentence
end
end
before do
Runtime::Feature.enable(:invite_members_group_modal, project: project)
Flow::Login.sign_in
project.visit!
Flow::MergeRequest.enable_merge_trains
project.add_member(user, Resource::Members::AccessLevel::MAINTAINER)
create_user_personal_access_token
Flow::Login.sign_in(as: user)
merge_request.visit!
Page::MergeRequest::Show.perform do |show|
show.has_pipeline_status?('passed')
show.try_to_merge!
show.wait_until(reload: false) { show.has_content? 'started a merge train' }
end
end
after do
runner.remove_via_api!
user.remove_via_api!
project.remove_via_api!
end
context 'when system cancels a merge request' do
......@@ -99,12 +100,12 @@ module QA
commit.api_client = user_api_client
commit.project = project
commit.commit_message = 'changing text file'
commit.add_files(
commit.update_files(
[
{
file_path: file_name,
content: Faker::Lorem.sentence
}
{
file_path: file_name,
content: 'Has to be different than before.'
}
]
)
end
......@@ -124,12 +125,6 @@ module QA
end
end
end
private
def create_user_personal_access_token
user_api_client.personal_access_token
end
end
end
end
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