summaryrefslogtreecommitdiff
path: root/spec/features
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/features
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/features')
-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
5 files changed, 16 insertions, 18 deletions
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