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
Léo-Paul Géneau
gitlab-ce
Commits
8a62f304
Commit
8a62f304
authored
Jun 28, 2017
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a UTF-8 encoding matcher
parent
7648f113
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
8 deletions
+19
-8
spec/lib/gitlab/git/blame_spec.rb
spec/lib/gitlab/git/blame_spec.rb
+3
-0
spec/lib/gitlab/git/branch_spec.rb
spec/lib/gitlab/git/branch_spec.rb
+1
-1
spec/lib/gitlab/git/diff_spec.rb
spec/lib/gitlab/git/diff_spec.rb
+1
-1
spec/lib/gitlab/git/repository_spec.rb
spec/lib/gitlab/git/repository_spec.rb
+5
-6
spec/support/matchers/be_utf8.rb
spec/support/matchers/be_utf8.rb
+9
-0
No files found.
spec/lib/gitlab/git/blame_spec.rb
View file @
8a62f304
...
@@ -20,6 +20,7 @@ describe Gitlab::Git::Blame, seed_helper: true do
...
@@ -20,6 +20,7 @@ describe Gitlab::Git::Blame, seed_helper: true do
expect
(
data
.
size
).
to
eq
(
95
)
expect
(
data
.
size
).
to
eq
(
95
)
expect
(
data
.
first
[
:commit
]).
to
be_kind_of
(
Gitlab
::
Git
::
Commit
)
expect
(
data
.
first
[
:commit
]).
to
be_kind_of
(
Gitlab
::
Git
::
Commit
)
expect
(
data
.
first
[
:line
]).
to
eq
(
"# Contribute to GitLab"
)
expect
(
data
.
first
[
:line
]).
to
eq
(
"# Contribute to GitLab"
)
expect
(
data
.
first
[
:line
]).
to
be_utf8
end
end
end
end
...
@@ -40,6 +41,7 @@ describe Gitlab::Git::Blame, seed_helper: true do
...
@@ -40,6 +41,7 @@ describe Gitlab::Git::Blame, seed_helper: true do
expect
(
data
.
size
).
to
eq
(
1
)
expect
(
data
.
size
).
to
eq
(
1
)
expect
(
data
.
first
[
:commit
]).
to
be_kind_of
(
Gitlab
::
Git
::
Commit
)
expect
(
data
.
first
[
:commit
]).
to
be_kind_of
(
Gitlab
::
Git
::
Commit
)
expect
(
data
.
first
[
:line
]).
to
eq
(
"Ä ü"
)
expect
(
data
.
first
[
:line
]).
to
eq
(
"Ä ü"
)
expect
(
data
.
first
[
:line
]).
to
be_utf8
end
end
end
end
...
@@ -61,6 +63,7 @@ describe Gitlab::Git::Blame, seed_helper: true do
...
@@ -61,6 +63,7 @@ describe Gitlab::Git::Blame, seed_helper: true do
expect
(
data
.
size
).
to
eq
(
1
)
expect
(
data
.
size
).
to
eq
(
1
)
expect
(
data
.
first
[
:commit
]).
to
be_kind_of
(
Gitlab
::
Git
::
Commit
)
expect
(
data
.
first
[
:commit
]).
to
be_kind_of
(
Gitlab
::
Git
::
Commit
)
expect
(
data
.
first
[
:line
]).
to
eq
(
" "
)
expect
(
data
.
first
[
:line
]).
to
eq
(
" "
)
expect
(
data
.
first
[
:line
]).
to
be_utf8
end
end
end
end
end
end
spec/lib/gitlab/git/branch_spec.rb
View file @
8a62f304
...
@@ -48,7 +48,7 @@ describe Gitlab::Git::Branch, seed_helper: true do
...
@@ -48,7 +48,7 @@ describe Gitlab::Git::Branch, seed_helper: true do
expect
(
Gitlab
::
Git
::
Commit
).
to
receive
(
:decorate
)
expect
(
Gitlab
::
Git
::
Commit
).
to
receive
(
:decorate
)
.
with
(
hash_including
(
attributes
)).
and_call_original
.
with
(
hash_including
(
attributes
)).
and_call_original
expect
(
branch
.
dereferenced_target
.
message
.
encoding
).
to
be
(
Encoding
::
UTF_8
)
expect
(
branch
.
dereferenced_target
.
message
).
to
be_utf8
end
end
end
end
...
...
spec/lib/gitlab/git/diff_spec.rb
View file @
8a62f304
...
@@ -180,7 +180,7 @@ EOT
...
@@ -180,7 +180,7 @@ EOT
let
(
:raw_patch
)
{
@raw_diff_hash
[
:diff
].
encode
(
Encoding
::
ASCII_8BIT
)
}
let
(
:raw_patch
)
{
@raw_diff_hash
[
:diff
].
encode
(
Encoding
::
ASCII_8BIT
)
}
it
'encodes diff patch to UTF-8'
do
it
'encodes diff patch to UTF-8'
do
expect
(
diff
.
diff
.
encoding
).
to
eq
(
Encoding
::
UTF_8
)
expect
(
diff
.
diff
).
to
be_utf8
end
end
end
end
end
end
...
...
spec/lib/gitlab/git/repository_spec.rb
View file @
8a62f304
...
@@ -32,7 +32,7 @@ describe Gitlab::Git::Repository, seed_helper: true do
...
@@ -32,7 +32,7 @@ describe Gitlab::Git::Repository, seed_helper: true do
end
end
it
'returns UTF-8'
do
it
'returns UTF-8'
do
expect
(
repository
.
root_ref
.
encoding
).
to
eq
(
Encoding
.
find
(
'UTF-8'
))
expect
(
repository
.
root_ref
).
to
be_utf8
end
end
it
'gets the branch name from GitalyClient'
do
it
'gets the branch name from GitalyClient'
do
...
@@ -124,7 +124,7 @@ describe Gitlab::Git::Repository, seed_helper: true do
...
@@ -124,7 +124,7 @@ describe Gitlab::Git::Repository, seed_helper: true do
end
end
it
'returns UTF-8'
do
it
'returns UTF-8'
do
expect
(
subject
.
first
.
encoding
).
to
eq
(
Encoding
.
find
(
'UTF-8'
))
expect
(
subject
.
first
).
to
be_utf8
end
end
it
{
is_expected
.
to
include
(
"master"
)
}
it
{
is_expected
.
to
include
(
"master"
)
}
...
@@ -158,7 +158,7 @@ describe Gitlab::Git::Repository, seed_helper: true do
...
@@ -158,7 +158,7 @@ describe Gitlab::Git::Repository, seed_helper: true do
end
end
it
'returns UTF-8'
do
it
'returns UTF-8'
do
expect
(
subject
.
first
.
encoding
).
to
eq
(
Encoding
.
find
(
'UTF-8'
))
expect
(
subject
.
first
).
to
be_utf8
end
end
describe
'#last'
do
describe
'#last'
do
...
@@ -1259,10 +1259,9 @@ describe Gitlab::Git::Repository, seed_helper: true do
...
@@ -1259,10 +1259,9 @@ describe Gitlab::Git::Repository, seed_helper: true do
it
'returns a Branch with UTF-8 fields'
do
it
'returns a Branch with UTF-8 fields'
do
branches
=
@repo
.
local_branches
.
to_a
branches
=
@repo
.
local_branches
.
to_a
expect
(
branches
.
size
).
to
be
>
0
expect
(
branches
.
size
).
to
be
>
0
utf_8
=
Encoding
.
find
(
'utf-8'
)
branches
.
each
do
|
branch
|
branches
.
each
do
|
branch
|
expect
(
branch
.
name
.
encoding
).
to
eq
(
utf_8
)
expect
(
branch
.
name
).
to
be_utf8
expect
(
branch
.
target
.
encoding
).
to
eq
(
utf_8
)
unless
branch
.
target
.
nil?
expect
(
branch
.
target
).
to
be_utf8
unless
branch
.
target
.
nil?
end
end
end
end
...
...
spec/support/matchers/be_utf8.rb
0 → 100644
View file @
8a62f304
RSpec
::
Matchers
.
define
:be_utf8
do
|
_
|
match
do
|
actual
|
actual
.
is_a?
(
String
)
&&
actual
.
encoding
==
Encoding
.
find
(
'UTF-8'
)
end
description
do
"be a String with encoding UTF-8"
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