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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
c253718e
Commit
c253718e
authored
Sep 05, 2019
by
Desiree Chevalier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add group file template tests
Adds tests for group level file templates.
parent
bb0bef9a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
168 additions
and
3 deletions
+168
-3
ee/app/views/groups/_templates_setting.html.haml
ee/app/views/groups/_templates_setting.html.haml
+3
-3
qa/qa/ee/page/group/settings/general.rb
qa/qa/ee/page/group/settings/general.rb
+25
-0
qa/qa/page/component/select2.rb
qa/qa/page/component/select2.rb
+8
-0
qa/qa/page/file/shared/commit_button.rb
qa/qa/page/file/shared/commit_button.rb
+4
-0
qa/qa/specs/features/ee/browser_ui/1_manage/group/group_file_template_spec.rb
.../ee/browser_ui/1_manage/group/group_file_template_spec.rb
+128
-0
No files found.
ee/app/views/groups/_templates_setting.html.haml
View file @
c253718e
-
return
unless
@group
.
feature_available?
(
:custom_file_templates_for_namespace
)
%section
.settings.no-animate
#js-templates
{
class:
(
'expanded'
if
expanded
)
}
%section
.settings.no-animate
#js-templates
{
class:
(
'expanded'
if
expanded
)
,
data:
{
qa_selector:
'file_template_repositories'
}
}
.settings-header
%h4
=
_
(
'Templates'
)
...
...
@@ -18,6 +18,6 @@
.form-text.text-muted
=
_
(
'Select a template repository'
)
=
link_to
icon
(
'question-circle'
),
help_page_path
(
'user/group/index.md'
,
anchor:
'group-file-templates-premium'
),
target:
'_blank'
=
project_select_tag
(
'group[file_template_project_id]'
,
class:
'project-item-select hidden-filter-value'
,
toggle_class:
'js-project-search js-project-filter js-filter-submit'
,
dropdown_class:
'dropdown-menu-selectable dropdown-menu-project js-filter-submit'
,
=
project_select_tag
(
'group[file_template_project_id]'
,
class:
'project-item-select hidden-filter-value
qa-file-template-repository-dropdown
'
,
toggle_class:
'js-project-search js-project-filter js-filter-submit'
,
dropdown_class:
'dropdown-menu-selectable dropdown-menu-project js-filter-submit'
,
placeholder:
_
(
'Search projects'
),
idAttribute:
'id'
,
data:
{
order_by:
'last_activity_at'
,
idattribute:
'id'
,
simple_filter:
true
,
allow_clear:
true
},
value:
@group
.
checked_file_template_project_id
)
=
f
.
submit
_
(
'Save changes'
),
class:
"btn btn-success"
=
f
.
submit
_
(
'Save changes'
),
class:
"btn btn-success"
,
data:
{
qa_selector:
'save_changes_button'
}
qa/qa/ee/page/group/settings/general.rb
View file @
c253718e
...
...
@@ -28,6 +28,12 @@ module QA
view
'ee/app/views/shared/_repository_size_limit_setting.html.haml'
do
element
:repository_size_limit_field
end
view
'ee/app/views/groups/_templates_setting.html.haml'
do
element
:file_template_repository_dropdown
element
:file_template_repositories
element
:save_changes_button
end
end
end
...
...
@@ -72,6 +78,25 @@ module QA
def
set_repository_size_limit
(
limit
)
find_element
(
:repository_size_limit_field
).
set
limit
end
def
current_file_template_repository
expand_section
(
:file_template_repositories
)
within_element
(
:file_template_repository_dropdown
)
do
current_selection
end
end
def
choose_file_template_repository
(
path
)
expand_section
(
:file_template_repositories
)
within_element
(
:file_template_repository_dropdown
)
do
clear_current_selection_if_present
end
click_element
:file_template_repository_dropdown
search_and_select
(
path
)
click_element
:save_changes_button
end
end
end
end
...
...
qa/qa/page/component/select2.rb
View file @
c253718e
...
...
@@ -20,12 +20,20 @@ module QA
def
search_and_select
(
item_text
)
find
(
'.select2-input'
).
set
(
item_text
)
wait_for_search_to_complete
select_item
(
item_text
)
end
def
expand_select_list
find
(
'span.select2-arrow'
).
click
end
def
wait_for_search_to_complete
has_css?
(
'.select2-active'
)
has_no_css?
(
'.select2-active'
,
wait:
30
)
end
end
end
end
...
...
qa/qa/page/file/shared/commit_button.rb
View file @
c253718e
...
...
@@ -13,6 +13,10 @@ module QA
def
commit_changes
click_element
(
:commit_button
)
wait
(
reload:
false
,
max:
60
)
do
finished_loading?
end
end
end
end
...
...
qa/qa/specs/features/ee/browser_ui/1_manage/group/group_file_template_spec.rb
0 → 100644
View file @
c253718e
# frozen_string_literal: true
module
QA
context
'Manage'
do
describe
'Group file templates'
do
include
Support
::
Api
templates
=
[
{
type:
'Dockerfile'
,
template:
'custom_dockerfile'
,
name:
'Dockerfile/custom_dockerfile.dockerfile'
,
content:
'dockerfile template test'
},
{
type:
'.gitignore'
,
template:
'custom_gitignore'
,
name:
'gitignore/custom_gitignore.gitignore'
,
content:
'gitignore template test'
},
{
type:
'.gitlab-ci.yml'
,
template:
'custom_gitlab-ci'
,
name:
'gitlab-ci/custom_gitlab-ci.yml'
,
content:
'gitlab-ci template test'
},
{
type:
'LICENSE'
,
template:
'custom_license'
,
name:
'LICENSE/custom_license.txt'
,
content:
'license template test'
}
]
before
(
:all
)
do
login
@group
=
Resource
::
Group
.
fabricate_via_api!
do
|
group
|
group
.
path
=
'template-group'
end
@file_template_project
=
Resource
::
Project
.
fabricate_via_api!
do
|
project
|
project
.
group
=
@group
project
.
name
=
'group-file-template-project'
project
.
description
=
'Add group file templates'
project
.
initialize_with_readme
=
true
end
templates
.
each
do
|
template
|
Resource
::
File
.
fabricate_via_api!
do
|
file
|
file
.
project
=
@file_template_project
file
.
name
=
template
[
:name
]
file
.
content
=
template
[
:content
]
file
.
commit_message
=
'Add test file templates'
end
end
@project
=
Resource
::
Project
.
fabricate_via_api!
do
|
project
|
project
.
group
=
@group
project
.
name
=
'group-file-template-project-2'
project
.
description
=
'Add files for group file templates'
project
.
initialize_with_readme
=
true
end
Page
::
Main
::
Menu
.
perform
(
&
:sign_out
)
end
after
(
:all
)
do
login
unless
Page
::
Main
::
Menu
.
perform
{
|
p
|
p
.
has_personal_area?
(
wait:
0
)
}
remove_group_file_template_if_set
end
templates
.
each
do
|
template
|
it
"creates file via custom
#{
template
[
:type
]
}
file template"
do
login
set_file_template_if_not_already_set
@project
.
visit!
Page
::
Project
::
Show
.
perform
(
&
:create_new_file!
)
Page
::
File
::
Form
.
perform
do
|
form
|
form
.
select_template
template
[
:type
],
template
[
:template
]
end
expect
(
page
).
to
have_content
(
template
[
:content
])
Page
::
File
::
Form
.
perform
(
&
:commit_changes
)
expect
(
page
).
to
have_content
(
'The file has been successfully created.'
)
expect
(
page
).
to
have_content
(
template
[
:type
])
expect
(
page
).
to
have_content
(
'Add new file'
)
expect
(
page
).
to
have_content
(
template
[
:content
])
end
end
def
login
Runtime
::
Browser
.
visit
(
:gitlab
,
Page
::
Main
::
Login
)
Page
::
Main
::
Login
.
perform
(
&
:sign_in_using_admin_credentials
)
end
def
set_file_template_if_not_already_set
api_client
=
Runtime
::
API
::
Client
.
new
(
:gitlab
)
response
=
get
Runtime
::
API
::
Request
.
new
(
api_client
,
"/groups/
#{
@group
.
id
}
"
).
url
if
parse_body
(
response
)[
:file_template_project_id
]
return
else
@group
.
visit!
Page
::
Group
::
Menu
.
perform
(
&
:click_group_general_settings_item
)
Page
::
Group
::
Settings
::
General
.
perform
do
|
general
|
general
.
choose_file_template_repository
(
@file_template_project
.
name
)
end
end
end
def
remove_group_file_template_if_set
api_client
=
Runtime
::
API
::
Client
.
new
(
:gitlab
)
response
=
get
Runtime
::
API
::
Request
.
new
(
api_client
,
"/groups/
#{
@group
.
id
}
"
).
url
if
parse_body
(
response
)[
:file_template_project_id
]
put
Runtime
::
API
::
Request
.
new
(
api_client
,
"/groups/
#{
@group
.
id
}
"
).
url
,
{
file_template_project_id:
nil
}
end
end
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