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
5256863c
Commit
5256863c
authored
Apr 05, 2014
by
lanrion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adjust for error handler modify
parent
90626d36
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
47 additions
and
30 deletions
+47
-30
.travis.yml
+3
-1
spec/api/custom_spec.rb
+4
-4
spec/api/groups_spec.rb
+14
-14
spec/api/media_spec.rb
+3
-2
spec/api/menu_spec.rb
+10
-3
spec/api/qrcode_spec.rb
+5
-3
spec/api/user_spec.rb
+6
-3
spec/spec_helper.rb
+2
-0
No files found.
.travis.yml
View file @
5256863c
...
@@ -2,7 +2,9 @@ language: ruby
...
@@ -2,7 +2,9 @@ language: ruby
bundler_args
:
--without development
bundler_args
:
--without development
rvm
:
rvm
:
-
2.0.0
-
2.0.0
script
:
bundle exec rspec spec
script
:
-
CODECLIMATE_REPO_TOKEN=c91fecbbd9e414e7cc3ad7a7d99207145de0ac65a3368de09e8c19295343d399 bundle exec rake"
-
bundle exec rspec spec
services
:
services
:
-
redis
-
redis
addons
:
addons
:
...
...
spec/api/custom_spec.rb
View file @
5256863c
...
@@ -15,7 +15,7 @@ describe WeixinAuthorize::Api::Custom do
...
@@ -15,7 +15,7 @@ describe WeixinAuthorize::Api::Custom do
it
"#send_text_custom"
do
it
"#send_text_custom"
do
response
=
$client
.
send_text_custom
(
ENV
[
"OPENID"
],
text_message
)
response
=
$client
.
send_text_custom
(
ENV
[
"OPENID"
],
text_message
)
expect
(
response
[
"errcode"
]).
to
eq
(
0
)
expect
(
response
.
code
).
to
eq
(
WeixinAuthorize
::
OK_CODE
)
end
end
it
"#send_news_custom"
do
it
"#send_news_custom"
do
...
@@ -32,14 +32,14 @@ describe WeixinAuthorize::Api::Custom do
...
@@ -32,14 +32,14 @@ describe WeixinAuthorize::Api::Custom do
"picurl"
=>
"http://www.baidu.com/img/bdlogo.gif"
"picurl"
=>
"http://www.baidu.com/img/bdlogo.gif"
}]
}]
response
=
$client
.
send_news_custom
(
ENV
[
"OPENID"
],
articles
)
response
=
$client
.
send_news_custom
(
ENV
[
"OPENID"
],
articles
)
expect
(
response
[
"errcode"
]).
to
eq
(
0
)
expect
(
response
.
code
).
to
eq
(
WeixinAuthorize
::
OK_CODE
)
end
end
it
"#send_image_custom"
do
it
"#send_image_custom"
do
image
=
$client
.
upload_media
(
image_file
,
"image"
)
image
=
$client
.
upload_media
(
image_file
,
"image"
)
media_id
=
image
[
"media_id"
]
media_id
=
image
.
result
[
"media_id"
]
response
=
$client
.
send_image_custom
(
ENV
[
"OPENID"
],
media_id
)
response
=
$client
.
send_image_custom
(
ENV
[
"OPENID"
],
media_id
)
expect
(
response
[
"errcode"
]).
to
eq
(
0
)
expect
(
response
.
code
).
to
eq
(
WeixinAuthorize
::
OK_CODE
)
end
end
it
"#send_video_custom"
do
it
"#send_video_custom"
do
...
...
spec/api/groups_spec.rb
View file @
5256863c
...
@@ -11,44 +11,44 @@ describe WeixinAuthorize::Api::Groups do
...
@@ -11,44 +11,44 @@ describe WeixinAuthorize::Api::Groups do
it
"create a group"
do
it
"create a group"
do
response
=
$client
.
create_group
(
group_name
)
response
=
$client
.
create_group
(
group_name
)
if
!
response
[
"errcode"
].
nil?
if
response
.
code
==
WeixinAuthorize
::
OK_CODE
expect
(
response
.
keys
).
to
eq
([
"errcode"
,
"errmsg"
])
puts
"SB WEIXIN says: system error"
else
expect
(
response
[
"group"
][
"name"
]).
to
eq
(
group_name
)
expect
(
response
[
"group"
][
"name"
]).
to
eq
(
group_name
)
else
expect
(
response
.
code
).
to
eq
(
-
1
)
puts
"SB WEIXIN says: system error"
end
end
end
end
it
"get groups"
do
it
"get groups"
do
groups
=
$client
.
groups
groups
=
$client
.
groups
expect
(
groups
[
"groups"
][
-
1
][
"name"
]).
to
eq
(
group_name
)
expect
(
groups
.
result
[
"groups"
][
-
1
][
"name"
]).
to
eq
(
group_name
)
end
end
it
"#get_group_for ENV['OPENID']"
do
it
"#get_group_for ENV['OPENID']"
do
group
=
$client
.
get_group_for
(
ENV
[
"OPENID"
])
group
=
$client
.
get_group_for
(
ENV
[
"OPENID"
])
expect
(
group
.
keys
).
to
eq
([
"groupid"
])
expect
(
group
.
result
.
keys
).
to
eq
([
"groupid"
])
end
end
it
"#update_group_name"
do
it
"#update_group_name"
do
response
=
$client
.
create_group
(
group_name
)
response
=
$client
.
create_group
(
group_name
)
if
!
response
[
"errcode"
].
nil?
if
response
.
code
!=
WeixinAuthorize
::
OK_CODE
expect
(
response
.
keys
).
to
eq
([
"errcode"
,
"errmsg"
]
)
expect
(
response
.
code
).
to
eq
(
-
1
)
puts
"SB WEIXIN says: system error"
puts
"SB WEIXIN says: system error"
else
else
expect
(
response
[
"group"
][
"name"
]).
to
eq
(
group_name
)
expect
(
response
.
result
[
"group"
][
"name"
]).
to
eq
(
group_name
)
response
=
$client
.
update_group_name
(
response
[
"group"
][
"id"
],
group_name_2
)
response
=
$client
.
update_group_name
(
response
.
result
[
"group"
][
"id"
],
group_name_2
)
expect
(
response
[
"errcode"
]).
to
eq
(
0
)
expect
(
response
.
code
).
to
eq
(
WeixinAuthorize
::
OK_CODE
)
groups
=
$client
.
groups
groups
=
$client
.
groups
expect
(
groups
[
"groups"
][
-
1
][
"name"
]).
to
eq
(
group_name_2
)
expect
(
groups
.
result
[
"groups"
][
-
1
][
"name"
]).
to
eq
(
group_name_2
)
end
end
end
end
it
"#update_group_for_openid"
do
it
"#update_group_for_openid"
do
groups
=
$client
.
groups
groups
=
$client
.
groups
last_group_id
=
groups
[
"groups"
][
-
1
][
"id"
]
last_group_id
=
groups
.
result
[
"groups"
][
-
1
][
"id"
]
$client
.
update_group_for_openid
(
ENV
[
"OPENID"
],
last_group_id
)
$client
.
update_group_for_openid
(
ENV
[
"OPENID"
],
last_group_id
)
group
=
$client
.
get_group_for
(
ENV
[
"OPENID"
])
group
=
$client
.
get_group_for
(
ENV
[
"OPENID"
])
expect
(
group
[
"groupid"
]).
to
eq
(
last_group_id
)
expect
(
group
.
result
[
"groupid"
]).
to
eq
(
last_group_id
)
$client
.
update_group_for_openid
(
ENV
[
"OPENID"
],
0
)
$client
.
update_group_for_openid
(
ENV
[
"OPENID"
],
0
)
end
end
...
...
spec/api/media_spec.rb
View file @
5256863c
...
@@ -12,12 +12,13 @@ describe WeixinAuthorize::Api::Media do
...
@@ -12,12 +12,13 @@ describe WeixinAuthorize::Api::Media do
it
"can upload a image"
do
it
"can upload a image"
do
response
=
$client
.
upload_media
(
image_file
,
"image"
)
response
=
$client
.
upload_media
(
image_file
,
"image"
)
expect
(
response
.
keys
).
to
eq
([
"type"
,
"media_id"
,
"created_at"
])
expect
(
response
.
code
).
to
eq
(
WeixinAuthorize
::
OK_CODE
)
expect
(
response
.
result
.
keys
).
to
eq
([
"type"
,
"media_id"
,
"created_at"
])
end
end
it
"#download_media_url return a String url"
do
it
"#download_media_url return a String url"
do
image
=
$client
.
upload_media
(
image_file
,
"image"
)
image
=
$client
.
upload_media
(
image_file
,
"image"
)
media_id
=
image
[
"media_id"
]
media_id
=
image
.
result
[
"media_id"
]
response
=
$client
.
download_media_url
(
media_id
)
response
=
$client
.
download_media_url
(
media_id
)
expect
(
response
.
class
).
to
eq
(
String
)
expect
(
response
.
class
).
to
eq
(
String
)
end
end
...
...
spec/api/menu_spec.rb
View file @
5256863c
...
@@ -6,16 +6,23 @@ describe WeixinAuthorize::Api::Menu do
...
@@ -6,16 +6,23 @@ describe WeixinAuthorize::Api::Menu do
it
"can create a menu"
do
it
"can create a menu"
do
menu
=
'{"button":[{"type":"click","name":"今日歌曲","key":"V1001_TODAY_MUSIC"},{"type":"click","name":"歌手简介","key":"V1001_TODAY_SINGER"},{"name":"菜单","sub_button":[{"type":"view","name":"搜索","url":"http://www.soso.com/"},{"type":"view","name":"视频","url":"http://v.qq.com/"},{"type":"click","name":"赞一下我们","key":"V1001_GOOD"}]}]}'
menu
=
'{"button":[{"type":"click","name":"今日歌曲","key":"V1001_TODAY_MUSIC"},{"type":"click","name":"歌手简介","key":"V1001_TODAY_SINGER"},{"name":"菜单","sub_button":[{"type":"view","name":"搜索","url":"http://www.soso.com/"},{"type":"view","name":"视频","url":"http://v.qq.com/"},{"type":"click","name":"赞一下我们","key":"V1001_GOOD"}]}]}'
response
=
$client
.
create_menu
(
MultiJson
.
load
(
menu
))
# or Json string
response
=
$client
.
create_menu
(
MultiJson
.
load
(
menu
))
# or Json string
expect
(
response
[
"errcode"
]).
to
eq
(
0
)
expect
(
response
.
code
).
to
eq
(
WeixinAuthorize
::
OK_CODE
)
end
it
"can't create a menu if invalid button size"
do
menu
=
'{"button":[]}'
response
=
$client
.
create_menu
(
menu
)
expect
(
response
.
code
).
not_to
eq
(
WeixinAuthorize
::
OK_CODE
)
end
end
it
"can get a weixin Menu info"
do
it
"can get a weixin Menu info"
do
menu_info
=
$client
.
menu
menu_info
=
$client
.
menu
expect
(
menu_info
.
keys
[
0
]).
to
eq
(
"menu"
)
expect
(
menu_info
.
result
.
keys
[
0
]).
to
eq
(
"menu"
)
expect
(
menu_info
.
code
).
to
eq
(
WeixinAuthorize
::
OK_CODE
)
end
end
it
"can delete weixin Menu"
do
it
"can delete weixin Menu"
do
response
=
$client
.
delete_menu
response
=
$client
.
delete_menu
expect
(
response
[
"errcode"
]).
to
eq
(
0
)
expect
(
response
.
code
).
to
eq
(
WeixinAuthorize
::
OK_CODE
)
end
end
end
end
spec/api/qrcode_spec.rb
View file @
5256863c
...
@@ -4,13 +4,15 @@ describe WeixinAuthorize::Api::Qrcode do
...
@@ -4,13 +4,15 @@ describe WeixinAuthorize::Api::Qrcode do
it
"#create_qr_scene"
do
it
"#create_qr_scene"
do
response
=
$client
.
create_qr_scene
(
"123"
)
response
=
$client
.
create_qr_scene
(
"123"
)
expect
(
response
.
keys
).
to
eq
([
"ticket"
,
"expire_seconds"
])
expect
(
response
.
code
).
to
eq
(
WeixinAuthorize
::
OK_CODE
)
expect
(
response
[
"expire_seconds"
]).
to
eq
(
1800
)
expect
(
response
.
result
.
keys
).
to
eq
([
"ticket"
,
"expire_seconds"
])
expect
(
response
.
result
[
"expire_seconds"
]).
to
eq
(
1800
)
end
end
it
"#create_qr_limit_scene"
do
it
"#create_qr_limit_scene"
do
response
=
$client
.
create_qr_limit_scene
(
"1234"
)
response
=
$client
.
create_qr_limit_scene
(
"1234"
)
expect
(
response
.
keys
).
to
eq
([
"ticket"
])
expect
(
response
.
code
).
to
eq
(
WeixinAuthorize
::
OK_CODE
)
expect
(
response
.
result
.
keys
).
to
eq
([
"ticket"
])
end
end
end
end
spec/api/user_spec.rb
View file @
5256863c
...
@@ -3,18 +3,21 @@ require "spec_helper"
...
@@ -3,18 +3,21 @@ require "spec_helper"
describe
WeixinAuthorize
::
Api
::
User
do
describe
WeixinAuthorize
::
Api
::
User
do
it
"can get a weixin User info"
do
it
"can get a weixin User info"
do
user_info
=
$client
.
user
(
ENV
[
"OPENID"
])
user_info
=
$client
.
user
(
ENV
[
"OPENID"
])
expect
(
user_info
[
"openid"
]).
to
eq
(
ENV
[
"OPENID"
])
expect
(
user_info
.
code
).
to
eq
(
WeixinAuthorize
::
OK_CODE
)
expect
(
user_info
.
result
[
"openid"
]).
to
eq
(
ENV
[
"OPENID"
])
end
end
it
"can get followers infos"
do
it
"can get followers infos"
do
valid_info
=
$client
.
is_valid?
valid_info
=
$client
.
is_valid?
expect
(
valid_info
).
to
eq
(
true
)
expect
(
valid_info
).
to
eq
(
true
)
followers
=
$client
.
followers
followers
=
$client
.
followers
expect
(
followers
.
keys
).
to
eq
([
"total"
,
"count"
,
"data"
,
"next_openid"
])
expect
(
followers
.
code
).
to
eq
(
WeixinAuthorize
::
OK_CODE
)
expect
(
followers
.
result
.
keys
).
to
eq
([
"total"
,
"count"
,
"data"
,
"next_openid"
])
valid_info
=
$client
.
is_valid?
valid_info
=
$client
.
is_valid?
expect
(
valid_info
).
to
eq
(
true
)
expect
(
valid_info
).
to
eq
(
true
)
followers
=
$client
.
followers
followers
=
$client
.
followers
expect
(
followers
.
keys
).
to
eq
([
"total"
,
"count"
,
"data"
,
"next_openid"
])
expect
(
followers
.
code
).
to
eq
(
WeixinAuthorize
::
OK_CODE
)
expect
(
followers
.
result
.
keys
).
to
eq
([
"total"
,
"count"
,
"data"
,
"next_openid"
])
end
end
end
end
spec/spec_helper.rb
View file @
5256863c
...
@@ -23,6 +23,8 @@ require 'coveralls'
...
@@ -23,6 +23,8 @@ require 'coveralls'
require
'simplecov'
require
'simplecov'
require
"codeclimate-test-reporter"
require
"codeclimate-test-reporter"
require
"pry-rails"
SimpleCov
.
formatter
=
SimpleCov
::
Formatter
::
MultiFormatter
[
SimpleCov
.
formatter
=
SimpleCov
::
Formatter
::
MultiFormatter
[
SimpleCov
::
Formatter
::
HTMLFormatter
,
SimpleCov
::
Formatter
::
HTMLFormatter
,
Coveralls
::
SimpleCov
::
Formatter
Coveralls
::
SimpleCov
::
Formatter
...
...
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