Commit 0f44c5a5 authored by Timothy Andrew's avatar Timothy Andrew

Generate branch/file names more randomly to avoid failures.

- Tests would randomly fail because of naming conflicts.
- Use a `random_git_name` method instead of using `FFaker` directly.
parent 71a9bcd3
......@@ -7,13 +7,13 @@ describe 'CycleAnalytics#code', feature: true do
subject { CycleAnalytics.new(project, from: from_date) }
def create_commit_referencing_issue(issue)
sha = project.repository.commit_file(user, FFaker::Product.brand, "content", "Commit for ##{issue.iid}", "master", false)
sha = project.repository.commit_file(user, random_git_name, "content", "Commit for ##{issue.iid}", "master", false)
commit = project.repository.commit(sha)
commit.create_cross_references!(user)
end
def create_merge_request_closing_issue(issue, message: nil)
source_branch = FFaker::Product.brand
source_branch = random_git_name
project.repository.add_branch(user, source_branch, 'master')
opts = {
......
......@@ -7,7 +7,7 @@ describe 'CycleAnalytics#plan', feature: true do
subject { CycleAnalytics.new(project, from: from_date) }
def create_commit_referencing_issue(issue)
sha = project.repository.commit_file(user, FFaker::Product.brand, "content", "Commit for ##{issue.iid}", "master", false)
sha = project.repository.commit_file(user, random_git_name, "content", "Commit for ##{issue.iid}", "master", false)
commit = project.repository.commit(sha)
commit.create_cross_references!
end
......
......@@ -7,9 +7,9 @@ describe 'CycleAnalytics#review', feature: true do
subject { CycleAnalytics.new(project, from: from_date) }
def create_merge_request_closing_issue(issue)
source_branch = FFaker::Product.brand
source_branch = random_git_name
project.repository.add_branch(user, source_branch, 'master')
sha = project.repository.commit_file(user, FFaker::Product.brand, "content", "commit message", source_branch, false)
sha = project.repository.commit_file(user, random_git_name, "content", "commit message", source_branch, false)
project.repository.commit(sha)
opts = {
......@@ -22,7 +22,6 @@ describe 'CycleAnalytics#review', feature: true do
MergeRequests::CreateService.new(project, user, opts).execute
end
def merge_merge_requests_closing_issue(issue)
merge_requests = issue.closed_by_merge_requests
merge_requests.each { |merge_request| MergeRequests::MergeService.new(project, user).execute(merge_request) }
......
module GitHelpers
def random_git_name
"#{FFaker::Product.brand}-#{FFaker::Product.brand}-#{rand(1000)}"
end
end
RSpec.configure do |config|
config.include GitHelpers
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