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
Jérome Perrin
gitlab-ce
Commits
ab46353f
Commit
ab46353f
authored
Mar 31, 2017
by
James Edwards-Jones
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added ProtectedTags#show page
Uncommented protected tags feature specs copied from protected branches
parent
e3fbcd00
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
167 additions
and
172 deletions
+167
-172
app/views/projects/protected_tags/_matching_tag.html.haml
app/views/projects/protected_tags/_matching_tag.html.haml
+9
-0
app/views/projects/protected_tags/show.html.haml
app/views/projects/protected_tags/show.html.haml
+25
-0
spec/features/protected_tags/access_control_ce_spec.rb
spec/features/protected_tags/access_control_ce_spec.rb
+39
-78
spec/features/protected_tags_spec.rb
spec/features/protected_tags_spec.rb
+94
-94
No files found.
app/views/projects/protected_tags/_matching_tag.html.haml
0 → 100644
View file @
ab46353f
%tr
%td
=
link_to
matching_tag
.
name
,
namespace_project_tree_path
(
@project
.
namespace
,
@project
,
matching_tag
.
name
)
-
if
@project
.
root_ref?
(
matching_tag
.
name
)
%span
.label.label-info.prepend-left-5
default
%td
-
commit
=
@project
.
commit
(
matching_tag
.
name
)
=
link_to
(
commit
.
short_id
,
namespace_project_commit_path
(
@project
.
namespace
,
@project
,
commit
.
id
),
class:
'commit_short_id'
)
=
time_ago_with_tooltip
(
commit
.
committed_date
)
app/views/projects/protected_tags/show.html.haml
0 → 100644
View file @
ab46353f
-
page_title
@protected_tag
.
name
,
"Protected Tags"
.row.prepend-top-default.append-bottom-default
.col-lg-3
%h4
.prepend-top-0
=
@protected_tag
.
name
.col-lg-9
%h5
Matching Tags
-
if
@matching_tags
.
present?
.table-responsive
%table
.table.protected-tags-list
%colgroup
%col
{
width:
"30%"
}
%col
{
width:
"30%"
}
%thead
%tr
%th
Tag
%th
Last commit
%tbody
-
@matching_tags
.
each
do
|
matching_tag
|
=
render
partial:
"matching_tag"
,
object:
matching_tag
-
else
%p
.settings-message.text-center
Couldn't find any matching tags.
spec/features/protected_tags/access_control_ce_spec.rb
View file @
ab46353f
# RSpec.shared_examples "protected tags > access control > CE" do
# ProtectedTag::PushAccessLevel.human_access_levels.each do |(access_type_id, access_type_name)|
# it "allows creating protected tags that #{access_type_name} can push to" do
# visit namespace_project_protected_tags_path(project.namespace, project)
# set_protected_tag_name('master')
# within('.new_protected_tag') do
# allowed_to_push_button = find(".js-allowed-to-push")
# unless allowed_to_push_button.text == access_type_name
# allowed_to_push_button.click
# within(".dropdown.open .dropdown-menu") { click_on access_type_name }
# end
# end
# click_on "Protect"
# expect(ProtectedTag.count).to eq(1)
# expect(ProtectedTag.last.push_access_levels.map(&:access_level)).to eq([access_type_id])
# end
# it "allows updating protected tags so that #{access_type_name} can push to them" do
# visit namespace_project_protected_tags_path(project.namespace, project)
# set_protected_tag_name('master')
# click_on "Protect"
# expect(ProtectedTag.count).to eq(1)
# within(".protected-tags-list") do
# find(".js-allowed-to-push").click
# within('.js-allowed-to-push-container') do
# expect(first("li")).to have_content("Roles")
# click_on access_type_name
# end
# end
# wait_for_ajax
# expect(ProtectedTag.last.push_access_levels.map(&:access_level)).to include(access_type_id)
# end
# end
# ProtectedTag::MergeAccessLevel.human_access_levels.each do |(access_type_id, access_type_name)|
# it "allows creating protected tags that #{access_type_name} can merge to" do
# visit namespace_project_protected_tags_path(project.namespace, project)
# set_protected_tag_name('master')
# within('.new_protected_tag') do
# allowed_to_merge_button = find(".js-allowed-to-merge")
# unless allowed_to_merge_button.text == access_type_name
# allowed_to_merge_button.click
# within(".dropdown.open .dropdown-menu") { click_on access_type_name }
# end
# end
# click_on "Protect"
# expect(ProtectedTag.count).to eq(1)
# expect(ProtectedTag.last.merge_access_levels.map(&:access_level)).to eq([access_type_id])
# end
# it "allows updating protected tags so that #{access_type_name} can merge to them" do
# visit namespace_project_protected_tags_path(project.namespace, project)
# set_protected_tag_name('master')
# click_on "Protect"
# expect(ProtectedTag.count).to eq(1)
# within(".protected-tags-list") do
# find(".js-allowed-to-merge").click
# within('.js-allowed-to-merge-container') do
# expect(first("li")).to have_content("Roles")
# click_on access_type_name
# end
# end
# wait_for_ajax
# expect(ProtectedTag.last.merge_access_levels.map(&:access_level)).to include(access_type_id)
# end
# end
# end
RSpec
.
shared_examples
"protected tags > access control > CE"
do
ProtectedTag
::
PushAccessLevel
.
human_access_levels
.
each
do
|
(
access_type_id
,
access_type_name
)
|
it
"allows creating protected tags that
#{
access_type_name
}
can push to"
do
visit
namespace_project_protected_tags_path
(
project
.
namespace
,
project
)
set_protected_tag_name
(
'master'
)
within
(
'.new_protected_tag'
)
do
allowed_to_push_button
=
find
(
".js-allowed-to-push"
)
unless
allowed_to_push_button
.
text
==
access_type_name
allowed_to_push_button
.
click
within
(
".dropdown.open .dropdown-menu"
)
{
click_on
access_type_name
}
end
end
click_on
"Protect"
expect
(
ProtectedTag
.
count
).
to
eq
(
1
)
expect
(
ProtectedTag
.
last
.
push_access_levels
.
map
(
&
:access_level
)).
to
eq
([
access_type_id
])
end
it
"allows updating protected tags so that
#{
access_type_name
}
can push to them"
do
visit
namespace_project_protected_tags_path
(
project
.
namespace
,
project
)
set_protected_tag_name
(
'master'
)
click_on
"Protect"
expect
(
ProtectedTag
.
count
).
to
eq
(
1
)
within
(
".protected-tags-list"
)
do
find
(
".js-allowed-to-push"
).
click
within
(
'.js-allowed-to-push-container'
)
do
expect
(
first
(
"li"
)).
to
have_content
(
"Roles"
)
click_on
access_type_name
end
end
wait_for_ajax
expect
(
ProtectedTag
.
last
.
push_access_levels
.
map
(
&
:access_level
)).
to
include
(
access_type_id
)
end
end
end
spec/features/protected_tags_spec.rb
View file @
ab46353f
#
require 'spec_helper'
#
Dir["./spec/features/protected_tags/*.rb"].sort.each { |f| require f }
#
feature 'Projected Tags', feature: true, js: true do
#
include WaitForAjax
#
let(:user) { create(:user, :admin) }
#
let(:project) { create(:project) }
#
before { login_as(user) }
#
def set_protected_tag_name(tag_name)
#
find(".js-protected-tag-select").click
#
find(".dropdown-input-field").set(tag_name)
#
click_on("Create wildcard #{tag_name}")
#
end
#
describe "explicit protected tags" do
#
it "allows creating explicit protected tags" do
#
visit namespace_project_protected_tags_path(project.namespace, project)
#
set_protected_tag_name('some-tag')
#
click_on "Protect"
#
within(".protected-tags-list") { expect(page).to have_content('some-tag') }
#
expect(ProtectedTag.count).to eq(1)
#
expect(ProtectedTag.last.name).to eq('some-tag')
#
end
#
it "displays the last commit on the matching tag if it exists" do
#
commit = create(:commit, project: project)
#
project.repository.add_tag(user, 'some-tag', commit.id)
#
visit namespace_project_protected_tags_path(project.namespace, project)
#
set_protected_tag_name('some-tag')
#
click_on "Protect"
#
within(".protected-tags-list") { expect(page).to have_content(commit.id[0..7]) }
#
end
#
it "displays an error message if the named tag does not exist" do
#
visit namespace_project_protected_tags_path(project.namespace, project)
#
set_protected_tag_name('some-tag')
#
click_on "Protect"
#
within(".protected-tags-list") { expect(page).to have_content('tag was removed') }
#
end
#
end
#
describe "wildcard protected tags" do
#
it "allows creating protected tags with a wildcard" do
#
visit namespace_project_protected_tags_path(project.namespace, project)
#
set_protected_tag_name('*-stable')
#
click_on "Protect"
#
within(".protected-tags-list") { expect(page).to have_content('*-stable') }
#
expect(ProtectedTag.count).to eq(1)
#
expect(ProtectedTag.last.name).to eq('*-stable')
#
end
#
it "displays the number of matching tags" do
#
project.repository.add_tag(user, 'production-stable', 'master')
#
project.repository.add_tag(user, 'staging-stable', 'master')
#
visit namespace_project_protected_tags_path(project.namespace, project)
#
set_protected_tag_name('*-stable')
#
click_on "Protect"
#
within(".protected-tags-list") { expect(page).to have_content("2 matching tags") }
#
end
#
it "displays all the tags matching the wildcard" do
#
project.repository.add_tag(user, 'production-stable', 'master')
#
project.repository.add_tag(user, 'staging-stable', 'master')
#
project.repository.add_tag(user, 'development', 'master')
#
visit namespace_project_protected_tags_path(project.namespace, project)
#
set_protected_tag_name('*-stable')
#
click_on "Protect"
#
visit namespace_project_protected_tags_path(project.namespace, project)
#
click_on "2 matching tags"
#
within(".protected-tags-list") do
#
expect(page).to have_content("production-stable")
#
expect(page).to have_content("staging-stable")
#
expect(page).not_to have_content("development")
#
end
#
end
#
end
#
describe "access control" do
#
include_examples "protected tags > access control > CE"
#
end
#
end
require
'spec_helper'
Dir
[
"./spec/features/protected_tags/*.rb"
].
sort
.
each
{
|
f
|
require
f
}
feature
'Projected Tags'
,
feature:
true
,
js:
true
do
include
WaitForAjax
let
(
:user
)
{
create
(
:user
,
:admin
)
}
let
(
:project
)
{
create
(
:project
)
}
before
{
login_as
(
user
)
}
def
set_protected_tag_name
(
tag_name
)
find
(
".js-protected-tag-select"
).
click
find
(
".dropdown-input-field"
).
set
(
tag_name
)
click_on
(
"Create wildcard
#{
tag_name
}
"
)
end
describe
"explicit protected tags"
do
it
"allows creating explicit protected tags"
do
visit
namespace_project_protected_tags_path
(
project
.
namespace
,
project
)
set_protected_tag_name
(
'some-tag'
)
click_on
"Protect"
within
(
".protected-tags-list"
)
{
expect
(
page
).
to
have_content
(
'some-tag'
)
}
expect
(
ProtectedTag
.
count
).
to
eq
(
1
)
expect
(
ProtectedTag
.
last
.
name
).
to
eq
(
'some-tag'
)
end
it
"displays the last commit on the matching tag if it exists"
do
commit
=
create
(
:commit
,
project:
project
)
project
.
repository
.
add_tag
(
user
,
'some-tag'
,
commit
.
id
)
visit
namespace_project_protected_tags_path
(
project
.
namespace
,
project
)
set_protected_tag_name
(
'some-tag'
)
click_on
"Protect"
within
(
".protected-tags-list"
)
{
expect
(
page
).
to
have_content
(
commit
.
id
[
0
..
7
])
}
end
it
"displays an error message if the named tag does not exist"
do
visit
namespace_project_protected_tags_path
(
project
.
namespace
,
project
)
set_protected_tag_name
(
'some-tag'
)
click_on
"Protect"
within
(
".protected-tags-list"
)
{
expect
(
page
).
to
have_content
(
'tag was removed'
)
}
end
end
describe
"wildcard protected tags"
do
it
"allows creating protected tags with a wildcard"
do
visit
namespace_project_protected_tags_path
(
project
.
namespace
,
project
)
set_protected_tag_name
(
'*-stable'
)
click_on
"Protect"
within
(
".protected-tags-list"
)
{
expect
(
page
).
to
have_content
(
'*-stable'
)
}
expect
(
ProtectedTag
.
count
).
to
eq
(
1
)
expect
(
ProtectedTag
.
last
.
name
).
to
eq
(
'*-stable'
)
end
it
"displays the number of matching tags"
do
project
.
repository
.
add_tag
(
user
,
'production-stable'
,
'master'
)
project
.
repository
.
add_tag
(
user
,
'staging-stable'
,
'master'
)
visit
namespace_project_protected_tags_path
(
project
.
namespace
,
project
)
set_protected_tag_name
(
'*-stable'
)
click_on
"Protect"
within
(
".protected-tags-list"
)
{
expect
(
page
).
to
have_content
(
"2 matching tags"
)
}
end
it
"displays all the tags matching the wildcard"
do
project
.
repository
.
add_tag
(
user
,
'production-stable'
,
'master'
)
project
.
repository
.
add_tag
(
user
,
'staging-stable'
,
'master'
)
project
.
repository
.
add_tag
(
user
,
'development'
,
'master'
)
visit
namespace_project_protected_tags_path
(
project
.
namespace
,
project
)
set_protected_tag_name
(
'*-stable'
)
click_on
"Protect"
visit
namespace_project_protected_tags_path
(
project
.
namespace
,
project
)
click_on
"2 matching tags"
within
(
".protected-tags-list"
)
do
expect
(
page
).
to
have_content
(
"production-stable"
)
expect
(
page
).
to
have_content
(
"staging-stable"
)
expect
(
page
).
not_to
have_content
(
"development"
)
end
end
end
describe
"access control"
do
include_examples
"protected tags > access control > CE"
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