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 ...@@ -7,13 +7,13 @@ describe 'CycleAnalytics#code', feature: true do
subject { CycleAnalytics.new(project, from: from_date) } subject { CycleAnalytics.new(project, from: from_date) }
def create_commit_referencing_issue(issue) 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 = project.repository.commit(sha)
commit.create_cross_references!(user) commit.create_cross_references!(user)
end end
def create_merge_request_closing_issue(issue, message: nil) 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') project.repository.add_branch(user, source_branch, 'master')
opts = { opts = {
......
...@@ -7,7 +7,7 @@ describe 'CycleAnalytics#plan', feature: true do ...@@ -7,7 +7,7 @@ describe 'CycleAnalytics#plan', feature: true do
subject { CycleAnalytics.new(project, from: from_date) } subject { CycleAnalytics.new(project, from: from_date) }
def create_commit_referencing_issue(issue) 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 = project.repository.commit(sha)
commit.create_cross_references! commit.create_cross_references!
end end
......
...@@ -7,9 +7,9 @@ describe 'CycleAnalytics#review', feature: true do ...@@ -7,9 +7,9 @@ describe 'CycleAnalytics#review', feature: true do
subject { CycleAnalytics.new(project, from: from_date) } subject { CycleAnalytics.new(project, from: from_date) }
def create_merge_request_closing_issue(issue) 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') 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) project.repository.commit(sha)
opts = { opts = {
...@@ -22,7 +22,6 @@ describe 'CycleAnalytics#review', feature: true do ...@@ -22,7 +22,6 @@ describe 'CycleAnalytics#review', feature: true do
MergeRequests::CreateService.new(project, user, opts).execute MergeRequests::CreateService.new(project, user, opts).execute
end end
def merge_merge_requests_closing_issue(issue) def merge_merge_requests_closing_issue(issue)
merge_requests = issue.closed_by_merge_requests merge_requests = issue.closed_by_merge_requests
merge_requests.each { |merge_request| MergeRequests::MergeService.new(project, user).execute(merge_request) } 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