summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2017-03-23 14:08:39 +0100
committerRémy Coutable <remy@rymai.me>2017-04-03 18:54:48 +0200
commit4e3516788fdea3de3c5f06e1981ddc518b05d0fb (patch)
treed83183c2dfb8c5082a9d5a9fbcda6a5479c7d9fd /spec
parentca6a7f1e9c9296317315249de9b8b3803d1c6ddc (diff)
downloadgitlab-ce-4e3516788fdea3de3c5f06e1981ddc518b05d0fb.tar.gz
Don't use FFaker in factories, use sequences instead
FFaker can generate data that randomly break our test suite. This simplifies our factories and use sequences which are more predictive. Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/profiles/personal_access_tokens_spec.rb2
-rw-r--r--spec/factories/chat_names.rb8
-rw-r--r--spec/factories/chat_teams.rb5
-rw-r--r--spec/factories/ci/runners.rb4
-rw-r--r--spec/factories/emails.rb2
-rw-r--r--spec/factories/issues.rb4
-rw-r--r--spec/factories/labels.rb4
-rw-r--r--spec/factories/oauth_applications.rb4
-rw-r--r--spec/factories/personal_access_tokens.rb2
-rw-r--r--spec/factories/project_hooks.rb2
-rw-r--r--spec/factories/sequences.rb10
-rw-r--r--spec/factories/service_hooks.rb2
-rw-r--r--spec/factories/snippets.rb9
-rw-r--r--spec/factories/spam_logs.rb6
-rw-r--r--spec/factories/system_hooks.rb2
-rw-r--r--spec/factories/users.rb8
-rw-r--r--spec/features/admin/admin_hooks_spec.rb2
-rw-r--r--spec/features/admin/admin_users_impersonation_tokens_spec.rb2
-rw-r--r--spec/features/issuables/issuable_list_spec.rb9
-rw-r--r--spec/features/profiles/personal_access_tokens_spec.rb4
-rw-r--r--spec/features/u2f_spec.rb17
-rw-r--r--spec/lib/gitlab/git_access_spec.rb8
-rw-r--r--spec/lib/gitlab/git_spec.rb17
-rw-r--r--spec/mailers/notify_spec.rb4
-rw-r--r--spec/models/cycle_analytics/plan_spec.rb4
-rw-r--r--spec/models/cycle_analytics/production_spec.rb2
-rw-r--r--spec/models/cycle_analytics/staging_spec.rb2
-rw-r--r--spec/models/repository_spec.rb17
-rw-r--r--spec/requests/api/files_spec.rb17
-rw-r--r--spec/requests/api/projects_spec.rb2
-rw-r--r--spec/requests/api/v3/files_spec.rb4
-rw-r--r--spec/requests/api/v3/projects_spec.rb2
-rw-r--r--spec/support/cycle_analytics_helpers.rb12
-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
36 files changed, 74 insertions, 140 deletions
diff --git a/spec/controllers/profiles/personal_access_tokens_spec.rb b/spec/controllers/profiles/personal_access_tokens_spec.rb
index dfed1de2046..98a43e278b2 100644
--- a/spec/controllers/profiles/personal_access_tokens_spec.rb
+++ b/spec/controllers/profiles/personal_access_tokens_spec.rb
@@ -12,7 +12,7 @@ describe Profiles::PersonalAccessTokensController do
end
it "allows creation of a token with scopes" do
- name = FFaker::Product.brand
+ name = 'My PAT'
scopes = %w[api read_user]
post :create, personal_access_token: token_attributes.merge(scopes: scopes, name: name)
diff --git a/spec/factories/chat_names.rb b/spec/factories/chat_names.rb
index 24225468d55..9a0be1a4598 100644
--- a/spec/factories/chat_names.rb
+++ b/spec/factories/chat_names.rb
@@ -6,11 +6,7 @@ FactoryGirl.define do
team_id 'T0001'
team_domain 'Awesome Team'
- sequence :chat_id do |n|
- "U#{n}"
- end
- sequence :chat_name do |n|
- "user#{n}"
- end
+ sequence(:chat_id) { |n| "U#{n}" }
+ chat_name { generate(:username) }
end
end
diff --git a/spec/factories/chat_teams.rb b/spec/factories/chat_teams.rb
index 82f44fa3d15..ffedf69a69b 100644
--- a/spec/factories/chat_teams.rb
+++ b/spec/factories/chat_teams.rb
@@ -1,9 +1,6 @@
FactoryGirl.define do
factory :chat_team, class: ChatTeam do
- sequence :team_id do |n|
- "abcdefghijklm#{n}"
- end
-
+ sequence(:team_id) { |n| "abcdefghijklm#{n}" }
namespace factory: :group
end
end
diff --git a/spec/factories/ci/runners.rb b/spec/factories/ci/runners.rb
index c3b4aff55ba..05abf60d5ce 100644
--- a/spec/factories/ci/runners.rb
+++ b/spec/factories/ci/runners.rb
@@ -1,8 +1,6 @@
FactoryGirl.define do
factory :ci_runner, class: Ci::Runner do
- sequence :description do |n|
- "My runner#{n}"
- end
+ sequence(:description) { |n| "My runner#{n}" }
platform "darwin"
is_shared false
diff --git a/spec/factories/emails.rb b/spec/factories/emails.rb
index 9794772ac7d..8303861bcfe 100644
--- a/spec/factories/emails.rb
+++ b/spec/factories/emails.rb
@@ -1,6 +1,6 @@
FactoryGirl.define do
factory :email do
user
- email { FFaker::Internet.email('alias') }
+ email { generate(:email_alias) }
end
end
diff --git a/spec/factories/issues.rb b/spec/factories/issues.rb
index 7e09f1ba8ea..dbd0fff8376 100644
--- a/spec/factories/issues.rb
+++ b/spec/factories/issues.rb
@@ -1,8 +1,4 @@
FactoryGirl.define do
- sequence :issue_created_at do |n|
- 4.hours.ago + ( 2 * n ).seconds
- end
-
factory :issue do
title
author
diff --git a/spec/factories/labels.rb b/spec/factories/labels.rb
index 5ba8443c62c..5706ab6a767 100644
--- a/spec/factories/labels.rb
+++ b/spec/factories/labels.rb
@@ -1,6 +1,6 @@
FactoryGirl.define do
factory :label, class: ProjectLabel do
- sequence(:title) { |n| "label#{n}" }
+ title { generate(:label) }
color "#990000"
project factory: :empty_project
@@ -16,7 +16,7 @@ FactoryGirl.define do
end
factory :group_label, class: GroupLabel do
- sequence(:title) { |n| "label#{n}" }
+ title { generate(:label) }
color "#990000"
group
end
diff --git a/spec/factories/oauth_applications.rb b/spec/factories/oauth_applications.rb
index 86cdc208268..c7ede40f240 100644
--- a/spec/factories/oauth_applications.rb
+++ b/spec/factories/oauth_applications.rb
@@ -1,8 +1,8 @@
FactoryGirl.define do
factory :oauth_application, class: 'Doorkeeper::Application', aliases: [:application] do
- name { FFaker::Name.name }
+ sequence(:name) { |n| "OAuth App #{n}" }
uid { Doorkeeper::OAuth::Helpers::UniqueToken.generate }
- redirect_uri { FFaker::Internet.uri('http') }
+ redirect_uri { generate(:url) }
owner
owner_type 'User'
end
diff --git a/spec/factories/personal_access_tokens.rb b/spec/factories/personal_access_tokens.rb
index 7b15ba47de1..06acaff6cd0 100644
--- a/spec/factories/personal_access_tokens.rb
+++ b/spec/factories/personal_access_tokens.rb
@@ -2,7 +2,7 @@ FactoryGirl.define do
factory :personal_access_token do
user
token { SecureRandom.hex(50) }
- name { FFaker::Product.brand }
+ sequence(:name) { |n| "PAT #{n}" }
revoked false
expires_at { 5.days.from_now }
scopes ['api']
diff --git a/spec/factories/project_hooks.rb b/spec/factories/project_hooks.rb
index 424ecc65759..39c2a9dd1fb 100644
--- a/spec/factories/project_hooks.rb
+++ b/spec/factories/project_hooks.rb
@@ -1,6 +1,6 @@
FactoryGirl.define do
factory :project_hook do
- url { FFaker::Internet.uri('http') }
+ url { generate(:url) }
trait :token do
token { SecureRandom.hex(10) }
diff --git a/spec/factories/sequences.rb b/spec/factories/sequences.rb
new file mode 100644
index 00000000000..5b8501aa770
--- /dev/null
+++ b/spec/factories/sequences.rb
@@ -0,0 +1,10 @@
+FactoryGirl.define do
+ sequence(:username) { |n| "user#{n}" }
+ sequence(:name) { |n| "John Doe#{n}" }
+ sequence(:email) { |n| "user#{n}@example.org" }
+ sequence(:email_alias) { |n| "user.alias#{n}@example.org" }
+ sequence(:url) { |n| "http://example#{n}.org" }
+ sequence(:label) { |n| "label#{n}" }
+ sequence(:branch) { |n| "my-branch-#{n}" }
+ sequence(:issue_created_at) { |n| 4.hours.ago + (2 * n).seconds }
+end
diff --git a/spec/factories/service_hooks.rb b/spec/factories/service_hooks.rb
index 6dd6af63f3e..e3f88ab8fcc 100644
--- a/spec/factories/service_hooks.rb
+++ b/spec/factories/service_hooks.rb
@@ -1,6 +1,6 @@
FactoryGirl.define do
factory :service_hook do
- url { FFaker::Internet.uri('http') }
+ url { generate(:url) }
service
end
end
diff --git a/spec/factories/snippets.rb b/spec/factories/snippets.rb
index 365f12a0c95..fb87c584f0b 100644
--- a/spec/factories/snippets.rb
+++ b/spec/factories/snippets.rb
@@ -1,11 +1,6 @@
FactoryGirl.define do
- sequence :title, aliases: [:content] do
- FFaker::Lorem.sentence
- end
-
- sequence :file_name do
- FFaker::Internet.user_name
- end
+ sequence(:title, aliases: [:content]) { |n| "My snippet #{n}" }
+ sequence(:file_name) { |n| "snippet-#{n}.rb" }
factory :snippet do
author
diff --git a/spec/factories/spam_logs.rb b/spec/factories/spam_logs.rb
index a4f6d291269..e369f9f13e9 100644
--- a/spec/factories/spam_logs.rb
+++ b/spec/factories/spam_logs.rb
@@ -1,9 +1,9 @@
FactoryGirl.define do
factory :spam_log do
user
- source_ip { FFaker::Internet.ip_v4_address }
+ sequence(:source_ip) { |n| "42.42.42.#{n % 255}" }
noteable_type 'Issue'
- title { FFaker::Lorem.sentence }
- description { FFaker::Lorem.paragraph(5) }
+ sequence(:title) { |n| "Spam title #{n}" }
+ description { "Spam description\nwith\nmultiple\nlines" }
end
end
diff --git a/spec/factories/system_hooks.rb b/spec/factories/system_hooks.rb
index c786e9cb79b..841e1e293e8 100644
--- a/spec/factories/system_hooks.rb
+++ b/spec/factories/system_hooks.rb
@@ -1,5 +1,5 @@
FactoryGirl.define do
factory :system_hook do
- url { FFaker::Internet.uri('http') }
+ url { generate(:url) }
end
end
diff --git a/spec/factories/users.rb b/spec/factories/users.rb
index 249dabbaae8..e1ae94a08e4 100644
--- a/spec/factories/users.rb
+++ b/spec/factories/users.rb
@@ -1,10 +1,8 @@
FactoryGirl.define do
- sequence(:name) { FFaker::Name.name }
-
factory :user, aliases: [:author, :assignee, :recipient, :owner, :creator, :resource_owner] do
- email { FFaker::Internet.email }
- name
- sequence(:username) { |n| "#{FFaker::Internet.user_name}#{n}" }
+ email { generate(:email) }
+ name { generate(:name) }
+ username { generate(:username) }
password "12345678"
confirmed_at { Time.now }
confirmation_token { nil }
diff --git a/spec/features/admin/admin_hooks_spec.rb b/spec/features/admin/admin_hooks_spec.rb
index f246997d5a2..570c374a89b 100644
--- a/spec/features/admin/admin_hooks_spec.rb
+++ b/spec/features/admin/admin_hooks_spec.rb
@@ -26,7 +26,7 @@ describe "Admin::Hooks", feature: true do
end
describe "New Hook" do
- let(:url) { FFaker::Internet.uri('http') }
+ let(:url) { generate(:url) }
it 'adds new hook' do
visit admin_hooks_path
diff --git a/spec/features/admin/admin_users_impersonation_tokens_spec.rb b/spec/features/admin/admin_users_impersonation_tokens_spec.rb
index 9ff5c2f9d40..ff23d486355 100644
--- a/spec/features/admin/admin_users_impersonation_tokens_spec.rb
+++ b/spec/features/admin/admin_users_impersonation_tokens_spec.rb
@@ -16,7 +16,7 @@ describe 'Admin > Users > Impersonation Tokens', feature: true, js: true do
describe "token creation" do
it "allows creation of a token" do
- name = FFaker::Product.brand
+ name = 'Hello World'
visit admin_user_impersonation_tokens_path(user_id: user.username)
fill_in "Name", with: name
diff --git a/spec/features/issuables/issuable_list_spec.rb b/spec/features/issuables/issuable_list_spec.rb
index b90bf6268fd..f324354dd46 100644
--- a/spec/features/issuables/issuable_list_spec.rb
+++ b/spec/features/issuables/issuable_list_spec.rb
@@ -46,16 +46,16 @@ describe 'issuable list', feature: true do
end
def create_issuables(issuable_type)
- 3.times do
+ 3.times do |n|
issuable =
if issuable_type == :issue
create(:issue, project: project, author: user)
else
- create(:merge_request, title: FFaker::Lorem.sentence, source_project: project, source_branch: FFaker::Name.name)
+ create(:merge_request, source_project: project, source_branch: "#{n}-feature")
end
2.times do
- create(:note_on_issue, noteable: issuable, project: project, note: 'Test note')
+ create(:note_on_issue, noteable: issuable, project: project)
end
create(:award_emoji, :downvote, awardable: issuable)
@@ -65,9 +65,8 @@ describe 'issuable list', feature: true do
if issuable_type == :issue
issue = Issue.reorder(:iid).first
merge_request = create(:merge_request,
- title: FFaker::Lorem.sentence,
source_project: project,
- source_branch: FFaker::Name.name)
+ source_branch: 'my-bug-fix')
MergeRequestsClosingIssues.create!(issue: issue, merge_request: merge_request)
end
diff --git a/spec/features/profiles/personal_access_tokens_spec.rb b/spec/features/profiles/personal_access_tokens_spec.rb
index 0917d4dc3ef..99fba594651 100644
--- a/spec/features/profiles/personal_access_tokens_spec.rb
+++ b/spec/features/profiles/personal_access_tokens_spec.rb
@@ -27,7 +27,7 @@ describe 'Profile > Personal Access Tokens', feature: true, js: true do
describe "token creation" do
it "allows creation of a personal access token" do
- name = FFaker::Product.brand
+ name = 'My PAT'
visit profile_personal_access_tokens_path
fill_in "Name", with: name
@@ -52,7 +52,7 @@ describe 'Profile > Personal Access Tokens', feature: true, js: true do
it "displays an error message" do
disallow_personal_access_token_saves!
visit profile_personal_access_tokens_path
- fill_in "Name", with: FFaker::Product.brand
+ fill_in "Name", with: 'My PAT'
expect { click_on "Create Personal Access Token" }.not_to change { PersonalAccessToken.count }
expect(page).to have_content("Name cannot be nil")
diff --git a/spec/features/u2f_spec.rb b/spec/features/u2f_spec.rb
index a8d00bb8e5a..28373098123 100644
--- a/spec/features/u2f_spec.rb
+++ b/spec/features/u2f_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-feature 'Using U2F (Universal 2nd Factor) Devices for Authentication', feature: true, js: true do
+feature 'Using U2F (Universal 2nd Factor) Devices for Authentication', :js do
include WaitForAjax
before { allow_any_instance_of(U2fHelper).to receive(:inject_u2f_api?).and_return(true) }
@@ -11,8 +11,7 @@ feature 'Using U2F (Universal 2nd Factor) Devices for Authentication', feature:
wait_for_ajax
end
- def register_u2f_device(u2f_device = nil)
- name = FFaker::Name.first_name
+ def register_u2f_device(u2f_device = nil, name: 'My device')
u2f_device ||= FakeU2fDevice.new(page, name)
u2f_device.respond_to_u2f_registration
click_on 'Setup New U2F Device'
@@ -62,7 +61,7 @@ feature 'Using U2F (Universal 2nd Factor) Devices for Authentication', feature:
expect(page).to have_content('Your U2F device was registered')
# Second device
- second_device = register_u2f_device
+ second_device = register_u2f_device(name: 'My other device')
expect(page).to have_content('Your U2F device was registered')
expect(page).to have_content(first_device.name)
@@ -76,7 +75,7 @@ feature 'Using U2F (Universal 2nd Factor) Devices for Authentication', feature:
expect(page).to have_content("You've already enabled two-factor authentication using mobile")
first_u2f_device = register_u2f_device
- second_u2f_device = register_u2f_device
+ second_u2f_device = register_u2f_device(name: 'My other device')
click_on "Delete", match: :first
@@ -99,7 +98,7 @@ feature 'Using U2F (Universal 2nd Factor) Devices for Authentication', feature:
user.update_attribute(:otp_required_for_login, true)
visit profile_account_path
manage_two_factor_authentication
- register_u2f_device(u2f_device)
+ register_u2f_device(u2f_device, name: 'My other device')
expect(page).to have_content('Your U2F device was registered')
expect(U2fRegistration.count).to eq(2)
@@ -198,7 +197,7 @@ feature 'Using U2F (Universal 2nd Factor) Devices for Authentication', feature:
current_user.update_attribute(:otp_required_for_login, true)
visit profile_account_path
manage_two_factor_authentication
- register_u2f_device
+ register_u2f_device(name: 'My other device')
logout
# Try authenticating user with the old U2F device
@@ -231,7 +230,7 @@ feature 'Using U2F (Universal 2nd Factor) Devices for Authentication', feature:
describe "when a given U2F device has not been registered" do
it "does not allow logging in with that particular device" do
- unregistered_device = FakeU2fDevice.new(page, FFaker::Name.first_name)
+ unregistered_device = FakeU2fDevice.new(page, 'My device')
login_as(user)
unregistered_device.respond_to_u2f_authentication
expect(page).to have_content('We heard back from your U2F device')
@@ -252,7 +251,7 @@ feature 'Using U2F (Universal 2nd Factor) Devices for Authentication', feature:
# Register second device
visit profile_two_factor_auth_path
expect(page).to have_content("Your U2F device needs to be set up.")
- second_device = register_u2f_device
+ second_device = register_u2f_device(name: 'My other device')
logout
# Authenticate as both devices
diff --git a/spec/lib/gitlab/git_access_spec.rb b/spec/lib/gitlab/git_access_spec.rb
index 48f7754bed8..703b41f95ac 100644
--- a/spec/lib/gitlab/git_access_spec.rb
+++ b/spec/lib/gitlab/git_access_spec.rb
@@ -183,7 +183,7 @@ describe Gitlab::GitAccess, lib: true do
describe '#check_push_access!' do
before { merge_into_protected_branch }
- let(:unprotected_branch) { FFaker::Internet.user_name }
+ let(:unprotected_branch) { 'unprotected_branch' }
let(:changes) do
{ push_new_branch: "#{Gitlab::Git::BLANK_SHA} 570e7b2ab refs/heads/wow",
@@ -211,9 +211,9 @@ describe Gitlab::GitAccess, lib: true do
target_branch = project.repository.lookup('feature')
source_branch = project.repository.create_file(
user,
- FFaker::InternetSE.login_user_name,
- FFaker::HipsterIpsum.paragraph,
- message: FFaker::HipsterIpsum.sentence,
+ 'John Doe',
+ 'This is the file content',
+ message: 'This is a good commit message',
branch_name: unprotected_branch)
rugged = project.repository.rugged
author = { email: "email@example.com", time: Time.now, name: "Example Git User" }
diff --git a/spec/lib/gitlab/git_spec.rb b/spec/lib/gitlab/git_spec.rb
index 8eaf7aac264..36f0e6507c8 100644
--- a/spec/lib/gitlab/git_spec.rb
+++ b/spec/lib/gitlab/git_spec.rb
@@ -1,21 +1,8 @@
require 'spec_helper'
describe Gitlab::Git, lib: true do
- let(:committer_email) { FFaker::Internet.email }
-
- # I have to remove periods from the end of the name
- # This happened when the user's name had a suffix (i.e. "Sr.")
- # This seems to be what git does under the hood. For example, this commit:
- #
- # $ git commit --author='Foo Sr. <foo@example.com>' -m 'Where's my trailing period?'
- #
- # results in this:
- #
- # $ git show --pretty
- # ...
- # Author: Foo Sr <foo@example.com>
- # ...
- let(:committer_name) { FFaker::Name.name.chomp("\.") }
+ let(:committer_email) { 'user@example.org' }
+ let(:committer_name) { 'John Doe' }
describe 'committer_hash' do
it "returns a hash containing the given email and name" do
diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb
index f60c5ffb32a..6a89b007f96 100644
--- a/spec/mailers/notify_spec.rb
+++ b/spec/mailers/notify_spec.rb
@@ -37,7 +37,7 @@ describe Notify do
context 'for issues' do
let(:issue) { create(:issue, author: current_user, assignee: assignee, project: project) }
- let(:issue_with_description) { create(:issue, author: current_user, assignee: assignee, project: project, description: FFaker::Lorem.sentence) }
+ let(:issue_with_description) { create(:issue, author: current_user, assignee: assignee, project: project, description: 'My awesome description') }
describe 'that are new' do
subject { Notify.new_issue_email(issue.assignee_id, issue.id) }
@@ -187,7 +187,7 @@ describe Notify do
let(:project) { create(:project, :repository) }
let(:merge_author) { create(:user) }
let(:merge_request) { create(:merge_request, author: current_user, assignee: assignee, source_project: project, target_project: project) }
- let(:merge_request_with_description) { create(:merge_request, author: current_user, assignee: assignee, source_project: project, target_project: project, description: FFaker::Lorem.sentence) }
+ let(:merge_request_with_description) { create(:merge_request, author: current_user, assignee: assignee, source_project: project, target_project: project, description: 'My awesome description') }
describe 'that are new' do
subject { Notify.new_merge_request_email(merge_request.assignee_id, merge_request.id) }
diff --git a/spec/models/cycle_analytics/plan_spec.rb b/spec/models/cycle_analytics/plan_spec.rb
index 55483fc876a..4f33f3c6d69 100644
--- a/spec/models/cycle_analytics/plan_spec.rb
+++ b/spec/models/cycle_analytics/plan_spec.rb
@@ -13,7 +13,7 @@ describe 'CycleAnalytics#plan', feature: true do
data_fn: -> (context) do
{
issue: context.create(:issue, project: context.project),
- branch_name: context.random_git_name
+ branch_name: context.generate(:branch)
}
end,
start_time_conditions: [["issue associated with a milestone",
@@ -35,7 +35,7 @@ describe 'CycleAnalytics#plan', feature: true do
context "when a regular label (instead of a list label) is added to the issue" do
it "returns nil" do
- branch_name = random_git_name
+ branch_name = generate(:branch)
label = create(:label)
issue = create(:issue, project: project)
issue.update(label_ids: [label.id])
diff --git a/spec/models/cycle_analytics/production_spec.rb b/spec/models/cycle_analytics/production_spec.rb
index e6a826a9418..4744b9e05ea 100644
--- a/spec/models/cycle_analytics/production_spec.rb
+++ b/spec/models/cycle_analytics/production_spec.rb
@@ -23,7 +23,7 @@ describe 'CycleAnalytics#production', feature: true do
# Make other changes on master
sha = context.project.repository.create_file(
context.user,
- context.random_git_name,
+ context.generate(:branch),
'content',
message: 'commit message',
branch_name: 'master')
diff --git a/spec/models/cycle_analytics/staging_spec.rb b/spec/models/cycle_analytics/staging_spec.rb
index 3a02ed81adb..f78d7a23105 100644
--- a/spec/models/cycle_analytics/staging_spec.rb
+++ b/spec/models/cycle_analytics/staging_spec.rb
@@ -28,7 +28,7 @@ describe 'CycleAnalytics#staging', feature: true do
# Make other changes on master
sha = context.project.repository.create_file(
context.user,
- context.random_git_name,
+ context.generate(:branch),
'content',
message: 'commit message',
branch_name: 'master')
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index df742ee8084..5899e121e68 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -24,21 +24,8 @@ describe Repository, models: true do
repository.commit(merge_commit_id)
end
- let(:author_email) { FFaker::Internet.email }
-
- # I have to remove periods from the end of the name
- # This happened when the user's name had a suffix (i.e. "Sr.")
- # This seems to be what git does under the hood. For example, this commit:
- #
- # $ git commit --author='Foo Sr. <foo@example.com>' -m 'Where's my trailing period?'
- #
- # results in this:
- #
- # $ git show --pretty
- # ...
- # Author: Foo Sr <foo@example.com>
- # ...
- let(:author_name) { FFaker::Name.name.chomp("\.") }
+ let(:author_email) { 'user@example.org' }
+ let(:author_name) { 'John Doe' }
describe '#branch_names_contains' do
subject { repository.branch_names_contains(sample_commit.id) }
diff --git a/spec/requests/api/files_spec.rb b/spec/requests/api/files_spec.rb
index a7fad7f0bdb..8012530f139 100644
--- a/spec/requests/api/files_spec.rb
+++ b/spec/requests/api/files_spec.rb
@@ -11,21 +11,8 @@ describe API::Files, api: true do
ref: 'master'
}
end
- let(:author_email) { FFaker::Internet.email }
-
- # I have to remove periods from the end of the name
- # This happened when the user's name had a suffix (i.e. "Sr.")
- # This seems to be what git does under the hood. For example, this commit:
- #
- # $ git commit --author='Foo Sr. <foo@example.com>' -m 'Where's my trailing period?'
- #
- # results in this:
- #
- # $ git show --pretty
- # ...
- # Author: Foo Sr <foo@example.com>
- # ...
- let(:author_name) { FFaker::Name.name.chomp("\.") }
+ let(:author_email) { 'user@example.org' }
+ let(:author_name) { 'John Doe' }
before { project.team << [user, :developer] }
diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb
index a3de4702ad0..2e291eb3cea 100644
--- a/spec/requests/api/projects_spec.rb
+++ b/spec/requests/api/projects_spec.rb
@@ -341,7 +341,6 @@ describe API::Projects, :api do
it "assigns attributes to project" do
project = attributes_for(:project, {
path: 'camelCasePath',
- description: FFaker::Lorem.sentence,
issues_enabled: false,
merge_requests_enabled: false,
wiki_enabled: false,
@@ -475,7 +474,6 @@ describe API::Projects, :api do
it 'assigns attributes to project' do
project = attributes_for(:project, {
- description: FFaker::Lorem.sentence,
issues_enabled: false,
merge_requests_enabled: false,
wiki_enabled: false,
diff --git a/spec/requests/api/v3/files_spec.rb b/spec/requests/api/v3/files_spec.rb
index 3b61139a2cd..349fd6b3415 100644
--- a/spec/requests/api/v3/files_spec.rb
+++ b/spec/requests/api/v3/files_spec.rb
@@ -26,8 +26,8 @@ describe API::V3::Files, api: true do
ref: 'master'
}
end
- let(:author_email) { FFaker::Internet.email }
- let(:author_name) { FFaker::Name.name.chomp("\.") }
+ let(:author_email) { 'user@example.org' }
+ let(:author_name) { 'John Doe' }
before { project.team << [user, :developer] }
diff --git a/spec/requests/api/v3/projects_spec.rb b/spec/requests/api/v3/projects_spec.rb
index b1aa793ec00..40531fe7545 100644
--- a/spec/requests/api/v3/projects_spec.rb
+++ b/spec/requests/api/v3/projects_spec.rb
@@ -356,7 +356,6 @@ describe API::V3::Projects, api: true do
it "assigns attributes to project" do
project = attributes_for(:project, {
path: 'camelCasePath',
- description: FFaker::Lorem.sentence,
issues_enabled: false,
merge_requests_enabled: false,
wiki_enabled: false,
@@ -501,7 +500,6 @@ describe API::V3::Projects, api: true do
it 'assigns attributes to project' do
project = attributes_for(:project, {
- description: FFaker::Lorem.sentence,
issues_enabled: false,
merge_requests_enabled: false,
wiki_enabled: false,
diff --git a/spec/support/cycle_analytics_helpers.rb b/spec/support/cycle_analytics_helpers.rb
index c864a705ca4..37ee4d55769 100644
--- a/spec/support/cycle_analytics_helpers.rb
+++ b/spec/support/cycle_analytics_helpers.rb
@@ -1,15 +1,13 @@
module CycleAnalyticsHelpers
- def create_commit_referencing_issue(issue, branch_name: random_git_name)
- project.repository.add_branch(user, branch_name, 'master')
+ def create_commit_referencing_issue(issue, branch_name: nil)
+ project.repository.add_branch(user, branch_name || generate(:branch), 'master')
create_commit("Commit for ##{issue.iid}", issue.project, user, branch_name)
end
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/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 }