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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
4f0780cc
Commit
4f0780cc
authored
Jul 20, 2016
by
Sean McGivern
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure to_json methods take optional argument
parent
ef2edcc1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
4 deletions
+28
-4
lib/gitlab/diff/position.rb
lib/gitlab/diff/position.rb
+2
-2
lib/gitlab/git_access_status.rb
lib/gitlab/git_access_status.rb
+2
-2
spec/lib/gitlab/diff/position_spec.rb
spec/lib/gitlab/diff/position_spec.rb
+24
-0
No files found.
lib/gitlab/diff/position.rb
View file @
4f0780cc
...
...
@@ -73,8 +73,8 @@ module Gitlab
diff_refs
.
complete?
end
def
to_json
JSON
.
generate
(
self
.
to_h
)
def
to_json
(
opts
=
nil
)
JSON
.
generate
(
self
.
to_h
,
opts
)
end
def
type
...
...
lib/gitlab/git_access_status.rb
View file @
4f0780cc
...
...
@@ -8,8 +8,8 @@ module Gitlab
@message
=
message
end
def
to_json
{
status:
@status
,
message:
@message
}.
to_json
def
to_json
(
opts
=
nil
)
{
status:
@status
,
message:
@message
}.
to_json
(
opts
)
end
end
end
spec/lib/gitlab/diff/position_spec.rb
View file @
4f0780cc
...
...
@@ -338,4 +338,28 @@ describe Gitlab::Diff::Position, lib: true do
end
end
end
describe
"#to_json"
do
let
(
:hash
)
do
{
old_path:
"files/ruby/popen.rb"
,
new_path:
"files/ruby/popen.rb"
,
old_line:
nil
,
new_line:
14
,
base_sha:
nil
,
head_sha:
nil
,
start_sha:
nil
}
end
let
(
:diff_position
)
{
described_class
.
new
(
hash
)
}
it
"returns the position as JSON"
do
expect
(
JSON
.
parse
(
diff_position
.
to_json
)).
to
eq
(
hash
.
stringify_keys
)
end
it
"works when nested under another hash"
do
expect
(
JSON
.
parse
(
JSON
.
generate
(
pos:
diff_position
))).
to
eq
(
'pos'
=>
hash
.
stringify_keys
)
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