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
d9869b67
Commit
d9869b67
authored
Feb 18, 2021
by
charlie ablett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor board helper specs
parent
061d1f36
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
41 deletions
+54
-41
ee/spec/helpers/boards_helper_spec.rb
ee/spec/helpers/boards_helper_spec.rb
+11
-13
spec/helpers/boards_helper_spec.rb
spec/helpers/boards_helper_spec.rb
+43
-28
No files found.
ee/spec/helpers/boards_helper_spec.rb
View file @
d9869b67
...
...
@@ -5,22 +5,22 @@ require 'spec_helper'
RSpec
.
describe
BoardsHelper
do
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:group
)
{
create
(
:group
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:project_board
)
{
create
(
:board
,
project:
project
)
}
describe
'#board_list_data'
do
let
(
:results
)
{
helper
.
board_list_data
}
it
'contains an endpoint to get users list'
do
board
=
create
(
:board
,
project:
project
)
assign
(
:board
,
board
)
assign
(
:board
,
project_board
)
assign
(
:project
,
project
)
expect
(
results
).
to
include
(
list_assignees_path:
"/-/boards/
#{
board
.
id
}
/users.json"
)
expect
(
results
).
to
include
(
list_assignees_path:
"/-/boards/
#{
project_
board
.
id
}
/users.json"
)
end
end
describe
'#current_board_json'
do
let
(
:board_json
)
{
helper
.
current_board_json
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:label1
)
{
create
(
:label
,
name:
"feijoa"
)
}
let
(
:label2
)
{
create
(
:label
,
name:
"pineapple"
)
}
let
(
:milestone
)
{
create
(
:milestone
)
}
...
...
@@ -38,26 +38,24 @@ RSpec.describe BoardsHelper do
let_it_be
(
:epic_board
)
{
create
(
:epic_board
,
group:
group
)
}
it
'generates the correct url'
do
@board
=
epic_board
@group
=
group
assign
(
:board
,
epic_board
)
assign
(
:group
,
group
)
expect
(
board_base_url
).
to
eq
"http://test.host/groups/
#{
group
.
full_path
}
/-/epic_boards"
expect
(
helper
.
board_base_url
).
to
eq
"http://test.host/groups/
#{
group
.
full_path
}
/-/epic_boards"
end
end
end
describe
'#board_data'
do
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:board
)
{
create
(
:board
,
project:
project
)
}
let
(
:board_data
)
{
helper
.
board_data
}
before
do
assign
(
:board
,
board
)
assign
(
:board
,
project_
board
)
assign
(
:project
,
project
)
allow
(
helper
).
to
receive
(
:current_user
)
{
user
}
allow
(
helper
).
to
receive
(
:can?
).
with
(
user
,
:create_non_backlog_issues
,
board
).
and_return
(
true
)
allow
(
helper
).
to
receive
(
:can?
).
with
(
user
,
:admin_issue
,
board
).
and_return
(
true
)
allow
(
helper
).
to
receive
(
:can?
).
with
(
user
,
:create_non_backlog_issues
,
project_
board
).
and_return
(
true
)
allow
(
helper
).
to
receive
(
:can?
).
with
(
user
,
:admin_issue
,
project_
board
).
and_return
(
true
)
end
context
'when no iteration'
,
:aggregate_failures
do
...
...
@@ -71,7 +69,7 @@ RSpec.describe BoardsHelper do
let_it_be
(
:iteration
)
{
create
(
:iteration
,
group:
group
)
}
before
do
board
.
update!
(
iteration:
iteration
)
project_
board
.
update!
(
iteration:
iteration
)
end
it
'serializes board with iteration'
do
...
...
spec/helpers/boards_helper_spec.rb
View file @
d9869b67
...
...
@@ -3,52 +3,71 @@
require
'spec_helper'
RSpec
.
describe
BoardsHelper
do
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:base_group
)
{
create
(
:group
,
path:
'base'
)
}
let_it_be
(
:project_board
)
{
create
(
:board
,
project:
project
)
}
let_it_be
(
:group_board
)
{
create
(
:board
,
group:
base_group
)
}
describe
'#build_issue_link_base'
do
context
'project board'
do
it
'returns correct path for project board'
do
@project
=
project
@board
=
create
(
:board
,
project:
@project
)
assign
(
:project
,
project
)
assign
(
:board
,
project_board
)
expect
(
build_issue_link_base
).
to
eq
(
"/
#{
@project
.
namespace
.
path
}
/
#{
@
project
.
path
}
/-/issues"
)
expect
(
helper
.
build_issue_link_base
).
to
eq
(
"/
#{
project
.
namespace
.
path
}
/
#{
project
.
path
}
/-/issues"
)
end
end
context
'group board'
do
let
(
:base_group
)
{
create
(
:group
,
path:
'base'
)
}
it
'returns correct path for base group'
do
@board
=
create
(
:board
,
group:
base_group
)
assign
(
:board
,
group_board
)
expect
(
build_issue_link_base
).
to
eq
(
'/base/:project_path/issues'
)
expect
(
helper
.
build_issue_link_base
).
to
eq
(
'/base/:project_path/issues'
)
end
it
'returns correct path for subgroup'
do
subgroup
=
create
(
:group
,
parent:
base_group
,
path:
'sub'
)
@board
=
create
(
:board
,
group:
subgroup
)
assign
(
:board
,
create
(
:board
,
group:
subgroup
)
)
expect
(
build_issue_link_base
).
to
eq
(
'/base/sub/:project_path/issues'
)
expect
(
helper
.
build_issue_link_base
).
to
eq
(
'/base/sub/:project_path/issues'
)
end
end
end
describe
'#board_data'
do
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:board
)
{
create
(
:board
,
project:
project
)
}
describe
'#board_base_url'
do
context
'when project board'
do
it
'generates the correct url'
do
assign
(
:board
,
group_board
)
assign
(
:group
,
base_group
)
expect
(
helper
.
board_base_url
).
to
eq
"http://test.host/groups/
#{
base_group
.
full_path
}
/-/boards"
end
end
context
'when project board'
do
it
'generates the correct url'
do
assign
(
:board
,
project_board
)
assign
(
:project
,
project
)
expect
(
helper
.
board_base_url
).
to
eq
"/
#{
project
.
full_path
}
/-/boards"
end
end
end
describe
'#board_data'
do
context
'project_board'
do
before
do
assign
(
:project
,
project
)
assign
(
:board
,
board
)
assign
(
:board
,
project_
board
)
allow
(
helper
).
to
receive
(
:current_user
)
{
user
}
allow
(
helper
).
to
receive
(
:can?
).
with
(
user
,
:create_non_backlog_issues
,
board
).
and_return
(
true
)
allow
(
helper
).
to
receive
(
:can?
).
with
(
user
,
:admin_issue
,
board
).
and_return
(
true
)
allow
(
helper
).
to
receive
(
:can?
).
with
(
user
,
:create_non_backlog_issues
,
project_
board
).
and_return
(
true
)
allow
(
helper
).
to
receive
(
:can?
).
with
(
user
,
:admin_issue
,
project_
board
).
and_return
(
true
)
end
it
'returns a board_lists_path as lists_endpoint'
do
expect
(
helper
.
board_data
[
:lists_endpoint
]).
to
eq
(
board_lists_path
(
board
))
expect
(
helper
.
board_data
[
:lists_endpoint
]).
to
eq
(
board_lists_path
(
project_
board
))
end
it
'returns board type as parent'
do
...
...
@@ -66,25 +85,22 @@ RSpec.describe BoardsHelper do
end
context
'group board'
do
let_it_be
(
:group
)
{
create
(
:group
,
path:
'base'
)
}
let_it_be
(
:board
)
{
create
(
:board
,
group:
group
)
}
before
do
assign
(
:group
,
group
)
assign
(
:board
,
board
)
assign
(
:group
,
base_
group
)
assign
(
:board
,
group_
board
)
allow
(
helper
).
to
receive
(
:current_user
)
{
user
}
allow
(
helper
).
to
receive
(
:can?
).
with
(
user
,
:create_non_backlog_issues
,
board
).
and_return
(
true
)
allow
(
helper
).
to
receive
(
:can?
).
with
(
user
,
:admin_issue
,
board
).
and_return
(
true
)
allow
(
helper
).
to
receive
(
:can?
).
with
(
user
,
:create_non_backlog_issues
,
group_
board
).
and_return
(
true
)
allow
(
helper
).
to
receive
(
:can?
).
with
(
user
,
:admin_issue
,
group_
board
).
and_return
(
true
)
end
it
'returns correct path for base group'
do
expect
(
helper
.
build_issue_link_base
).
to
eq
(
'/base/:project_path/issues'
)
expect
(
helper
.
build_issue_link_base
).
to
eq
(
"/
#{
base_group
.
full_path
}
/:project_path/issues"
)
end
it
'returns required label endpoints'
do
expect
(
helper
.
board_data
[
:labels_fetch_path
]).
to
eq
(
"/groups/
base
/-/labels.json?include_ancestor_groups=true&only_group_labels=true"
)
expect
(
helper
.
board_data
[
:labels_manage_path
]).
to
eq
(
"/groups/
base
/-/labels"
)
expect
(
helper
.
board_data
[
:labels_fetch_path
]).
to
eq
(
"/groups/
#{
base_group
.
full_path
}
/-/labels.json?include_ancestor_groups=true&only_group_labels=true"
)
expect
(
helper
.
board_data
[
:labels_manage_path
]).
to
eq
(
"/groups/
#{
base_group
.
full_path
}
/-/labels"
)
end
end
end
...
...
@@ -93,8 +109,7 @@ RSpec.describe BoardsHelper do
let
(
:board_json
)
{
helper
.
current_board_json
}
it
'can serialise with a basic set of attributes'
do
board
=
create
(
:board
,
project:
project
)
assign
(
:board
,
board
)
assign
(
:board
,
project_board
)
expect
(
board_json
).
to
match_schema
(
'current-board'
)
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