zendesk_api 0.1.11 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +3 -0
- data/.travis.yml +1 -3
- data/Gemfile +24 -0
- data/Gemfile.lock +75 -10
- data/Procfile +1 -0
- data/Rakefile +10 -3
- data/Readme.md +65 -0
- data/bin/zendesk +26 -0
- data/config.ru +6 -0
- data/config/mongoid.yml +81 -0
- data/lib/zendesk_api/actions.rb +2 -2
- data/lib/zendesk_api/collection.rb +15 -4
- data/lib/zendesk_api/console/base.rb +12 -0
- data/lib/zendesk_api/console/console.rb +144 -0
- data/lib/zendesk_api/console/extensions.rb +183 -0
- data/lib/zendesk_api/console/options.rb +41 -0
- data/lib/zendesk_api/resource.rb +12 -1
- data/lib/zendesk_api/resources.rb +28 -8
- data/lib/zendesk_api/server/base.rb +119 -0
- data/lib/zendesk_api/server/docs/account_settings.md +145 -0
- data/lib/zendesk_api/server/docs/activity_stream.md +121 -0
- data/lib/zendesk_api/server/docs/attachments.md +73 -0
- data/lib/zendesk_api/server/docs/autocomplete.md +29 -0
- data/lib/zendesk_api/server/docs/categories.md +193 -0
- data/lib/zendesk_api/server/docs/custom_roles.md +88 -0
- data/lib/zendesk_api/server/docs/forum_subscriptions.md +139 -0
- data/lib/zendesk_api/server/docs/forums.md +229 -0
- data/lib/zendesk_api/server/docs/group_memberships.md +229 -0
- data/lib/zendesk_api/server/docs/groups.md +212 -0
- data/lib/zendesk_api/server/docs/introduction.md +159 -0
- data/lib/zendesk_api/server/docs/job_statuses.md +86 -0
- data/lib/zendesk_api/server/docs/locales.md +124 -0
- data/lib/zendesk_api/server/docs/macros.md +287 -0
- data/lib/zendesk_api/server/docs/organizations.md +253 -0
- data/lib/zendesk_api/server/docs/problems.md +117 -0
- data/lib/zendesk_api/server/docs/requests.md +256 -0
- data/lib/zendesk_api/server/docs/satisfaction_ratings.md +136 -0
- data/lib/zendesk_api/server/docs/search.md +106 -0
- data/lib/zendesk_api/server/docs/sharing_agreements.md +57 -0
- data/lib/zendesk_api/server/docs/side_loading.md +125 -0
- data/lib/zendesk_api/server/docs/suspended_tickets.md +182 -0
- data/lib/zendesk_api/server/docs/tags.md +36 -0
- data/lib/zendesk_api/server/docs/ticket_audits.md +657 -0
- data/lib/zendesk_api/server/docs/ticket_export.md +121 -0
- data/lib/zendesk_api/server/docs/ticket_fields.md +277 -0
- data/lib/zendesk_api/server/docs/ticket_import.md +65 -0
- data/lib/zendesk_api/server/docs/ticket_metrics.md +125 -0
- data/lib/zendesk_api/server/docs/tickets.md +622 -0
- data/lib/zendesk_api/server/docs/topic_comments.md +221 -0
- data/lib/zendesk_api/server/docs/topic_subscriptions.md +140 -0
- data/lib/zendesk_api/server/docs/topic_votes.md +154 -0
- data/lib/zendesk_api/server/docs/topics.md +335 -0
- data/lib/zendesk_api/server/docs/triggers.md +199 -0
- data/lib/zendesk_api/server/docs/user_identities.md +279 -0
- data/lib/zendesk_api/server/docs/users.md +400 -0
- data/lib/zendesk_api/server/docs/views.md +505 -0
- data/lib/zendesk_api/server/helper.rb +104 -0
- data/lib/zendesk_api/server/html_renderer.rb +98 -0
- data/lib/zendesk_api/server/models/user_request.rb +16 -0
- data/lib/zendesk_api/server/models/zlib_json.rb +13 -0
- data/lib/zendesk_api/server/public/config.rb +26 -0
- data/lib/zendesk_api/server/public/favicon.ico +0 -0
- data/lib/zendesk_api/server/public/images/glyphicons-halflings-white.png +0 -0
- data/lib/zendesk_api/server/public/images/glyphicons-halflings.png +0 -0
- data/lib/zendesk_api/server/public/images/spinner.gif +0 -0
- data/lib/zendesk_api/server/public/images/zendesk_developers_bg.png +0 -0
- data/lib/zendesk_api/server/public/images/zendesk_developers_header.png +0 -0
- data/lib/zendesk_api/server/public/javascripts/application.js +186 -0
- data/lib/zendesk_api/server/public/javascripts/bootstrap-alert.js +90 -0
- data/lib/zendesk_api/server/public/javascripts/bootstrap-button.js +96 -0
- data/lib/zendesk_api/server/public/javascripts/bootstrap-carousel.js +169 -0
- data/lib/zendesk_api/server/public/javascripts/bootstrap-collapse.js +157 -0
- data/lib/zendesk_api/server/public/javascripts/bootstrap-dropdown.js +100 -0
- data/lib/zendesk_api/server/public/javascripts/bootstrap-modal.js +218 -0
- data/lib/zendesk_api/server/public/javascripts/bootstrap-popover.js +98 -0
- data/lib/zendesk_api/server/public/javascripts/bootstrap-scrollspy.js +151 -0
- data/lib/zendesk_api/server/public/javascripts/bootstrap-tab.js +135 -0
- data/lib/zendesk_api/server/public/javascripts/bootstrap-tooltip.js +275 -0
- data/lib/zendesk_api/server/public/javascripts/bootstrap-transition.js +61 -0
- data/lib/zendesk_api/server/public/javascripts/bootstrap-typeahead.js +285 -0
- data/lib/zendesk_api/server/public/sass/screen.scss +102 -0
- data/lib/zendesk_api/server/public/sass/styles.scss +5 -0
- data/lib/zendesk_api/server/public/stylesheets/developer.screen.css +836 -0
- data/lib/zendesk_api/server/public/stylesheets/screen.css +129 -0
- data/lib/zendesk_api/server/public/stylesheets/styles.css +6208 -0
- data/lib/zendesk_api/server/templates/footer.haml +13 -0
- data/lib/zendesk_api/server/templates/header.haml +20 -0
- data/lib/zendesk_api/server/templates/index.haml +68 -0
- data/lib/zendesk_api/server/templates/layout.haml +44 -0
- data/lib/zendesk_api/server/templates/param.haml +4 -0
- data/lib/zendesk_api/server/templates/search.haml +23 -0
- data/lib/zendesk_api/server/templates/sidebar.haml +7 -0
- data/lib/zendesk_api/version.rb +1 -1
- data/spec/{association_spec.rb → core/association_spec.rb} +1 -1
- data/spec/{client_spec.rb → core/client_spec.rb} +1 -1
- data/spec/{collection_spec.rb → core/collection_spec.rb} +1 -1
- data/spec/{configuration_spec.rb → core/configuration_spec.rb} +1 -1
- data/spec/{create_resource_spec.rb → core/create_resource_spec.rb} +1 -1
- data/spec/{data_resource_spec.rb → core/data_resource_spec.rb} +1 -1
- data/spec/{inflection_spec.rb → core/inflection_spec.rb} +1 -1
- data/spec/{lru_cache_spec.rb → core/lru_cache_spec.rb} +1 -1
- data/spec/{middleware → core/middleware}/request/etag_cache_spec.rb +1 -1
- data/spec/{middleware → core/middleware}/request/retry_spec.rb +1 -1
- data/spec/{middleware → core/middleware}/request/test.jpg +0 -0
- data/spec/{middleware → core/middleware}/request/upload_spec.rb +1 -1
- data/spec/{middleware → core/middleware}/response/callback_spec.rb +1 -1
- data/spec/{middleware → core/middleware}/response/deflate_spec.rb +1 -1
- data/spec/{middleware → core/middleware}/response/gzip_spec.rb +1 -1
- data/spec/{middleware → core/middleware}/response/parse_iso_dates_spec.rb +1 -1
- data/spec/{read_resource_spec.rb → core/read_resource_spec.rb} +1 -1
- data/spec/{rescue_spec.rb → core/rescue_spec.rb} +1 -1
- data/spec/{resource_spec.rb → core/resource_spec.rb} +1 -1
- data/spec/{search_spec.rb → core/search_spec.rb} +1 -1
- data/spec/{spec_helper.rb → core/spec_helper.rb} +5 -5
- data/spec/{trackie_spec.rb → core/trackie_spec.rb} +1 -1
- data/{live → spec/live}/Readme.md +0 -0
- data/{live → spec/live}/activity_spec.rb +1 -1
- data/{live → spec/live}/audit_spec.rb +1 -1
- data/{live → spec/live}/bookmark_spec.rb +1 -1
- data/{live → spec/live}/category_spec.rb +1 -1
- data/{live → spec/live}/collection_spec.rb +1 -1
- data/{live → spec/live}/crm_spec.rb +1 -1
- data/{live → spec/live}/custom_role_spec.rb +1 -1
- data/{live → spec/live}/forum_spec.rb +1 -1
- data/{live → spec/live}/forum_subscription_spec.rb +1 -1
- data/{live → spec/live}/group_membership_spec.rb +1 -1
- data/{live → spec/live}/group_spec.rb +1 -1
- data/{live → spec/live}/identity_spec.rb +1 -1
- data/{live → spec/live}/locale_spec.rb +1 -1
- data/{live → spec/live}/macro_spec.rb +1 -1
- data/{live → spec/live}/mobile_device_spec.rb +1 -1
- data/{live → spec/live}/organization_spec.rb +1 -1
- data/{live → spec/live}/request_spec.rb +1 -1
- data/{live → spec/live}/satisfaction_rating_spec.rb +1 -1
- data/{live → spec/live}/setting_spec.rb +1 -1
- data/{live → spec/live}/suspended_ticket_spec.rb +1 -1
- data/{live → spec/live}/ticket_field_spec.rb +1 -1
- data/{live → spec/live}/ticket_metrics_spec.rb +1 -1
- data/{live → spec/live}/ticket_spec.rb +1 -1
- data/spec/live/topic_comment_spec.rb +24 -0
- data/{live → spec/live}/topic_spec.rb +1 -1
- data/{live → spec/live}/topic_subscription_spec.rb +1 -1
- data/{live → spec/live}/topic_vote_spec.rb +1 -1
- data/{live → spec/live}/upload_spec.rb +1 -1
- data/{live → spec/live}/user_spec.rb +1 -1
- data/{live → spec/live}/view_spec.rb +1 -1
- data/spec/macros/resource_macros.rb +1 -1
- data/spec/server/app_spec.rb +140 -0
- data/spec/server/helper_spec.rb +97 -0
- data/spec/server/html_renderer_spec.rb +130 -0
- data/spec/server/spec_helper.rb +43 -0
- metadata +198 -77
- data/live/topic_comment_spec.rb +0 -13
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'core/spec_helper'
|
|
2
|
+
|
|
3
|
+
describe ZendeskAPI::Topic::TopicComment do
|
|
4
|
+
def valid_attributes
|
|
5
|
+
{ :body => "Texty-text, text." }
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
under topic do
|
|
9
|
+
it_should_be_creatable
|
|
10
|
+
it_should_be_updatable :body
|
|
11
|
+
it_should_be_deletable
|
|
12
|
+
it_should_be_readable topic, :comments
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
describe ZendeskAPI::User::TopicComment do
|
|
17
|
+
def valid_attributes
|
|
18
|
+
{ :body => "Texty-text, text."}
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
under current_user do
|
|
22
|
+
it_should_be_readable current_user, :topic_comments
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -149,7 +149,7 @@ module ResourceMacros
|
|
|
149
149
|
if described_class.respond_to?(:find) && !example.metadata[:not_findable]
|
|
150
150
|
options = default_options
|
|
151
151
|
options.merge!(:id => object.id) unless described_class.ancestors.include?(ZendeskAPI::SingularResource)
|
|
152
|
-
described_class.find(client, options).should_not be_nil
|
|
152
|
+
described_class.find(client, options).should_not be_nil
|
|
153
153
|
end
|
|
154
154
|
end
|
|
155
155
|
end
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
require 'server/spec_helper'
|
|
2
|
+
|
|
3
|
+
describe ZendeskAPI::Server::App do
|
|
4
|
+
context "configuration" do
|
|
5
|
+
subject { described_class.settings }
|
|
6
|
+
|
|
7
|
+
context "documentation" do
|
|
8
|
+
# TODO
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
context "a GET to /" do
|
|
13
|
+
before { get '/' }
|
|
14
|
+
|
|
15
|
+
it "should respond ok" do
|
|
16
|
+
last_response.status.should == 200
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
context "a GET to /:object_id" do
|
|
21
|
+
context "with a stored object" do
|
|
22
|
+
subject do
|
|
23
|
+
ZendeskAPI::Server::UserRequest.create(
|
|
24
|
+
:username => "test",
|
|
25
|
+
:method => :post,
|
|
26
|
+
:url => "http://my.url.com",
|
|
27
|
+
:json => '{"hello": "goodbye"}',
|
|
28
|
+
:url_params => [{ :name => :a, :value => :b }],
|
|
29
|
+
:request => {}, # TODO
|
|
30
|
+
:response => {}
|
|
31
|
+
)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
before { get "/#{subject._id}" }
|
|
35
|
+
|
|
36
|
+
it "should respond ok" do
|
|
37
|
+
last_response.status.should == 200
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "should fill in url field" do
|
|
41
|
+
last_response.body.should include "value='http://my.url.com'"
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "should fill in json field" do
|
|
45
|
+
last_response.body.should include subject.json
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it "should select the proper method" do
|
|
49
|
+
last_response.body.should include "selected value='POST'"
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it "should add url param" do
|
|
53
|
+
last_response.body.should include "value='a'"
|
|
54
|
+
last_response.body.should include "value='b'"
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
context "with no object" do
|
|
59
|
+
before { get '/1234567876543' }
|
|
60
|
+
|
|
61
|
+
it "should respond ok" do
|
|
62
|
+
last_response.status.should == 200
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
context "a POST to /" do
|
|
68
|
+
context "valid" do
|
|
69
|
+
before do
|
|
70
|
+
stub_json_request(:put, "https://me:2@smersh.zendesk.com/api/v2/users.json?id=1").with(:body => '{"hello":1}')
|
|
71
|
+
|
|
72
|
+
post '/', :method => "PUT", :url => "https://smersh.zendesk.com/api/v2/users.json",
|
|
73
|
+
:params => [{ "name" => "id", "value" => "1" }, {}], :json => '{"hello":1}',
|
|
74
|
+
:username => "me", :password => "2"
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it "should return ok" do
|
|
78
|
+
last_response.status.should == 200
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
context "user request" do
|
|
82
|
+
it "should not save authorization data" do
|
|
83
|
+
user_request = ZendeskAPI::Server::UserRequest.last
|
|
84
|
+
user_request.request[:request_headers]["Authorization"].should be_nil
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
context "invalid url" do
|
|
90
|
+
before do
|
|
91
|
+
post '/', :url => "http://nowheresville.com", :method => "PUT"
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
it "should set the error" do
|
|
95
|
+
last_response.body.should =~ /valid URL/
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
context "invalid" do
|
|
100
|
+
before do
|
|
101
|
+
@user_requests = ZendeskAPI::Server::UserRequest.count
|
|
102
|
+
|
|
103
|
+
post '/', :method => "OMG", :url => "https://nowheresville.com",
|
|
104
|
+
:params => [{ "name" => "", "value" => "11243" }, {}], :json => '{"hello":1}',
|
|
105
|
+
:username => "me", :password => "2"
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
it "should not save user request" do
|
|
109
|
+
ZendeskAPI::Server::UserRequest.count.should == @user_requests
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
it "should return ok" do
|
|
113
|
+
last_response.status.should == 200
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
context "a POST to /search" do
|
|
119
|
+
subject do
|
|
120
|
+
post '/search', :query => query
|
|
121
|
+
last_response.body
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
context "valid documentation" do
|
|
125
|
+
let(:query) { "users" }
|
|
126
|
+
|
|
127
|
+
it "should return the correct documentation" do
|
|
128
|
+
should == described_class.settings.documentation["users"][:body]
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
context "invalid query" do
|
|
133
|
+
let(:query) { "omgnotreal" }
|
|
134
|
+
|
|
135
|
+
it "should return the introduction" do
|
|
136
|
+
should == described_class.settings.help
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
end
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
require 'server/spec_helper'
|
|
2
|
+
|
|
3
|
+
describe ZendeskAPI::Server::Helper do
|
|
4
|
+
subject do
|
|
5
|
+
Class.new do
|
|
6
|
+
include ZendeskAPI::Server::Helper
|
|
7
|
+
def params; @params ||= {}; end
|
|
8
|
+
end.new
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
context "coerce path" do
|
|
12
|
+
let(:coerced) do
|
|
13
|
+
subject.coerce_path(path)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
context "with no protocol" do
|
|
17
|
+
let(:path) { "smersh.zendesk.com/api/v2/users" }
|
|
18
|
+
|
|
19
|
+
it "should be assumed as https" do
|
|
20
|
+
coerced.should == "users"
|
|
21
|
+
subject.params["url"].should == "https://smersh.zendesk.com/api/v2"
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
context "with no .zendesk.com" do
|
|
26
|
+
let(:path) { "smersh/api/v2/users" }
|
|
27
|
+
|
|
28
|
+
it "should fill in https and .zendesk.com" do
|
|
29
|
+
coerced.should == "users"
|
|
30
|
+
subject.params["url"].should == "https://smersh.zendesk.com/api/v2"
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
context "with no .zendesk.com and no /api/v2" do
|
|
35
|
+
let(:path) { "smersh/users" }
|
|
36
|
+
|
|
37
|
+
it "should fill in https and .zendesk.com" do
|
|
38
|
+
coerced.should == "users"
|
|
39
|
+
subject.params["url"].should == "https://smersh.zendesk.com/api/v2"
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
context "with an https url" do
|
|
44
|
+
let(:path) { "https://smersh.zendesk.com/api/v2/users" }
|
|
45
|
+
|
|
46
|
+
it "should not change anything" do
|
|
47
|
+
coerced.should == "users"
|
|
48
|
+
subject.params["url"].should == "https://smersh.zendesk.com/api/v2"
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
context "with an http url" do
|
|
53
|
+
let(:path) { "http://smersh.zendesk.com/api/v2/users" }
|
|
54
|
+
|
|
55
|
+
it "should set the error" do
|
|
56
|
+
coerced.should == path
|
|
57
|
+
subject.instance_variable_get(:@error).should_not be_nil
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
context "execute request" do
|
|
63
|
+
before do
|
|
64
|
+
subject.params.merge!(:username => "me", :password => "2", :url => "https://somewhere.com")
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it "should return error if invalid method" do
|
|
68
|
+
subject.instance_variable_set(:@method, "BLARGHL")
|
|
69
|
+
subject.execute_request
|
|
70
|
+
subject.instance_variable_get(:@error).should_not be_nil
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
context "valid request" do
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
context "map headers" do
|
|
78
|
+
it "should combine headers" do
|
|
79
|
+
subject.map_headers("accept-encoding" => "true", "hello" => "123").should ==
|
|
80
|
+
"Accept-Encoding: true\nHello: 123"
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
context "client" do
|
|
85
|
+
it "should set configuration options" do
|
|
86
|
+
subject.client(:username => "me", :password => "2", :url => "https://somewhere").should_not be_nil
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
it "should not allow http in production" do
|
|
90
|
+
app.stub(:development? => false)
|
|
91
|
+
|
|
92
|
+
expect do
|
|
93
|
+
subject.client(:url => "somewhere")
|
|
94
|
+
end.to raise_error ArgumentError
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
require 'server/spec_helper'
|
|
2
|
+
|
|
3
|
+
describe ZendeskAPI::Server::HtmlRenderer do
|
|
4
|
+
context "header" do
|
|
5
|
+
subject { described_class.render(markdown) }
|
|
6
|
+
|
|
7
|
+
before(:each) do
|
|
8
|
+
described_class.instance_variable_set(:@markdown, nil)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
context "h2" do
|
|
12
|
+
let(:markdown) { "## Hello" }
|
|
13
|
+
let(:id) { described_class.generate_id("Hello") }
|
|
14
|
+
|
|
15
|
+
it "should add icons" do
|
|
16
|
+
subject.should =~ /icon-plus/
|
|
17
|
+
subject.should =~ /icon-minus/
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "should generate an id" do
|
|
21
|
+
subject.should =~ /h2 id="#{id}"/
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "should add the id to the headers" do
|
|
25
|
+
subject # Render
|
|
26
|
+
|
|
27
|
+
described_class.markdown.renderer.headers.should include id
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
context "h3" do
|
|
32
|
+
let(:markdown) { "### Hello" }
|
|
33
|
+
let(:id) { described_class.generate_id("Hello") }
|
|
34
|
+
|
|
35
|
+
it "should add icons" do
|
|
36
|
+
subject.should =~ /icon-plus/
|
|
37
|
+
subject.should =~ /icon-minus/
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "should generate an id" do
|
|
41
|
+
subject.should =~ /h3 id="#{described_class.generate_id(id)}"/
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "should add the id to the headers" do
|
|
45
|
+
subject # Render
|
|
46
|
+
|
|
47
|
+
described_class.markdown.renderer.headers.should include id
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
context "h1" do
|
|
52
|
+
let(:markdown) { "# Hello" }
|
|
53
|
+
let(:id) { described_class.generate_id("Hello") }
|
|
54
|
+
|
|
55
|
+
it "should not add icons" do
|
|
56
|
+
subject.should_not =~ /icon-plus/
|
|
57
|
+
subject.should_not =~ /icon-minus/
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it "should generate an id" do
|
|
61
|
+
subject.should =~ /h1 id="#{described_class.generate_id(id)}"/
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it "should not add the id to the headers" do
|
|
65
|
+
subject # Render
|
|
66
|
+
|
|
67
|
+
described_class.markdown.renderer.headers.should_not include id
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
context "code" do
|
|
73
|
+
subject { described_class.render(markdown) }
|
|
74
|
+
|
|
75
|
+
context "curl" do
|
|
76
|
+
let(:markdown) do
|
|
77
|
+
<<-END
|
|
78
|
+
```bash
|
|
79
|
+
curl -v -u someone@something.com https://{subdomain}.zendesk.com/api/v2/my_path.json?id={blah} \
|
|
80
|
+
-d '{"hello": {"goodbye": "see you later"}}' -X PUT
|
|
81
|
+
```
|
|
82
|
+
END
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
it "should have a button" do
|
|
86
|
+
subject.should =~ %r{<button.*</button>}m
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
it "should have a pre" do
|
|
90
|
+
subject.should =~ %r{<pre (.*)>curl .*</pre>}m
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
context "pre modifiers" do
|
|
94
|
+
let(:modifiers) do
|
|
95
|
+
subject =~ %r{<pre (.*)>curl .*</pre>}m && $1
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
it "should have a class" do
|
|
99
|
+
modifiers.should include "class='example'"
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it "should have a data-url" do
|
|
103
|
+
modifiers.should include "data-url='https://{subdomain}.zendesk.com/api/v2/my_path.json?id={blah}'"
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
it "should have a data-json" do
|
|
107
|
+
modifiers.should include "data-json='{\"hello\": {\"goodbye\": \"see you later\"}}'"
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
it "should have a data-method" do
|
|
111
|
+
modifiers.should include "data-method='PUT'"
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
context "other" do
|
|
117
|
+
let(:markdown) do
|
|
118
|
+
<<-END
|
|
119
|
+
```json
|
|
120
|
+
{ "hello": "goodbye" }
|
|
121
|
+
```
|
|
122
|
+
END
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
it "should be wrapped in a pre" do
|
|
126
|
+
subject.should =~ %r{^<pre>.*</pre>$}m
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|