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
Kazuhiko Shiozaki
gitlab-ce
Commits
991c9f6f
Commit
991c9f6f
authored
Aug 20, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test Email::AttachmentUploader.
parent
2f78b5e8
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
25 deletions
+51
-25
spec/lib/gitlab/email/attachment_uploader_spec.rb
spec/lib/gitlab/email/attachment_uploader_spec.rb
+26
-0
spec/lib/gitlab/email/reply_parser_spec.rb
spec/lib/gitlab/email/reply_parser_spec.rb
+1
-1
spec/services/projects/upload_service_spec.rb
spec/services/projects/upload_service_spec.rb
+24
-24
No files found.
spec/lib/gitlab/email/attachment_uploader_spec.rb
0 → 100644
View file @
991c9f6f
require
"spec_helper"
describe
Gitlab
::
Email
::
AttachmentUploader
do
def
fixture_file
(
filename
)
return
''
if
filename
.
blank?
file_path
=
File
.
expand_path
(
Rails
.
root
+
'spec/fixtures/'
+
filename
)
File
.
read
(
file_path
)
end
describe
"#execute"
do
let
(
:project
)
{
build
(
:project
)
}
let
(
:message_raw
)
{
fixture_file
(
"emails/attachment.eml"
)
}
let
(
:message
)
{
Mail
::
Message
.
new
(
message_raw
)
}
it
"creates a post with an attachment"
do
links
=
described_class
.
new
(
message
).
execute
(
project
)
link
=
links
.
first
expect
(
link
).
not_to
be_nil
expect
(
link
[
:is_image
]).
to
be_truthy
expect
(
link
[
:alt
]).
to
eq
(
"bricks"
)
expect
(
link
[
:url
]).
to
include
(
"/
#{
project
.
path_with_namespace
}
"
)
expect
(
link
[
:url
]).
to
include
(
"bricks.png"
)
end
end
end
spec/lib/gitlab/email/reply_parser_spec.rb
View file @
991c9f6f
...
@@ -8,7 +8,7 @@ describe Gitlab::Email::ReplyParser do
...
@@ -8,7 +8,7 @@ describe Gitlab::Email::ReplyParser do
File
.
read
(
file_path
)
File
.
read
(
file_path
)
end
end
describe
'
self.parse_body
'
do
describe
'
#execute
'
do
def
test_parse_body
(
mail_string
)
def
test_parse_body
(
mail_string
)
described_class
.
new
(
Mail
::
Message
.
new
(
mail_string
)).
execute
described_class
.
new
(
Mail
::
Message
.
new
(
mail_string
)).
execute
end
end
...
...
spec/services/projects/upload_service_spec.rb
View file @
991c9f6f
...
@@ -13,13 +13,13 @@ describe Projects::UploadService do
...
@@ -13,13 +13,13 @@ describe Projects::UploadService do
@link_to_file
=
upload_file
(
@project
.
repository
,
gif
)
@link_to_file
=
upload_file
(
@project
.
repository
,
gif
)
end
end
it
{
expect
(
@link_to_file
).
to
have_key
(
'alt'
)
}
it
{
expect
(
@link_to_file
).
to
have_key
(
:alt
)
}
it
{
expect
(
@link_to_file
).
to
have_key
(
'url'
)
}
it
{
expect
(
@link_to_file
).
to
have_key
(
:url
)
}
it
{
expect
(
@link_to_file
).
to
have_key
(
'is_image'
)
}
it
{
expect
(
@link_to_file
).
to
have_key
(
:is_image
)
}
it
{
expect
(
@link_to_file
).
to
have_value
(
'banana_sample'
)
}
it
{
expect
(
@link_to_file
).
to
have_value
(
'banana_sample'
)
}
it
{
expect
(
@link_to_file
[
'is_image'
]).
to
equal
(
true
)
}
it
{
expect
(
@link_to_file
[
:is_image
]).
to
equal
(
true
)
}
it
{
expect
(
@link_to_file
[
'url'
]).
to
match
(
"/
#{
@project
.
path_with_namespace
}
"
)
}
it
{
expect
(
@link_to_file
[
:url
]).
to
match
(
"/
#{
@project
.
path_with_namespace
}
"
)
}
it
{
expect
(
@link_to_file
[
'url'
]).
to
match
(
'banana_sample.gif'
)
}
it
{
expect
(
@link_to_file
[
:url
]).
to
match
(
'banana_sample.gif'
)
}
end
end
context
'for valid png file'
do
context
'for valid png file'
do
...
@@ -29,13 +29,13 @@ describe Projects::UploadService do
...
@@ -29,13 +29,13 @@ describe Projects::UploadService do
@link_to_file
=
upload_file
(
@project
.
repository
,
png
)
@link_to_file
=
upload_file
(
@project
.
repository
,
png
)
end
end
it
{
expect
(
@link_to_file
).
to
have_key
(
'alt'
)
}
it
{
expect
(
@link_to_file
).
to
have_key
(
:alt
)
}
it
{
expect
(
@link_to_file
).
to
have_key
(
'url'
)
}
it
{
expect
(
@link_to_file
).
to
have_key
(
:url
)
}
it
{
expect
(
@link_to_file
).
to
have_value
(
'dk'
)
}
it
{
expect
(
@link_to_file
).
to
have_value
(
'dk'
)
}
it
{
expect
(
@link_to_file
).
to
have_key
(
'is_image'
)
}
it
{
expect
(
@link_to_file
).
to
have_key
(
:is_image
)
}
it
{
expect
(
@link_to_file
[
'is_image'
]).
to
equal
(
true
)
}
it
{
expect
(
@link_to_file
[
:is_image
]).
to
equal
(
true
)
}
it
{
expect
(
@link_to_file
[
'url'
]).
to
match
(
"/
#{
@project
.
path_with_namespace
}
"
)
}
it
{
expect
(
@link_to_file
[
:url
]).
to
match
(
"/
#{
@project
.
path_with_namespace
}
"
)
}
it
{
expect
(
@link_to_file
[
'url'
]).
to
match
(
'dk.png'
)
}
it
{
expect
(
@link_to_file
[
:url
]).
to
match
(
'dk.png'
)
}
end
end
context
'for valid jpg file'
do
context
'for valid jpg file'
do
...
@@ -44,13 +44,13 @@ describe Projects::UploadService do
...
@@ -44,13 +44,13 @@ describe Projects::UploadService do
@link_to_file
=
upload_file
(
@project
.
repository
,
jpg
)
@link_to_file
=
upload_file
(
@project
.
repository
,
jpg
)
end
end
it
{
expect
(
@link_to_file
).
to
have_key
(
'alt'
)
}
it
{
expect
(
@link_to_file
).
to
have_key
(
:alt
)
}
it
{
expect
(
@link_to_file
).
to
have_key
(
'url'
)
}
it
{
expect
(
@link_to_file
).
to
have_key
(
:url
)
}
it
{
expect
(
@link_to_file
).
to
have_key
(
'is_image'
)
}
it
{
expect
(
@link_to_file
).
to
have_key
(
:is_image
)
}
it
{
expect
(
@link_to_file
).
to
have_value
(
'rails_sample'
)
}
it
{
expect
(
@link_to_file
).
to
have_value
(
'rails_sample'
)
}
it
{
expect
(
@link_to_file
[
'is_image'
]).
to
equal
(
true
)
}
it
{
expect
(
@link_to_file
[
:is_image
]).
to
equal
(
true
)
}
it
{
expect
(
@link_to_file
[
'url'
]).
to
match
(
"/
#{
@project
.
path_with_namespace
}
"
)
}
it
{
expect
(
@link_to_file
[
:url
]).
to
match
(
"/
#{
@project
.
path_with_namespace
}
"
)
}
it
{
expect
(
@link_to_file
[
'url'
]).
to
match
(
'rails_sample.jpg'
)
}
it
{
expect
(
@link_to_file
[
:url
]).
to
match
(
'rails_sample.jpg'
)
}
end
end
context
'for txt file'
do
context
'for txt file'
do
...
@@ -59,13 +59,13 @@ describe Projects::UploadService do
...
@@ -59,13 +59,13 @@ describe Projects::UploadService do
@link_to_file
=
upload_file
(
@project
.
repository
,
txt
)
@link_to_file
=
upload_file
(
@project
.
repository
,
txt
)
end
end
it
{
expect
(
@link_to_file
).
to
have_key
(
'alt'
)
}
it
{
expect
(
@link_to_file
).
to
have_key
(
:alt
)
}
it
{
expect
(
@link_to_file
).
to
have_key
(
'url'
)
}
it
{
expect
(
@link_to_file
).
to
have_key
(
:url
)
}
it
{
expect
(
@link_to_file
).
to
have_key
(
'is_image'
)
}
it
{
expect
(
@link_to_file
).
to
have_key
(
:is_image
)
}
it
{
expect
(
@link_to_file
).
to
have_value
(
'doc_sample.txt'
)
}
it
{
expect
(
@link_to_file
).
to
have_value
(
'doc_sample.txt'
)
}
it
{
expect
(
@link_to_file
[
'is_image'
]).
to
equal
(
false
)
}
it
{
expect
(
@link_to_file
[
:is_image
]).
to
equal
(
false
)
}
it
{
expect
(
@link_to_file
[
'url'
]).
to
match
(
"/
#{
@project
.
path_with_namespace
}
"
)
}
it
{
expect
(
@link_to_file
[
:url
]).
to
match
(
"/
#{
@project
.
path_with_namespace
}
"
)
}
it
{
expect
(
@link_to_file
[
'url'
]).
to
match
(
'doc_sample.txt'
)
}
it
{
expect
(
@link_to_file
[
:url
]).
to
match
(
'doc_sample.txt'
)
}
end
end
context
'for too large a file'
do
context
'for too large a file'
do
...
...
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