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
d7cbeda5
Commit
d7cbeda5
authored
May 27, 2019
by
Mark Lapierre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fabricate a file via the API
parent
e59c3f8e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
15 deletions
+42
-15
qa/qa/resource/file.rb
qa/qa/resource/file.rb
+29
-2
qa/qa/specs/features/browser_ui/3_create/repository/user_views_commit_diff_patch_spec.rb
.../3_create/repository/user_views_commit_diff_patch_spec.rb
+13
-13
No files found.
qa/qa/resource/file.rb
View file @
d7cbeda5
...
...
@@ -3,9 +3,12 @@
module
QA
module
Resource
class
File
<
Base
attr_accessor
:name
,
attr_accessor
:author_email
,
:author_name
,
:branch
,
:content
,
:commit_message
:commit_message
,
:name
attribute
:project
do
Project
.
fabricate!
do
|
resource
|
...
...
@@ -31,6 +34,30 @@ module QA
page
.
commit_changes
end
end
def
resource_web_url
(
resource
)
super
rescue
ResourceURLMissingError
# this particular resource does not expose a web_url property
end
def
api_get_path
"/projects/
#{
CGI
.
escape
(
project
.
path_with_namespace
)
}
/repository/files/
#{
CGI
.
escape
(
@name
)
}
"
end
def
api_post_path
api_get_path
end
def
api_post_body
{
branch:
@branch
||
"master"
,
author_email:
@author_email
||
Runtime
::
User
.
default_email
,
author_name:
@author_name
||
Runtime
::
User
.
username
,
content:
content
,
commit_message:
commit_message
}
end
end
end
end
qa/qa/specs/features/browser_ui/3_create/repository/user_views_commit_diff_patch_spec.rb
View file @
d7cbeda5
...
...
@@ -3,13 +3,16 @@
module
QA
context
'Create'
do
# failure reported: https://gitlab.com/gitlab-org/quality/nightly/issues/42
# also failing in staging until the fix is picked into the next release:
# https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/24533
describe
'Commit data'
,
:quarantine
do
before
(
:context
)
do
Runtime
::
Browser
.
visit
(
:gitlab
,
Page
::
Main
::
Login
)
Page
::
Main
::
Login
.
perform
(
&
:sign_in_using_credentials
)
# Get the user's details to confirm they're included in the email patch
@user
=
Resource
::
User
.
fabricate_via_api!
do
|
user
|
user
.
username
=
Runtime
::
User
.
username
end
project_push
=
Resource
::
Repository
::
ProjectPush
.
fabricate!
do
|
push
|
push
.
file_name
=
'README.md'
push
.
file_content
=
'# This is a test project'
...
...
@@ -21,12 +24,13 @@ module QA
# add second file to repo to enable diff from initial commit
@commit_message
=
'Add second file'
Page
::
Project
::
Show
.
perform
(
&
:create_new_file!
)
Page
::
File
::
Form
.
perform
do
|
f
|
f
.
add_name
(
'second'
)
f
.
add_content
(
'second file content'
)
f
.
add_commit_message
(
@commit_message
)
f
.
commit_changes
Resource
::
File
.
fabricate_via_api!
do
|
file
|
file
.
project
=
@project
file
.
name
=
'second'
file
.
content
=
'second file content'
file
.
commit_message
=
@commit_message
file
.
author_name
=
@user
.
name
file
.
author_email
=
@user
.
public_email
end
end
...
...
@@ -42,15 +46,11 @@ module QA
end
it
'user views raw email patch'
do
user
=
Resource
::
User
.
fabricate_via_api!
do
|
user
|
user
.
username
=
Runtime
::
User
.
username
end
view_commit
Page
::
Project
::
Commit
::
Show
.
perform
(
&
:select_email_patches
)
expect
(
page
).
to
have_content
(
"From:
#{
user
.
name
}
<
#{
user
.
public_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
(
'diff --git a/second b/second'
)
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