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
872b3b61
Commit
872b3b61
authored
Apr 11, 2021
by
Abhishek Kumar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added spec for context_commits_diff model and entity
parent
f9643949
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
2 deletions
+44
-2
app/models/context_commits_diff.rb
app/models/context_commits_diff.rb
+2
-2
spec/models/context_commits_diff_spec.rb
spec/models/context_commits_diff_spec.rb
+23
-0
spec/serializers/context_commits_diff_entity_spec.rb
spec/serializers/context_commits_diff_entity_spec.rb
+19
-0
No files found.
app/models/context_commits_diff.rb
View file @
872b3b61
...
...
@@ -32,8 +32,8 @@ class ContextCommitsDiff
def
diff_refs
Gitlab
::
Diff
::
DiffRefs
.
new
(
base_sha:
commits
.
last
.
diff_refs
.
base_sha
,
head_sha:
commits
.
first
.
diff_refs
.
head_sha
base_sha:
commits
.
last
&
.
diff_refs
&
.
base_sha
,
head_sha:
commits
.
first
&
.
diff_refs
&
.
head_sha
)
end
...
...
spec/models/context_commits_diff_spec.rb
0 → 100644
View file @
872b3b61
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
ContextCommitsDiff
do
let
(
:merge_request_context_commit_diff_file
)
{
create
(
:merge_request_context_commit_diff_file
)
}
let
(
:merge_request
)
{
merge_request_context_commit_diff_file
.
merge_request_context_commit
.
merge_request
}
let
(
:context_commits_diff
)
{
merge_request
.
context_commits_diff
}
subject
{
context_commits_diff
}
describe
'.commits_count'
do
it
'reports commits count'
do
expect
(
subject
.
commits_count
).
to
be
(
1
)
end
end
describe
'.raw_diffs'
do
it
'returns instance of Gitlab::Git::DiffCollection'
do
expect
(
subject
.
raw_diffs
).
to
be_a
(
Gitlab
::
Git
::
DiffCollection
)
end
end
end
spec/serializers/context_commits_diff_entity_spec.rb
0 → 100644
View file @
872b3b61
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
ContextCommitsDiffEntity
do
let
(
:merge_request_context_commit_diff_file
)
{
create
(
:merge_request_context_commit_diff_file
)
}
let
(
:merge_request
)
{
merge_request_context_commit_diff_file
.
merge_request_context_commit
.
merge_request
}
let
(
:context_commits_diff
)
{
merge_request
.
context_commits_diff
}
context
'as json'
do
describe
'.diff_files'
do
it
'returns diff files metadata'
do
payload
=
ContextCommitsDiffEntity
.
represent
(
context_commits_diff
).
as_json
expect
(
payload
[
:commits_count
]).
to
eq
(
1
)
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