Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
weixin_authorize
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_common
weixin_authorize
Commits
f2e55732
Commit
f2e55732
authored
Apr 19, 2014
by
lanrion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated media_spec
parent
8f57fa4a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
14 deletions
+49
-14
spec/api/media_spec.rb
+49
-14
No files found.
spec/api/media_spec.rb
View file @
f2e55732
...
@@ -2,36 +2,71 @@ require "spec_helper"
...
@@ -2,36 +2,71 @@ require "spec_helper"
describe
WeixinAuthorize
::
Api
::
Media
do
describe
WeixinAuthorize
::
Api
::
Media
do
let
(
:image_path
)
do
let
(
:image_
jpg_
path
)
do
"
#{
File
.
dirname
(
__FILE__
)
}
/medias/ruby-logo.jpg"
"
#{
File
.
dirname
(
__FILE__
)
}
/medias/ruby-logo.jpg"
end
end
let
(
:image_
file
)
do
let
(
:image_
ico_path
)
do
File
.
new
(
image_path
)
"
#{
File
.
dirname
(
__FILE__
)
}
/medias/favicon.ico"
end
end
let
(
:remote_image_path
)
do
let
(
:image_jpg_file
)
do
File
.
new
(
image_jpg_path
)
end
let
(
:image_ico_file
)
do
File
.
new
(
image_ico_path
)
end
let
(
:remote_png_path
)
do
"http://l.ruby-china.org/user/large_avatar/273.png"
"http://l.ruby-china.org/user/large_avatar/273.png"
# "http://g.hiphotos.baidu.com/baike/c0%3Dbaike80%2C5%2C5%2C80%2C26/sign=ce55457e4334970a537e187df4a3baad/03087bf40ad162d99455ef4d13dfa9ec8b13632762d0ed14.jpg"
end
end
it
"can upload a image"
do
let
(
:remote_jpg_path
)
do
response
=
$client
.
upload_media
(
image_file
,
"image"
)
"http://g.hiphotos.baidu.com/baike/c0%3Dbaike80%2C5%2C5%2C80%2C26/sign=ce55457e4334970a537e187df4a3baad/03087bf40ad162d99455ef4d13dfa9ec8b13632762d0ed14.jpg"
end
it
"can upload a jpg File image"
do
response
=
$client
.
upload_media
(
image_jpg_file
,
"image"
)
expect
(
response
.
code
).
to
eq
(
WeixinAuthorize
::
OK_CODE
)
expect
(
response
.
code
).
to
eq
(
WeixinAuthorize
::
OK_CODE
)
expect
(
response
.
result
.
keys
).
to
eq
([
"type"
,
"media_id"
,
"created_at"
])
expect
(
response
.
result
.
keys
).
to
eq
([
"type"
,
"media_id"
,
"created_at"
])
end
end
it
"#download_media_url return a String url"
do
it
"can upload a ico File image"
do
image
=
$client
.
upload_media
(
image_file
,
"image"
)
response
=
$client
.
upload_media
(
image_ico_file
,
"image"
)
media_id
=
image
.
result
[
"media_id"
]
expect
(
response
.
code
).
to
eq
(
WeixinAuthorize
::
OK_CODE
)
response
=
$client
.
download_media_url
(
media_id
)
expect
(
response
.
result
.
keys
).
to
eq
([
"type"
,
"media_id"
,
"created_at"
])
expect
(
response
.
class
).
to
eq
(
String
)
end
it
"can upload a local image"
do
response
=
$client
.
upload_media
(
image_jpg_path
,
"image"
)
expect
(
response
.
code
).
to
eq
(
WeixinAuthorize
::
OK_CODE
)
expect
(
response
.
result
.
keys
).
to
eq
([
"type"
,
"media_id"
,
"created_at"
])
end
end
it
"can upload a
remote
image"
do
it
"can upload a
local ico
image"
do
response
=
$client
.
upload_media
(
remote_image_path
,
"image"
,
true
)
response
=
$client
.
upload_media
(
image_ico_path
,
"image"
)
expect
(
response
.
code
).
to
eq
(
WeixinAuthorize
::
OK_CODE
)
expect
(
response
.
code
).
to
eq
(
WeixinAuthorize
::
OK_CODE
)
expect
(
response
.
result
.
keys
).
to
eq
([
"type"
,
"media_id"
,
"created_at"
])
expect
(
response
.
result
.
keys
).
to
eq
([
"type"
,
"media_id"
,
"created_at"
])
end
end
it
"can upload a remote png image"
do
response
=
$client
.
upload_media
(
remote_png_path
,
"image"
)
expect
(
response
.
code
).
to
eq
(
WeixinAuthorize
::
OK_CODE
)
expect
(
response
.
result
.
keys
).
to
eq
([
"type"
,
"media_id"
,
"created_at"
])
end
it
"can upload a remote jpg image"
do
response
=
$client
.
upload_media
(
remote_jpg_path
,
"image"
)
expect
(
response
.
code
).
to
eq
(
WeixinAuthorize
::
OK_CODE
)
expect
(
response
.
result
.
keys
).
to
eq
([
"type"
,
"media_id"
,
"created_at"
])
end
it
"#download_media_url return a String url"
do
image
=
$client
.
upload_media
(
image_ico_path
,
"image"
)
media_id
=
image
.
result
[
"media_id"
]
image_url
=
$client
.
download_media_url
(
media_id
)
expect
(
image_url
.
class
).
to
eq
(
String
)
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