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