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
c4c80ec4
Commit
c4c80ec4
authored
Mar 23, 2021
by
Peter Leitzen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve performance of groups helper spec
This commit also fixes _some_ RuboCop rules.
parent
38081550
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
41 deletions
+41
-41
spec/helpers/groups_helper_spec.rb
spec/helpers/groups_helper_spec.rb
+41
-41
No files found.
spec/helpers/groups_helper_spec.rb
View file @
c4c80ec4
...
@@ -5,33 +5,31 @@ require 'spec_helper'
...
@@ -5,33 +5,31 @@ require 'spec_helper'
RSpec
.
describe
GroupsHelper
do
RSpec
.
describe
GroupsHelper
do
include
ApplicationHelper
include
ApplicationHelper
describe
'group_icon_url'
do
describe
'
#
group_icon_url'
do
it
'returns an url for the avatar'
do
it
'returns an url for the avatar'
do
avatar_file_path
=
File
.
join
(
'spec'
,
'fixtures'
,
'banana_sample.gif'
)
group
=
create
(
:group
,
:with_avatar
)
group
=
create
(
:group
)
expect
(
group_icon_url
(
group
.
path
).
to_s
).
to
match
(
group
.
avatar
.
url
)
group
.
avatar
=
fixture_file_upload
(
avatar_file_path
)
group
.
save!
expect
(
group_icon_url
(
group
.
path
).
to_s
)
.
to
match
(
group
.
avatar
.
url
)
end
end
it
'gives default avatar_icon when no avatar is present'
do
it
'gives default avatar_icon when no avatar is present'
do
group
=
create
(
:group
)
group
=
build_stubbed
(
:group
)
expect
(
group_icon_url
(
group
.
path
)).
to
match_asset_path
(
'group_avatar.png'
)
expect
(
group_icon_url
(
group
.
path
)).
to
match_asset_path
(
'group_avatar.png'
)
end
end
end
end
describe
'group_dependency_proxy_url'
do
describe
'
#
group_dependency_proxy_url'
do
it
'converts uppercase letters to lowercase'
do
it
'converts uppercase letters to lowercase'
do
group
=
create
(
:group
,
path:
'GroupWithUPPERcaseLetters'
)
group
=
build_stubbed
(
:group
,
path:
'GroupWithUPPERcaseLetters'
)
expect
(
group_dependency_proxy_url
(
group
)).
to
end_with
(
"/groupwithuppercaseletters
#{
DependencyProxy
::
URL_SUFFIX
}
"
)
expect
(
group_dependency_proxy_url
(
group
)).
to
end_with
(
"/groupwithuppercaseletters
#{
DependencyProxy
::
URL_SUFFIX
}
"
)
end
end
end
end
describe
'group_lfs_status'
do
describe
'
#
group_lfs_status'
do
let
(
:group
)
{
create
(
:group
)
}
let
_it_be_with_reload
(
:group
)
{
create
(
:group
)
}
let
!
(
:project
)
{
create
(
:project
,
namespace_id:
group
.
id
)
}
let
_it_be_with_reload
(
:project
)
{
create
(
:project
,
namespace_id:
group
.
id
)
}
before
do
before
do
allow
(
Gitlab
.
config
.
lfs
).
to
receive
(
:enabled
).
and_return
(
true
)
allow
(
Gitlab
.
config
.
lfs
).
to
receive
(
:enabled
).
and_return
(
true
)
...
@@ -54,9 +52,7 @@ RSpec.describe GroupsHelper do
...
@@ -54,9 +52,7 @@ RSpec.describe GroupsHelper do
end
end
context
'more than one project in group'
do
context
'more than one project in group'
do
before
do
let_it_be_with_reload
(
:another_project
)
{
create
(
:project
,
namespace_id:
group
.
id
)
}
create
(
:project
,
namespace_id:
group
.
id
)
end
context
'LFS enabled in group'
do
context
'LFS enabled in group'
do
before
do
before
do
...
@@ -92,7 +88,7 @@ RSpec.describe GroupsHelper do
...
@@ -92,7 +88,7 @@ RSpec.describe GroupsHelper do
end
end
end
end
describe
'group_title'
do
describe
'
#
group_title'
do
let_it_be
(
:group
)
{
create
(
:group
)
}
let_it_be
(
:group
)
{
create
(
:group
)
}
let_it_be
(
:nested_group
)
{
create
(
:group
,
parent:
group
)
}
let_it_be
(
:nested_group
)
{
create
(
:group
,
parent:
group
)
}
let_it_be
(
:deep_nested_group
)
{
create
(
:group
,
parent:
nested_group
)
}
let_it_be
(
:deep_nested_group
)
{
create
(
:group
,
parent:
nested_group
)
}
...
@@ -115,14 +111,14 @@ RSpec.describe GroupsHelper do
...
@@ -115,14 +111,14 @@ RSpec.describe GroupsHelper do
end
end
end
end
# rubocop:disable Layout/SpaceBeforeComma
describe
'#share_with_group_lock_help_text'
do
describe
'#share_with_group_lock_help_text'
do
let!
(
:root_group
)
{
create
(
:group
)
}
let_it_be_with_reload
(
:root_group
)
{
create
(
:group
)
}
let!
(
:subgroup
)
{
create
(
:group
,
parent:
root_group
)
}
let_it_be_with_reload
(
:subgroup
)
{
create
(
:group
,
parent:
root_group
)
}
let!
(
:sub_subgroup
)
{
create
(
:group
,
parent:
subgroup
)
}
let_it_be_with_reload
(
:sub_subgroup
)
{
create
(
:group
,
parent:
subgroup
)
}
let
(
:root_owner
)
{
create
(
:user
)
}
let_it_be
(
:root_owner
)
{
create
(
:user
)
}
let
(
:sub_owner
)
{
create
(
:user
)
}
let_it_be
(
:sub_owner
)
{
create
(
:user
)
}
let
(
:sub_sub_owner
)
{
create
(
:user
)
}
let_it_be
(
:sub_sub_owner
)
{
create
(
:user
)
}
let
(
:possible_help_texts
)
do
let
(
:possible_help_texts
)
do
{
{
default_help:
"This setting will be applied to all subgroups unless overridden by a group owner"
,
default_help:
"This setting will be applied to all subgroups unless overridden by a group owner"
,
...
@@ -149,6 +145,13 @@ RSpec.describe GroupsHelper do
...
@@ -149,6 +145,13 @@ RSpec.describe GroupsHelper do
subject
{
helper
.
share_with_group_lock_help_text
(
sub_subgroup
)
}
subject
{
helper
.
share_with_group_lock_help_text
(
sub_subgroup
)
}
before_all
do
root_group
.
add_owner
(
root_owner
)
subgroup
.
add_owner
(
sub_owner
)
sub_subgroup
.
add_owner
(
sub_sub_owner
)
end
# rubocop:disable Layout/SpaceBeforeComma
where
(
:root_share_with_group_locked
,
:subgroup_share_with_group_locked
,
:sub_subgroup_share_with_group_locked
,
:current_user
,
:help_text
,
:linked_ancestor
)
do
where
(
:root_share_with_group_locked
,
:subgroup_share_with_group_locked
,
:sub_subgroup_share_with_group_locked
,
:current_user
,
:help_text
,
:linked_ancestor
)
do
[
[
[
false
,
false
,
false
,
:root_owner
,
:default_help
,
nil
],
[
false
,
false
,
false
,
:root_owner
,
:default_help
,
nil
],
...
@@ -177,13 +180,10 @@ RSpec.describe GroupsHelper do
...
@@ -177,13 +180,10 @@ RSpec.describe GroupsHelper do
[
true
,
true
,
true
,
:sub_sub_owner
,
:ancestor_locked_so_ask_the_owner
,
:root_group
]
[
true
,
true
,
true
,
:sub_sub_owner
,
:ancestor_locked_so_ask_the_owner
,
:root_group
]
]
]
end
end
# rubocop:enable Layout/SpaceBeforeComma
with_them
do
with_them
do
before
do
before
do
root_group
.
add_owner
(
root_owner
)
subgroup
.
add_owner
(
sub_owner
)
sub_subgroup
.
add_owner
(
sub_sub_owner
)
root_group
.
update_column
(
:share_with_group_lock
,
true
)
if
root_share_with_group_locked
root_group
.
update_column
(
:share_with_group_lock
,
true
)
if
root_share_with_group_locked
subgroup
.
update_column
(
:share_with_group_lock
,
true
)
if
subgroup_share_with_group_locked
subgroup
.
update_column
(
:share_with_group_lock
,
true
)
if
subgroup_share_with_group_locked
sub_subgroup
.
update_column
(
:share_with_group_lock
,
true
)
if
sub_subgroup_share_with_group_locked
sub_subgroup
.
update_column
(
:share_with_group_lock
,
true
)
if
sub_subgroup_share_with_group_locked
...
@@ -212,8 +212,8 @@ RSpec.describe GroupsHelper do
...
@@ -212,8 +212,8 @@ RSpec.describe GroupsHelper do
end
end
describe
'#group_container_registry_nav'
do
describe
'#group_container_registry_nav'
do
let
(
:group
)
{
create
(
:group
,
:public
)
}
let
_it_be
(
:group
)
{
create
(
:group
,
:public
)
}
let
(
:user
)
{
create
(
:user
)
}
let
_it_be
(
:user
)
{
create
(
:user
)
}
before
do
before
do
stub_container_registry_config
(
enabled:
true
)
stub_container_registry_config
(
enabled:
true
)
...
@@ -248,8 +248,8 @@ RSpec.describe GroupsHelper do
...
@@ -248,8 +248,8 @@ RSpec.describe GroupsHelper do
end
end
describe
'#group_sidebar_links'
do
describe
'#group_sidebar_links'
do
let
(
:group
)
{
create
(
:group
,
:public
)
}
let
_it_be
(
:group
)
{
create
(
:group
,
:public
)
}
let
(
:user
)
{
create
(
:user
)
}
let
_it_be
(
:user
)
{
create
(
:user
)
}
before
do
before
do
group
.
add_owner
(
user
)
group
.
add_owner
(
user
)
...
@@ -287,10 +287,10 @@ RSpec.describe GroupsHelper do
...
@@ -287,10 +287,10 @@ RSpec.describe GroupsHelper do
end
end
end
end
describe
'parent_group_options'
do
describe
'
#
parent_group_options'
do
let
(
:current_user
)
{
create
(
:user
)
}
let
_it_be
(
:current_user
)
{
create
(
:user
)
}
let
(
:group
)
{
create
(
:group
,
name:
'group'
)
}
let
_it_be
(
:group
)
{
create
(
:group
,
name:
'group'
)
}
let
(
:group2
)
{
create
(
:group
,
name:
'group2'
)
}
let
_it_be
(
:group2
)
{
create
(
:group
,
name:
'group2'
)
}
before
do
before
do
group
.
add_owner
(
current_user
)
group
.
add_owner
(
current_user
)
...
@@ -321,9 +321,9 @@ RSpec.describe GroupsHelper do
...
@@ -321,9 +321,9 @@ RSpec.describe GroupsHelper do
end
end
describe
'#can_disable_group_emails?'
do
describe
'#can_disable_group_emails?'
do
let
(
:current_user
)
{
create
(
:user
)
}
let
_it_be
(
:current_user
)
{
create
(
:user
)
}
let
(
:group
)
{
create
(
:group
,
name:
'group'
)
}
let
_it_be
(
:group
)
{
create
(
:group
,
name:
'group'
)
}
let
(
:subgroup
)
{
create
(
:group
,
name:
'subgroup'
,
parent:
group
)
}
let
_it_be
(
:subgroup
)
{
create
(
:group
,
name:
'subgroup'
,
parent:
group
)
}
before
do
before
do
allow
(
helper
).
to
receive
(
:current_user
)
{
current_user
}
allow
(
helper
).
to
receive
(
:current_user
)
{
current_user
}
...
@@ -361,8 +361,8 @@ RSpec.describe GroupsHelper do
...
@@ -361,8 +361,8 @@ RSpec.describe GroupsHelper do
end
end
describe
'#can_update_default_branch_protection?'
do
describe
'#can_update_default_branch_protection?'
do
let
(
:current_user
)
{
create
(
:user
)
}
let
_it_be
(
:current_user
)
{
create
(
:user
)
}
let
(
:group
)
{
create
(
:group
)
}
let
_it_be
(
:group
)
{
create
(
:group
)
}
subject
{
helper
.
can_update_default_branch_protection?
(
group
)
}
subject
{
helper
.
can_update_default_branch_protection?
(
group
)
}
...
...
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