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
a2be3954
Commit
a2be3954
authored
Dec 12, 2016
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
specs for bitbucket representers
parent
c45484ba
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
160 additions
and
3 deletions
+160
-3
lib/bitbucket/representation/pull_request_comment.rb
lib/bitbucket/representation/pull_request_comment.rb
+3
-3
spec/lib/bitbucket/representation/comment_spec.rb
spec/lib/bitbucket/representation/comment_spec.rb
+22
-0
spec/lib/bitbucket/representation/issue_spec.rb
spec/lib/bitbucket/representation/issue_spec.rb
+42
-0
spec/lib/bitbucket/representation/pull_request_comment_spec.rb
...lib/bitbucket/representation/pull_request_comment_spec.rb
+35
-0
spec/lib/bitbucket/representation/pull_request_spec.rb
spec/lib/bitbucket/representation/pull_request_spec.rb
+47
-0
spec/lib/bitbucket/representation/user_spec.rb
spec/lib/bitbucket/representation/user_spec.rb
+11
-0
No files found.
lib/bitbucket/representation/pull_request_comment.rb
View file @
a2be3954
...
@@ -6,15 +6,15 @@ module Bitbucket
...
@@ -6,15 +6,15 @@ module Bitbucket
end
end
def
file_path
def
file_path
inline
.
fetch
(
'path'
,
nil
)
inline
.
fetch
(
'path'
)
end
end
def
old_pos
def
old_pos
inline
.
fetch
(
'from'
,
nil
)
inline
.
fetch
(
'from'
)
end
end
def
new_pos
def
new_pos
inline
.
fetch
(
'to'
,
nil
)
inline
.
fetch
(
'to'
)
end
end
def
parent_id
def
parent_id
...
...
spec/lib/bitbucket/representation/comment_spec.rb
0 → 100644
View file @
a2be3954
require
'spec_helper'
describe
Bitbucket
::
Representation
::
Comment
do
describe
'#author'
do
it
{
expect
(
described_class
.
new
(
'user'
=>
{
'username'
=>
'Ben'
}).
author
).
to
eq
(
'Ben'
)
}
it
{
expect
(
described_class
.
new
({}).
author
).
to
eq
(
'Anonymous'
)
}
end
describe
'#note'
do
it
{
expect
(
described_class
.
new
(
'content'
=>
{
'raw'
=>
'Text'
}).
note
).
to
eq
(
'Text'
)
}
it
{
expect
(
described_class
.
new
({}).
note
).
to
be_nil
}
end
describe
'#created_at'
do
it
{
expect
(
described_class
.
new
(
'created_on'
=>
Date
.
today
).
created_at
).
to
eq
(
Date
.
today
)
}
end
describe
'#updated_at'
do
it
{
expect
(
described_class
.
new
(
'updated_on'
=>
Date
.
today
).
updated_at
).
to
eq
(
Date
.
today
)
}
it
{
expect
(
described_class
.
new
(
'created_on'
=>
Date
.
today
).
updated_at
).
to
eq
(
Date
.
today
)
}
end
end
spec/lib/bitbucket/representation/issue_spec.rb
0 → 100644
View file @
a2be3954
require
'spec_helper'
describe
Bitbucket
::
Representation
::
Issue
do
describe
'#iid'
do
it
{
expect
(
described_class
.
new
(
'id'
=>
1
).
iid
).
to
eq
(
1
)
}
end
describe
'#kind'
do
it
{
expect
(
described_class
.
new
(
'kind'
=>
'bug'
).
kind
).
to
eq
(
'bug'
)
}
end
describe
'#author'
do
it
{
expect
(
described_class
.
new
({
'reporter'
=>
{
'username'
=>
'Ben'
}}).
author
).
to
eq
(
'Ben'
)
}
it
{
expect
(
described_class
.
new
({}).
author
).
to
eq
(
'Anonymous'
)
}
end
describe
'#description'
do
it
{
expect
(
described_class
.
new
({
'content'
=>
{
'raw'
=>
'Text'
}}).
description
).
to
eq
(
'Text'
)
}
it
{
expect
(
described_class
.
new
({}).
description
).
to
be_nil
}
end
describe
'#state'
do
it
{
expect
(
described_class
.
new
({
'state'
=>
'invalid'
}).
state
).
to
eq
(
'closed'
)
}
it
{
expect
(
described_class
.
new
({
'state'
=>
'wontfix'
}).
state
).
to
eq
(
'closed'
)
}
it
{
expect
(
described_class
.
new
({
'state'
=>
'resolved'
}).
state
).
to
eq
(
'closed'
)
}
it
{
expect
(
described_class
.
new
({
'state'
=>
'duplicate'
}).
state
).
to
eq
(
'closed'
)
}
it
{
expect
(
described_class
.
new
({
'state'
=>
'closed'
}).
state
).
to
eq
(
'closed'
)
}
it
{
expect
(
described_class
.
new
({
'state'
=>
'opened'
}).
state
).
to
eq
(
'opened'
)
}
end
describe
'#title'
do
it
{
expect
(
described_class
.
new
(
'title'
=>
'Issue'
).
title
).
to
eq
(
'Issue'
)
}
end
describe
'#created_at'
do
it
{
expect
(
described_class
.
new
(
'created_on'
=>
Date
.
today
).
created_at
).
to
eq
(
Date
.
today
)
}
end
describe
'#updated_at'
do
it
{
expect
(
described_class
.
new
(
'edited_on'
=>
Date
.
today
).
updated_at
).
to
eq
(
Date
.
today
)
}
end
end
spec/lib/bitbucket/representation/pull_request_comment_spec.rb
0 → 100644
View file @
a2be3954
require
'spec_helper'
describe
Bitbucket
::
Representation
::
PullRequestComment
do
describe
'#iid'
do
it
{
expect
(
described_class
.
new
(
'id'
=>
1
).
iid
).
to
eq
(
1
)
}
end
describe
'#file_path'
do
it
{
expect
(
described_class
.
new
(
'inline'
=>
{
'path'
=>
'/path'
}).
file_path
).
to
eq
(
'/path'
)
}
end
describe
'#old_pos'
do
it
{
expect
(
described_class
.
new
(
'inline'
=>
{
'from'
=>
3
}).
old_pos
).
to
eq
(
3
)
}
end
describe
'#new_pos'
do
it
{
expect
(
described_class
.
new
(
'inline'
=>
{
'to'
=>
3
}).
new_pos
).
to
eq
(
3
)
}
end
describe
'#parent_id'
do
it
{
expect
(
described_class
.
new
({
'parent'
=>
{
'id'
=>
2
}}).
parent_id
).
to
eq
(
2
)
}
it
{
expect
(
described_class
.
new
({}).
parent_id
).
to
be_nil
}
end
describe
'#inline?'
do
it
{
expect
(
described_class
.
new
(
'inline'
=>
{}).
inline?
).
to
be_truthy
}
it
{
expect
(
described_class
.
new
({}).
inline?
).
to
be_falsey
}
end
describe
'#has_parent?'
do
it
{
expect
(
described_class
.
new
(
'parent'
=>
{}).
has_parent?
).
to
be_truthy
}
it
{
expect
(
described_class
.
new
({}).
has_parent?
).
to
be_falsey
}
end
end
spec/lib/bitbucket/representation/pull_request_spec.rb
0 → 100644
View file @
a2be3954
require
'spec_helper'
describe
Bitbucket
::
Representation
::
PullRequest
do
describe
'#iid'
do
it
{
expect
(
described_class
.
new
(
'id'
=>
1
).
iid
).
to
eq
(
1
)
}
end
describe
'#author'
do
it
{
expect
(
described_class
.
new
({
'author'
=>
{
'username'
=>
'Ben'
}}).
author
).
to
eq
(
'Ben'
)
}
it
{
expect
(
described_class
.
new
({}).
author
).
to
eq
(
'Anonymous'
)
}
end
describe
'#description'
do
it
{
expect
(
described_class
.
new
({
'description'
=>
'Text'
}).
description
).
to
eq
(
'Text'
)
}
it
{
expect
(
described_class
.
new
({}).
description
).
to
be_nil
}
end
describe
'#state'
do
it
{
expect
(
described_class
.
new
({
'state'
=>
'MERGED'
}).
state
).
to
eq
(
'merged'
)
}
it
{
expect
(
described_class
.
new
({
'state'
=>
'DECLINED'
}).
state
).
to
eq
(
'closed'
)
}
it
{
expect
(
described_class
.
new
({}).
state
).
to
eq
(
'opened'
)
}
end
describe
'#title'
do
it
{
expect
(
described_class
.
new
(
'title'
=>
'Issue'
).
title
).
to
eq
(
'Issue'
)
}
end
describe
'#source_branch_name'
do
it
{
expect
(
described_class
.
new
({
source:
{
branch:
{
name:
'feature'
}
}
}.
with_indifferent_access
).
source_branch_name
).
to
eq
(
'feature'
)
}
it
{
expect
(
described_class
.
new
({
source:
{}
}.
with_indifferent_access
).
source_branch_name
).
to
be_nil
}
end
describe
'#source_branch_sha'
do
it
{
expect
(
described_class
.
new
({
source:
{
commit:
{
hash:
'abcd123'
}
}
}.
with_indifferent_access
).
source_branch_sha
).
to
eq
(
'abcd123'
)
}
it
{
expect
(
described_class
.
new
({
source:
{}
}.
with_indifferent_access
).
source_branch_sha
).
to
be_nil
}
end
describe
'#target_branch_name'
do
it
{
expect
(
described_class
.
new
({
destination:
{
branch:
{
name:
'master'
}
}
}.
with_indifferent_access
).
target_branch_name
).
to
eq
(
'master'
)
}
it
{
expect
(
described_class
.
new
({
destination:
{}
}.
with_indifferent_access
).
target_branch_name
).
to
be_nil
}
end
describe
'#target_branch_sha'
do
it
{
expect
(
described_class
.
new
({
destination:
{
commit:
{
hash:
'abcd123'
}
}
}.
with_indifferent_access
).
target_branch_sha
).
to
eq
(
'abcd123'
)
}
it
{
expect
(
described_class
.
new
({
destination:
{}
}.
with_indifferent_access
).
target_branch_sha
).
to
be_nil
}
end
end
spec/lib/bitbucket/representation/user_spec.rb
0 → 100644
View file @
a2be3954
require
'spec_helper'
describe
Bitbucket
::
Representation
::
User
do
describe
'#username'
do
it
'returns correct value'
do
user
=
described_class
.
new
(
'username'
=>
'Ben'
)
expect
(
user
.
username
).
to
eq
(
'Ben'
)
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