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
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
Hide 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
File
.
read
(
file_path
)
end
describe
'
self.parse_body
'
do
describe
'
#execute
'
do
def
test_parse_body
(
mail_string
)
described_class
.
new
(
Mail
::
Message
.
new
(
mail_string
)).
execute
end
...
...
spec/services/projects/upload_service_spec.rb
View file @
991c9f6f
...
...
@@ -13,13 +13,13 @@ describe Projects::UploadService do
@link_to_file
=
upload_file
(
@project
.
repository
,
gif
)
end
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
(
'is_image'
)
}
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
(
:is_image
)
}
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
[
'url'
]).
to
match
(
"/
#{
@project
.
path_with_namespace
}
"
)
}
it
{
expect
(
@link_to_file
[
'url'
]).
to
match
(
'banana_sample.gif'
)
}
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
(
'banana_sample.gif'
)
}
end
context
'for valid png file'
do
...
...
@@ -29,13 +29,13 @@ describe Projects::UploadService do
@link_to_file
=
upload_file
(
@project
.
repository
,
png
)
end
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
(
:alt
)
}
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_key
(
'is_image'
)
}
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
(
'dk.png'
)
}
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
[
:url
]).
to
match
(
"/
#{
@project
.
path_with_namespace
}
"
)
}
it
{
expect
(
@link_to_file
[
:url
]).
to
match
(
'dk.png'
)
}
end
context
'for valid jpg file'
do
...
...
@@ -44,13 +44,13 @@ describe Projects::UploadService do
@link_to_file
=
upload_file
(
@project
.
repository
,
jpg
)
end
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
(
'is_image'
)
}
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
(
:is_image
)
}
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
[
'url'
]).
to
match
(
"/
#{
@project
.
path_with_namespace
}
"
)
}
it
{
expect
(
@link_to_file
[
'url'
]).
to
match
(
'rails_sample.jpg'
)
}
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
(
'rails_sample.jpg'
)
}
end
context
'for txt file'
do
...
...
@@ -59,13 +59,13 @@ describe Projects::UploadService do
@link_to_file
=
upload_file
(
@project
.
repository
,
txt
)
end
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
(
'is_image'
)
}
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
(
:is_image
)
}
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
[
'url'
]).
to
match
(
"/
#{
@project
.
path_with_namespace
}
"
)
}
it
{
expect
(
@link_to_file
[
'url'
]).
to
match
(
'doc_sample.txt'
)
}
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
(
'doc_sample.txt'
)
}
end
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