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
c81df605
Commit
c81df605
authored
Dec 03, 2020
by
Vasilii Iakliushin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update code style for code_owners_spec.rb
* Use `subject` where possible * Minor style fixes
parent
faae3048
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
17 deletions
+18
-17
ee/spec/lib/gitlab/code_owners_spec.rb
ee/spec/lib/gitlab/code_owners_spec.rb
+18
-17
No files found.
ee/spec/lib/gitlab/code_owners_spec.rb
View file @
c81df605
...
...
@@ -19,6 +19,8 @@ RSpec.describe Gitlab::CodeOwners do
end
describe
'.for_blob'
do
subject
{
described_class
.
for_blob
(
project
,
blob
)
}
let
(
:branch
)
{
TestEnv
::
BRANCH_SHA
[
'with-codeowners'
]
}
let
(
:blob
)
{
project
.
repository
.
blob_at
(
branch
,
'docs/CODEOWNERS'
)
}
let
(
:codeowner_lookup_ref
)
{
branch
}
...
...
@@ -29,7 +31,7 @@ RSpec.describe Gitlab::CodeOwners do
end
it
'returns users for a blob'
do
expect
(
described_class
.
for_blob
(
project
,
blob
))
.
to
include
(
code_owner
)
is_expected
.
to
include
(
code_owner
)
end
end
...
...
@@ -39,7 +41,7 @@ RSpec.describe Gitlab::CodeOwners do
end
it
'returns no users'
do
expect
(
described_class
.
for_blob
(
project
,
blob
))
.
to
be_empty
is_expected
.
to
be_empty
end
end
end
...
...
@@ -100,7 +102,7 @@ RSpec.describe Gitlab::CodeOwners do
end
end
describe
".fast_path_lookup and .slow_path_lookup"
do
describe
'.fast_path_lookup and .slow_path_lookup'
do
let
(
:codeowner_lookup_ref
)
{
merge_request
.
target_branch
}
let
(
:codeowner_content
)
{
'files/ruby/feature.rb @owner-1'
}
let
(
:merge_request
)
do
...
...
@@ -117,7 +119,7 @@ RSpec.describe Gitlab::CodeOwners do
stub_licensed_features
(
code_owners:
true
)
end
it
"return equivalent results"
do
it
'returns equivalent results'
do
fast_results
=
described_class
.
entries_for_merge_request
(
merge_request
).
first
expect
(
merge_request
.
merge_request_diff
).
to
receive
(
:overflow?
).
and_return
(
true
)
...
...
@@ -131,6 +133,9 @@ RSpec.describe Gitlab::CodeOwners do
end
describe
'.entries_for_merge_request'
do
subject
(
:entries
)
{
described_class
.
entries_for_merge_request
(
merge_request
,
merge_request_diff:
merge_request_diff
)
}
let
(
:merge_request_diff
)
{
nil
}
let
(
:codeowner_lookup_ref
)
{
merge_request
.
target_branch
}
let
(
:merge_request
)
do
create
(
...
...
@@ -145,38 +150,34 @@ RSpec.describe Gitlab::CodeOwners do
context
'when the feature is available'
do
before
do
stub_licensed_features
(
code_owners:
true
)
allow
(
merge_request
).
to
receive
(
:modified_paths
).
with
(
past_merge_request_diff:
merge_request_diff
)
{
[
'docs/CODEOWNERS'
]
}
end
it
'returns owners for merge request'
do
expect
(
merge_request
).
to
receive
(
:modified_paths
).
with
(
past_merge_request_diff:
nil
).
and_return
([
'docs/CODEOWNERS'
])
entry
=
described_class
.
entries_for_merge_request
(
merge_request
).
first
expect
(
entry
.
pattern
).
to
eq
(
'docs/CODEOWNERS'
)
expect
(
entry
.
users
).
to
eq
([
code_owner
])
expect
(
entries
.
first
).
to
have_attributes
(
pattern:
'docs/CODEOWNERS'
,
users:
[
code_owner
])
end
context
'when merge_request_diff is specified'
do
let
(
:merge_request_diff
)
{
merge_request
.
merge_request_diff
}
it
'returns owners at the specified ref'
do
expect
(
described_class
).
to
receive
(
:fast_path_lookup
).
and_call_original
expect
(
merge_request
).
to
receive
(
:modified_paths
).
with
(
past_merge_request_diff:
merge_request
.
merge_request_diff
).
and_return
([
'docs/CODEOWNERS'
])
entry
=
described_class
.
entries_for_merge_request
(
merge_request
,
merge_request_diff:
merge_request
.
merge_request_diff
).
first
expect
(
entry
.
users
).
to
eq
([
code_owner
])
expect
(
entries
.
first
).
to
have_attributes
(
pattern:
'docs/CODEOWNERS'
,
users:
[
code_owner
])
end
end
context
'when the merge request is large (>1_000 files)'
do
before
do
expect
(
merge_request
.
merge_request_diff
).
to
receive
(
:overflow?
)
.
and_return
(
true
)
expect
(
merge_request
.
merge_request_diff
).
to
receive
(
:overflow?
)
{
true
}
end
it
'generates paths via .slow_path_lookup'
do
expect
(
described_class
).
not_to
receive
(
:fast_path_lookup
)
expect
(
described_class
).
to
receive
(
:slow_path_lookup
).
and_call_original
described_class
.
entries_for_merge_request
(
merge_request
)
entries
end
end
end
...
...
@@ -189,7 +190,7 @@ RSpec.describe Gitlab::CodeOwners do
it
'skips reading codeowners and returns an empty array'
do
expect
(
described_class
).
not_to
receive
(
:loader_for_merge_request
)
expect
(
described_class
.
entries_for_merge_request
(
merge_request
)).
to
eq
([])
is_expected
.
to
be_empty
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