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
39a9fe28
Commit
39a9fe28
authored
May 10, 2021
by
peterhegman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move specs for private methods into specs for public methods
Per reviewer feedback
parent
443fb94f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
58 deletions
+38
-58
spec/helpers/groups/group_members_helper_spec.rb
spec/helpers/groups/group_members_helper_spec.rb
+30
-44
spec/helpers/projects/project_members_helper_spec.rb
spec/helpers/projects/project_members_helper_spec.rb
+8
-14
No files found.
spec/helpers/groups/group_members_helper_spec.rb
View file @
39a9fe28
...
@@ -23,76 +23,59 @@ RSpec.describe Groups::GroupMembersHelper do
...
@@ -23,76 +23,59 @@ RSpec.describe Groups::GroupMembersHelper do
end
end
end
end
describe
'#group_
group_links_serialized
'
do
describe
'#group_
members_list_data_json
'
do
include_context
'group_group_link'
let
(
:group_members
)
{
create_list
(
:group_member
,
2
,
group:
group
,
created_by:
current_user
)
}
it
'matches json schema'
do
let
(
:pagination
)
{
{}
}
json
=
helper
.
send
(
:group_group_links_serialized
,
shared_group
.
shared_with_group_links
).
to_json
let
(
:collection
)
{
group_members
}
let
(
:presented_members
)
{
present_members
(
collection
)
}
expect
(
json
).
to
match_schema
(
'group_link/group_group_links'
)
subject
{
Gitlab
::
Json
.
parse
(
helper
.
group_members_list_data_json
(
group
,
presented_members
,
pagination
))
}
end
end
describe
'#group_members_serialized'
do
shared_examples
'members.json'
do
shared_examples
'members.json'
do
it
'matches json schema'
do
it
'returns `members` property that matches json schema'
do
json
=
helper
.
send
(
:group_members_serialized
,
group
,
present_members
([
group_member
])).
to_json
expect
(
subject
[
'members'
].
to_json
).
to
match_schema
(
'members'
)
end
end
expect
(
json
).
to
match_schema
(
'members'
)
before
do
allow
(
helper
).
to
receive
(
:group_group_member_path
).
with
(
group
,
':id'
).
and_return
(
'/groups/foo-bar/-/group_members/:id'
)
allow
(
helper
).
to
receive
(
:can?
).
with
(
current_user
,
:admin_group_member
,
group
).
and_return
(
true
)
end
end
it
'returns expected json'
do
expected
=
{
member_path:
'/groups/foo-bar/-/group_members/:id'
,
source_id:
group
.
id
,
can_manage_members:
true
}.
as_json
expect
(
subject
).
to
include
(
expected
)
end
end
context
'for a group member'
do
context
'for a group member'
do
let
(
:group_member
)
{
create
(
:group_member
,
group:
group
,
created_by:
current_user
)
}
it_behaves_like
'members.json'
it_behaves_like
'members.json'
context
'with user status set'
do
context
'with user status set'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let!
(
:status
)
{
create
(
:user_status
,
user:
user
)
}
let!
(
:status
)
{
create
(
:user_status
,
user:
user
)
}
let
(
:group_member
)
{
create
(
:group_member
,
group:
group
,
user:
user
,
created_by:
current_user
)
}
let
(
:group_member
s
)
{
[
create
(
:group_member
,
group:
group
,
user:
user
,
created_by:
current_user
)]
}
it_behaves_like
'members.json'
it_behaves_like
'members.json'
end
end
end
end
context
'for an invited group member'
do
context
'for an invited group member'
do
let
(
:group_member
)
{
create
(
:group_member
,
:invited
,
group:
group
,
created_by:
current_user
)
}
let
(
:group_member
s
)
{
create_list
(
:group_member
,
2
,
:invited
,
group:
group
,
created_by:
current_user
)
}
it_behaves_like
'members.json'
it_behaves_like
'members.json'
end
end
context
'for an access request'
do
context
'for an access request'
do
let
(
:group_member
)
{
create
(
:group_member
,
:access_request
,
group:
group
,
created_by:
current_user
)
}
let
(
:group_member
s
)
{
create_list
(
:group_member
,
2
,
:access_request
,
group:
group
,
created_by:
current_user
)
}
it_behaves_like
'members.json'
it_behaves_like
'members.json'
end
end
end
describe
'#group_members_list_data_json'
do
let_it_be
(
:group_members
)
{
create_list
(
:group_member
,
2
,
group:
group
,
created_by:
current_user
)
}
let
(
:pagination
)
{
{}
}
let
(
:collection
)
{
group_members
}
let
(
:presented_members
)
{
present_members
(
collection
)
}
subject
{
Gitlab
::
Json
.
parse
(
helper
.
group_members_list_data_json
(
group
,
presented_members
,
pagination
))
}
before
do
allow
(
helper
).
to
receive
(
:group_group_member_path
).
with
(
group
,
':id'
).
and_return
(
'/groups/foo-bar/-/group_members/:id'
)
allow
(
helper
).
to
receive
(
:can?
).
with
(
current_user
,
:admin_group_member
,
group
).
and_return
(
true
)
end
it
'returns expected json'
do
expected
=
{
members:
helper
.
send
(
:group_members_serialized
,
group
,
presented_members
),
member_path:
'/groups/foo-bar/-/group_members/:id'
,
source_id:
group
.
id
,
can_manage_members:
true
}.
as_json
expect
(
subject
).
to
include
(
expected
)
end
context
'when pagination is not available'
do
context
'when pagination is not available'
do
it
'sets `pagination` attribute to expected json'
do
it
'sets `pagination` attribute to expected json'
do
...
@@ -144,12 +127,15 @@ RSpec.describe Groups::GroupMembersHelper do
...
@@ -144,12 +127,15 @@ RSpec.describe Groups::GroupMembersHelper do
param_name:
nil
,
param_name:
nil
,
params:
{}
params:
{}
},
},
members:
helper
.
send
(
:group_group_links_serialized
,
shared_group
.
shared_with_group_links
),
member_path:
'/groups/foo-bar/-/group_links/:id'
,
member_path:
'/groups/foo-bar/-/group_links/:id'
,
source_id:
shared_group
.
id
source_id:
shared_group
.
id
}.
as_json
}.
as_json
expect
(
subject
).
to
include
(
expected
)
expect
(
subject
).
to
include
(
expected
)
end
end
it
'returns `members` property that matches json schema'
do
expect
(
subject
[
'members'
].
to_json
).
to
match_schema
(
'group_link/group_group_links'
)
end
end
end
end
end
spec/helpers/projects/project_members_helper_spec.rb
View file @
39a9fe28
...
@@ -152,12 +152,6 @@ RSpec.describe Projects::ProjectMembersHelper do
...
@@ -152,12 +152,6 @@ RSpec.describe Projects::ProjectMembersHelper do
let
(
:collection
)
{
project_members
}
let
(
:collection
)
{
project_members
}
let
(
:presented_members
)
{
present_members
(
collection
)
}
let
(
:presented_members
)
{
present_members
(
collection
)
}
describe
'#project_members_serialized'
do
it
'matches json schema'
do
expect
(
helper
.
send
(
:project_members_serialized
,
project
,
presented_members
).
to_json
).
to
match_schema
(
'members'
)
end
end
describe
'#project_members_list_data_json'
do
describe
'#project_members_list_data_json'
do
let
(
:allow_admin_project
)
{
true
}
let
(
:allow_admin_project
)
{
true
}
let
(
:pagination
)
{
{}
}
let
(
:pagination
)
{
{}
}
...
@@ -170,7 +164,6 @@ RSpec.describe Projects::ProjectMembersHelper do
...
@@ -170,7 +164,6 @@ RSpec.describe Projects::ProjectMembersHelper do
it
'returns expected json'
do
it
'returns expected json'
do
expected
=
{
expected
=
{
members:
helper
.
send
(
:project_members_serialized
,
project
,
presented_members
),
member_path:
'/foo-bar/-/project_members/:id'
,
member_path:
'/foo-bar/-/project_members/:id'
,
source_id:
project
.
id
,
source_id:
project
.
id
,
can_manage_members:
true
can_manage_members:
true
...
@@ -179,6 +172,10 @@ RSpec.describe Projects::ProjectMembersHelper do
...
@@ -179,6 +172,10 @@ RSpec.describe Projects::ProjectMembersHelper do
expect
(
subject
).
to
include
(
expected
)
expect
(
subject
).
to
include
(
expected
)
end
end
it
'returns `members` property that matches json schema'
do
expect
(
subject
[
'members'
].
to_json
).
to
match_schema
(
'members'
)
end
context
'when pagination is not available'
do
context
'when pagination is not available'
do
it
'sets `pagination` attribute to expected json'
do
it
'sets `pagination` attribute to expected json'
do
expected
=
{
expected
=
{
...
@@ -217,12 +214,6 @@ RSpec.describe Projects::ProjectMembersHelper do
...
@@ -217,12 +214,6 @@ RSpec.describe Projects::ProjectMembersHelper do
let
(
:allow_admin_project
)
{
true
}
let
(
:allow_admin_project
)
{
true
}
describe
'#project_group_links_data_json'
do
it
'matches json schema'
do
expect
(
helper
.
send
(
:project_group_links_serialized
,
project_group_links
).
to_json
).
to
match_schema
(
'group_link/project_group_links'
)
end
end
describe
'#project_group_links_list_data_json'
do
describe
'#project_group_links_list_data_json'
do
subject
{
Gitlab
::
Json
.
parse
(
helper
.
project_group_links_list_data_json
(
project
,
project_group_links
))
}
subject
{
Gitlab
::
Json
.
parse
(
helper
.
project_group_links_list_data_json
(
project
,
project_group_links
))
}
...
@@ -233,7 +224,6 @@ RSpec.describe Projects::ProjectMembersHelper do
...
@@ -233,7 +224,6 @@ RSpec.describe Projects::ProjectMembersHelper do
it
'returns expected json'
do
it
'returns expected json'
do
expected
=
{
expected
=
{
members:
helper
.
send
(
:project_group_links_serialized
,
project_group_links
),
pagination:
{
pagination:
{
current_page:
nil
,
current_page:
nil
,
per_page:
nil
,
per_page:
nil
,
...
@@ -248,6 +238,10 @@ RSpec.describe Projects::ProjectMembersHelper do
...
@@ -248,6 +238,10 @@ RSpec.describe Projects::ProjectMembersHelper do
expect
(
subject
).
to
include
(
expected
)
expect
(
subject
).
to
include
(
expected
)
end
end
it
'returns `members` property that matches json schema'
do
expect
(
subject
[
'members'
].
to_json
).
to
match_schema
(
'group_link/project_group_links'
)
end
end
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