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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
f8a6d340
Commit
f8a6d340
authored
May 26, 2014
by
Marin Jankovski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add image_service spec.
parent
3b2b3cff
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
3 deletions
+65
-3
spec/controllers/projects_controller_spec.rb
spec/controllers/projects_controller_spec.rb
+0
-3
spec/services/projects/image_service_spec.rb
spec/services/projects/image_service_spec.rb
+65
-0
No files found.
spec/controllers/projects_controller_spec.rb
View file @
f8a6d340
...
@@ -3,10 +3,7 @@ require('spec_helper')
...
@@ -3,10 +3,7 @@ require('spec_helper')
describe
ProjectsController
do
describe
ProjectsController
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:png
)
{
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/dk.png'
,
'image/png'
)
}
let
(
:jpg
)
{
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/rails_sample.jpg'
,
'image/jpg'
)
}
let
(
:jpg
)
{
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/rails_sample.jpg'
,
'image/jpg'
)
}
let
(
:gif
)
{
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/banana_sample.gif'
,
'image/gif'
)
}
let
(
:txt
)
{
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/doc_sample.txt'
,
'text/plain'
)
}
describe
"POST #upload_image"
do
describe
"POST #upload_image"
do
before
do
before
do
...
...
spec/services/projects/image_service_spec.rb
0 → 100644
View file @
f8a6d340
require
'spec_helper'
describe
Projects
::
ImageService
do
before
(
:each
)
{
enable_observers
}
after
(
:each
)
{
disable_observers
}
describe
'Image service'
do
before
do
@user
=
create
:user
@project
=
create
:project
,
creator_id:
@user
.
id
,
namespace:
@user
.
namespace
end
context
'for valid gif file'
do
before
do
gif
=
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/banana_sample.gif'
,
'image/gif'
)
@link_to_image
=
upload_image
(
@project
.
repository
,
{
'markdown_img'
=>
gif
},
"http://test.example/"
)
end
it
{
expect
(
@link_to_image
).
to
have_key
(
"alt"
)
}
it
{
expect
(
@link_to_image
).
to
have_key
(
"url"
)
}
it
{
expect
(
@link_to_image
).
to
have_value
(
"banana_sample"
)
}
it
{
expect
(
@link_to_image
[
"url"
]).
to
match
(
"http://test.example/uploads/
#{
@project
.
path_with_namespace
}
"
)
}
it
{
expect
(
@link_to_image
[
"url"
]).
to
match
(
"banana_sample.gif"
)
}
end
context
'for valid png file'
do
before
do
png
=
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/dk.png'
,
'image/png'
)
@link_to_image
=
upload_image
(
@project
.
repository
,
{
'markdown_img'
=>
png
},
"http://test.example/"
)
end
it
{
expect
(
@link_to_image
).
to
have_key
(
"alt"
)
}
it
{
expect
(
@link_to_image
).
to
have_key
(
"url"
)
}
it
{
expect
(
@link_to_image
).
to
have_value
(
"dk"
)
}
it
{
expect
(
@link_to_image
[
"url"
]).
to
match
(
"http://test.example/uploads/
#{
@project
.
path_with_namespace
}
"
)
}
it
{
expect
(
@link_to_image
[
"url"
]).
to
match
(
"dk.png"
)
}
end
context
'for valid jpg file'
do
before
do
jpg
=
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/rails_sample.jpg'
,
'image/jpg'
)
@link_to_image
=
upload_image
(
@project
.
repository
,
{
'markdown_img'
=>
jpg
},
"http://test.example/"
)
end
it
{
expect
(
@link_to_image
).
to
have_key
(
"alt"
)
}
it
{
expect
(
@link_to_image
).
to
have_key
(
"url"
)
}
it
{
expect
(
@link_to_image
).
to
have_value
(
"rails_sample"
)
}
it
{
expect
(
@link_to_image
[
"url"
]).
to
match
(
"http://test.example/uploads/
#{
@project
.
path_with_namespace
}
"
)
}
it
{
expect
(
@link_to_image
[
"url"
]).
to
match
(
"rails_sample.jpg"
)
}
end
context
'for txt file'
do
before
do
txt
=
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/doc_sample.txt'
,
'text/plain'
)
@link_to_image
=
upload_image
(
@project
.
repository
,
{
'markdown_img'
=>
txt
},
"http://test.example/"
)
end
it
{
expect
(
@link_to_image
).
to
be_nil
}
end
end
def
upload_image
(
repository
,
params
,
root_url
)
Projects
::
ImageService
.
new
(
repository
,
params
,
root_url
).
execute
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