Commit 586ef92a authored by Dan Davison's avatar Dan Davison

Merge branch 'ml-update-test-filename' into 'master'

Use unique filename in case of retries

See merge request gitlab-org/gitlab!21712
parents 3dcc9548 459f48ac
...@@ -54,7 +54,7 @@ module QA ...@@ -54,7 +54,7 @@ module QA
@assignee = nil @assignee = nil
@milestone = nil @milestone = nil
@labels = [] @labels = []
@file_name = "added_file.txt" @file_name = "added_file-#{SecureRandom.hex(8)}.txt"
@file_content = "File Added" @file_content = "File Added"
@target_new_branch = true @target_new_branch = true
@no_preparation = false @no_preparation = false
......
# frozen_string_literal: true # frozen_string_literal: true
require 'securerandom'
module QA module QA
module Resource module Resource
class MergeRequestFromFork < MergeRequest class MergeRequestFromFork < MergeRequest
...@@ -13,7 +15,7 @@ module QA ...@@ -13,7 +15,7 @@ module QA
Repository::ProjectPush.fabricate! do |resource| Repository::ProjectPush.fabricate! do |resource|
resource.project = fork.project resource.project = fork.project
resource.branch_name = fork_branch resource.branch_name = fork_branch
resource.file_name = 'file2.txt' resource.file_name = "file2-#{SecureRandom.hex(8)}.txt"
resource.user = fork.user resource.user = fork.user
end end
end end
......
# frozen_string_literal: true # frozen_string_literal: true
require 'securerandom'
module QA module QA
module Resource module Resource
class ProtectedBranch < Base class ProtectedBranch < Base
...@@ -15,7 +17,7 @@ module QA ...@@ -15,7 +17,7 @@ module QA
attribute :branch do attribute :branch do
Repository::ProjectPush.fabricate! do |project_push| Repository::ProjectPush.fabricate! do |project_push|
project_push.project = project project_push.project = project
project_push.file_name = 'new_file.md' project_push.file_name = "new_file-#{SecureRandom.hex(8)}.md"
project_push.commit_message = 'Add new file' project_push.commit_message = 'Add new file'
project_push.branch_name = branch_name project_push.branch_name = branch_name
project_push.new_branch = true project_push.new_branch = true
......
# frozen_string_literal: true # frozen_string_literal: true
require 'securerandom'
module QA module QA
module Resource module Resource
module Repository module Repository
...@@ -15,7 +17,7 @@ module QA ...@@ -15,7 +17,7 @@ module QA
end end
def initialize def initialize
@file_name = 'file.txt' @file_name = "file-#{SecureRandom.hex(8)}.txt"
@file_content = '# This is test project' @file_content = '# This is test project'
@commit_message = "This is a test commit" @commit_message = "This is a test commit"
@branch_name = 'master' @branch_name = 'master'
......
# frozen_string_literal: true # frozen_string_literal: true
require 'pathname' require 'pathname'
require 'securerandom'
module QA module QA
module Resource module Resource
...@@ -13,7 +14,7 @@ module QA ...@@ -13,7 +14,7 @@ module QA
attr_writer :remote_branch, :gpg_key_id attr_writer :remote_branch, :gpg_key_id
def initialize def initialize
@file_name = 'file.txt' @file_name = "file-#{SecureRandom.hex(8)}.txt"
@file_content = '# This is test file' @file_content = '# This is test file'
@commit_message = "This is a test commit" @commit_message = "This is a test commit"
@branch_name = 'master' @branch_name = 'master'
......
...@@ -4,12 +4,7 @@ module QA ...@@ -4,12 +4,7 @@ module QA
context 'Create' do context 'Create' do
describe 'Download merge request patch and diff' do describe 'Download merge request patch and diff' do
before(:context) do before(:context) do
project = Resource::Project.fabricate_via_api! do |project|
project.name = 'project'
end
@merge_request = Resource::MergeRequest.fabricate_via_api! do |merge_request| @merge_request = Resource::MergeRequest.fabricate_via_api! do |merge_request|
merge_request.project = project
merge_request.title = 'This is a merge request' merge_request.title = 'This is a merge request'
merge_request.description = '... for downloading patches and diffs' merge_request.description = '... for downloading patches and diffs'
end end
...@@ -23,7 +18,7 @@ module QA ...@@ -23,7 +18,7 @@ module QA
expect(page.text).to start_with('From') expect(page.text).to start_with('From')
expect(page).to have_content('Subject: [PATCH] This is a test commit') expect(page).to have_content('Subject: [PATCH] This is a test commit')
expect(page).to have_content('diff --git a/added_file.txt b/added_file.txt') expect(page).to have_content("diff --git a/#{@merge_request.file_name} b/#{@merge_request.file_name}")
end end
it 'views the merge request plain diff' do it 'views the merge request plain diff' do
...@@ -32,7 +27,7 @@ module QA ...@@ -32,7 +27,7 @@ module QA
@merge_request.visit! @merge_request.visit!
Page::MergeRequest::Show.perform(&:view_plain_diff) Page::MergeRequest::Show.perform(&:view_plain_diff)
expect(page.text).to start_with('diff --git a/added_file.txt b/added_file.txt') expect(page.text).to start_with("diff --git a/#{@merge_request.file_name} b/#{@merge_request.file_name}")
expect(page).to have_content('+File Added') expect(page).to have_content('+File Added')
end end
end end
......
...@@ -59,7 +59,7 @@ module QA ...@@ -59,7 +59,7 @@ module QA
commit.update_files( commit.update_files(
[ [
{ {
file_path: 'added_file.txt', file_path: merge_request.file_name,
content: "File updated" content: "File updated"
} }
] ]
......
...@@ -57,6 +57,7 @@ module QA ...@@ -57,6 +57,7 @@ module QA
project_push.project = @project project_push.project = @project
project_push.new_branch = true project_push.new_branch = true
project_push.branch_name = branch_name project_push.branch_name = branch_name
project_push.file_name = "file-#{SecureRandom.hex(8)}.txt"
end end
# Create a merge request to merge the branch we just created # Create a merge request to merge the branch we just created
...@@ -91,7 +92,7 @@ module QA ...@@ -91,7 +92,7 @@ module QA
project_push.project = @project project_push.project = @project
project_push.new_branch = true project_push.new_branch = true
project_push.branch_name = branch_name project_push.branch_name = branch_name
project_push.file_name = "another_file.txt" project_push.file_name = "file-#{SecureRandom.hex(8)}.txt"
project_push.file_content = "merge me" project_push.file_content = "merge me"
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