summaryrefslogtreecommitdiff
path: root/spec/support
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-04-04 13:36:36 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-04-04 13:36:36 +0200
commit44321b1a3d99fc1a25d4b24afef55e1755f89e8a (patch)
treeb5eee1964c7f32adb8096c07cee23c2a413640eb /spec/support
parentb03f1699c47ce8a08f67ef458107d22cbafbc0bd (diff)
parent5efd67942cec39d733d27a52edc2ebc86babce30 (diff)
downloadgitlab-ce-44321b1a3d99fc1a25d4b24afef55e1755f89e8a.tar.gz
Merge branch 'master' into feature/multi-level-container-registry-images
* master: (57 commits) Ensure we generate unique usernames otherwise validations fail Fix a Knapsack issue that would load support/capybara.rb before support/env.rb Ensure users have a short username otherwise a click event is triggered ... Enable the `bullet_logger` setting; enable `raise` in test environment Fix Rubocop offenses Set the right timeout for Gitlab::Shell#fetch_remote Refactoring Projects::ImportService Move methods that are not related to mirroring to the repository model Fix GitHub pull request formatter spec Rename skip_metrics to imported on the importable concern Add CHANGELOG Remove unused include from RepositoryImportWorker Skip MR metrics when importing projects from GitHub Fetch GitHub project as a mirror to get all refs at once Make file templates easy to use and discover Ensure user has a unique username otherwise `user10` would match `user1` Ensure the AbuseReport fixtures create unique reported users Don't use FFaker in factories, use sequences instead Fix brittle specs Fix the AbuseReport seeder ... Conflicts: db/schema.rb
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/cycle_analytics_helpers.rb10
-rw-r--r--spec/support/filter_spec_helper.rb4
-rw-r--r--spec/support/git_helpers.rb9
-rw-r--r--spec/support/issuables_list_metadata_shared_examples.rb4
-rw-r--r--spec/support/services/issuable_create_service_slash_commands_shared_examples.rb2
-rw-r--r--spec/support/test_env.rb6
6 files changed, 13 insertions, 22 deletions
diff --git a/spec/support/cycle_analytics_helpers.rb b/spec/support/cycle_analytics_helpers.rb
index c864a705ca4..8ad042f5e3b 100644
--- a/spec/support/cycle_analytics_helpers.rb
+++ b/spec/support/cycle_analytics_helpers.rb
@@ -1,5 +1,5 @@
module CycleAnalyticsHelpers
- def create_commit_referencing_issue(issue, branch_name: random_git_name)
+ def create_commit_referencing_issue(issue, branch_name: generate(:branch))
project.repository.add_branch(user, branch_name, 'master')
create_commit("Commit for ##{issue.iid}", issue.project, user, branch_name)
end
@@ -7,9 +7,7 @@ module CycleAnalyticsHelpers
def create_commit(message, project, user, branch_name, count: 1)
oldrev = project.repository.commit(branch_name).sha
commit_shas = Array.new(count) do |index|
- filename = random_git_name
-
- commit_sha = project.repository.create_file(user, filename, "content", message: message, branch_name: branch_name)
+ commit_sha = project.repository.create_file(user, generate(:branch), "content", message: message, branch_name: branch_name)
project.repository.commit(commit_sha)
commit_sha
@@ -24,13 +22,13 @@ module CycleAnalyticsHelpers
def create_merge_request_closing_issue(issue, message: nil, source_branch: nil)
if !source_branch || project.repository.commit(source_branch).blank?
- source_branch = random_git_name
+ source_branch = generate(:branch)
project.repository.add_branch(user, source_branch, 'master')
end
sha = project.repository.create_file(
user,
- random_git_name,
+ generate(:branch),
'content',
message: 'commit message',
branch_name: source_branch)
diff --git a/spec/support/filter_spec_helper.rb b/spec/support/filter_spec_helper.rb
index a8e454eb09e..b871b7ffc90 100644
--- a/spec/support/filter_spec_helper.rb
+++ b/spec/support/filter_spec_helper.rb
@@ -63,9 +63,9 @@ module FilterSpecHelper
#
# Returns a String
def invalidate_reference(reference)
- if reference =~ /\A(.+)?.\d+\z/
+ if reference =~ /\A(.+)?[^\d]\d+\z/
# Integer-based reference with optional project prefix
- reference.gsub(/\d+\z/) { |i| i.to_i + 1 }
+ reference.gsub(/\d+\z/) { |i| i.to_i + 10_000 }
elsif reference =~ /\A(.+@)?(\h{7,40}\z)/
# SHA-based reference with optional prefix
reference.gsub(/\h{7,40}\z/) { |v| v.reverse }
diff --git a/spec/support/git_helpers.rb b/spec/support/git_helpers.rb
deleted file mode 100644
index 93422390ef7..00000000000
--- a/spec/support/git_helpers.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-module GitHelpers
- def random_git_name
- "#{FFaker::Product.brand}-#{FFaker::Product.brand}-#{rand(1000)}"
- end
-end
-
-RSpec.configure do |config|
- config.include GitHelpers
-end
diff --git a/spec/support/issuables_list_metadata_shared_examples.rb b/spec/support/issuables_list_metadata_shared_examples.rb
index 4c0f556e736..7ea4073ef2b 100644
--- a/spec/support/issuables_list_metadata_shared_examples.rb
+++ b/spec/support/issuables_list_metadata_shared_examples.rb
@@ -2,12 +2,12 @@ shared_examples 'issuables list meta-data' do |issuable_type, action = nil|
before do
@issuable_ids = []
- 2.times do
+ 2.times do |n|
issuable =
if issuable_type == :issue
create(issuable_type, project: project)
else
- create(issuable_type, title: FFaker::Lorem.sentence, source_project: project, source_branch: FFaker::Name.name)
+ create(issuable_type, source_project: project, source_branch: "#{n}-feature")
end
@issuable_ids << issuable.id
diff --git a/spec/support/services/issuable_create_service_slash_commands_shared_examples.rb b/spec/support/services/issuable_create_service_slash_commands_shared_examples.rb
index ee492daee30..9e9cdf3e48b 100644
--- a/spec/support/services/issuable_create_service_slash_commands_shared_examples.rb
+++ b/spec/support/services/issuable_create_service_slash_commands_shared_examples.rb
@@ -7,7 +7,7 @@ shared_examples 'new issuable record that supports slash commands' do
let(:assignee) { create(:user) }
let!(:milestone) { create(:milestone, project: project) }
let!(:labels) { create_list(:label, 3, project: project) }
- let(:base_params) { { title: FFaker::Lorem.sentence(3) } }
+ let(:base_params) { { title: 'My issuable title' } }
let(:params) { base_params.merge(defined?(default_params) ? default_params : {}).merge(example_params) }
let(:issuable) { described_class.new(project, user, params).execute }
diff --git a/spec/support/test_env.rb b/spec/support/test_env.rb
index a19a35c2c0d..1b5cb71a6b0 100644
--- a/spec/support/test_env.rb
+++ b/spec/support/test_env.rb
@@ -131,8 +131,10 @@ module TestEnv
set_repo_refs(repo_path, branch_sha)
- # We must copy bare repositories because we will push to them.
- system(git_env, *%W(#{Gitlab.config.git.bin_path} clone -q --bare #{repo_path} #{repo_path_bare}))
+ unless File.directory?(repo_path_bare)
+ # We must copy bare repositories because we will push to them.
+ system(git_env, *%W(#{Gitlab.config.git.bin_path} clone -q --bare #{repo_path} #{repo_path_bare}))
+ end
end
def copy_repo(project)