Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
cbc3d1f9
Commit
cbc3d1f9
authored
Jan 21, 2019
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[QA] Use public_email instead of email since it's available
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
cae2330b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
134 additions
and
4 deletions
+134
-4
qa/qa/resource/user.rb
qa/qa/resource/user.rb
+11
-3
qa/qa/runtime/user.rb
qa/qa/runtime/user.rb
+4
-0
qa/qa/specs/features/browser_ui/3_create/repository/user_views_raw_diff_patch_requests_spec.rb
...ate/repository/user_views_raw_diff_patch_requests_spec.rb
+1
-1
qa/spec/resource/user_spec.rb
qa/spec/resource/user_spec.rb
+118
-0
No files found.
qa/qa/resource/user.rb
View file @
cbc3d1f9
...
@@ -17,11 +17,11 @@ module QA
...
@@ -17,11 +17,11 @@ module QA
end
end
def
username
def
username
@username
||
=
"qa-user-
#{
unique_id
}
"
@username
||
"qa-user-
#{
unique_id
}
"
end
end
def
password
def
password
@password
||
=
'password'
@password
||
'password'
end
end
def
name
def
name
...
@@ -29,7 +29,15 @@ module QA
...
@@ -29,7 +29,15 @@ module QA
end
end
def
email
def
email
@email
||=
api_resource
&
.
dig
(
:email
)
||
"
#{
username
}
@example.com"
@email
||=
"
#{
username
}
@example.com"
end
def
public_email
@public_email
||=
begin
api_public_email
=
api_resource
&
.
dig
(
:public_email
)
api_public_email
&&
api_public_email
!=
''
?
api_public_email
:
Runtime
::
User
.
default_email
end
end
end
def
credentials_given?
def
credentials_given?
...
...
qa/qa/runtime/user.rb
View file @
cbc3d1f9
...
@@ -7,6 +7,10 @@ module QA
...
@@ -7,6 +7,10 @@ module QA
'root'
'root'
end
end
def
default_email
'admin@example.com'
end
def
default_password
def
default_password
'5iveL!fe'
'5iveL!fe'
end
end
...
...
qa/qa/specs/features/browser_ui/3_create/repository/user_views_raw_diff_patch_requests_spec.rb
View file @
cbc3d1f9
...
@@ -47,7 +47,7 @@ module QA
...
@@ -47,7 +47,7 @@ module QA
Page
::
Project
::
Commit
::
Show
.
perform
(
&
:select_email_patches
)
Page
::
Project
::
Commit
::
Show
.
perform
(
&
:select_email_patches
)
expect
(
page
).
to
have_content
(
"From:
#{
user
.
name
}
<
#{
user
.
email
}
>"
)
expect
(
page
).
to
have_content
(
"From:
#{
user
.
name
}
<
#{
user
.
public_
email
}
>"
)
expect
(
page
).
to
have_content
(
'Subject: [PATCH] Add second file'
)
expect
(
page
).
to
have_content
(
'Subject: [PATCH] Add second file'
)
expect
(
page
).
to
have_content
(
'diff --git a/second b/second'
)
expect
(
page
).
to
have_content
(
'diff --git a/second b/second'
)
end
end
...
...
qa/spec/resource/user_spec.rb
0 → 100644
View file @
cbc3d1f9
# frozen_string_literal: true
describe
QA
::
Resource
::
User
do
let
(
:api_resource
)
do
{
name:
"GitLab QA"
,
username:
"gitlab-qa"
,
web_url:
"https://staging.gitlab.com/gitlab-qa"
,
public_email:
"1614863-gitlab-qa@users.noreply.staging.gitlab.com"
}
end
describe
'#username'
do
it
'generates a default username'
do
expect
(
subject
.
username
).
to
match
(
/qa-user-\w+/
)
end
it
'is possible to set the username'
do
subject
.
username
=
'johndoe'
expect
(
subject
.
username
).
to
eq
(
'johndoe'
)
end
end
describe
'#password'
do
it
'generates a default password'
do
expect
(
subject
.
password
).
to
eq
(
'password'
)
end
it
'is possible to set the password'
do
subject
.
password
=
'secret'
expect
(
subject
.
password
).
to
eq
(
'secret'
)
end
end
describe
'#name'
do
it
'defaults to the username'
do
expect
(
subject
.
name
).
to
eq
(
subject
.
username
)
end
it
'retrieves the name from the api_resource if present'
do
subject
.
__send__
(
:api_resource
=
,
api_resource
)
expect
(
subject
.
name
).
to
eq
(
api_resource
[
:name
])
end
it
'is possible to set the name'
do
subject
.
name
=
'John Doe'
expect
(
subject
.
name
).
to
eq
(
'John Doe'
)
end
end
describe
'#email'
do
it
'defaults to the <username>@example.com'
do
expect
(
subject
.
email
).
to
eq
(
"
#{
subject
.
username
}
@example.com"
)
end
it
'is possible to set the email'
do
subject
.
email
=
'johndoe@example.org'
expect
(
subject
.
email
).
to
eq
(
'johndoe@example.org'
)
end
end
describe
'#public_email'
do
it
'defaults to QA::Runtime::User.default_email'
do
expect
(
subject
.
public_email
).
to
eq
(
QA
::
Runtime
::
User
.
default_email
)
end
it
'retrieves the public_email from the api_resource if present'
do
subject
.
__send__
(
:api_resource
=
,
api_resource
)
expect
(
subject
.
public_email
).
to
eq
(
api_resource
[
:public_email
])
end
it
'defaults to QA::Runtime::User.default_email if the public_email from the api_resource is blank'
do
subject
.
__send__
(
:api_resource
=
,
api_resource
.
merge
(
public_email:
''
))
expect
(
subject
.
public_email
).
to
eq
(
QA
::
Runtime
::
User
.
default_email
)
end
end
describe
'#credentials_given?'
do
it
'returns false when username and email have not been overridden'
do
expect
(
subject
).
not_to
be_credentials_given
end
it
'returns false even after username and email have been called'
do
# Call #username and #password to ensure this doesn't set their respective
# instance variable.
subject
.
username
subject
.
password
expect
(
subject
).
not_to
be_credentials_given
end
it
'returns false if only the username has been overridden'
do
subject
.
username
=
'johndoe'
expect
(
subject
).
not_to
be_credentials_given
end
it
'returns false if only the password has been overridden'
do
subject
.
password
=
'secret'
expect
(
subject
).
not_to
be_credentials_given
end
it
'returns true if both the username and password have been overridden'
do
subject
.
username
=
'johndoe'
subject
.
password
=
'secret'
expect
(
subject
).
to
be_credentials_given
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment