drip-ruby 3.2.0 → 3.4.2
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.
- checksums.yaml +5 -5
- data/.github/pull_request_template.md +39 -0
- data/.rubocop.yml +5 -1
- data/.rubocop_todo.yml +17 -9
- data/.travis.yml +2 -4
- data/CHANGELOG.md +51 -1
- data/Gemfile +12 -0
- data/README.md +6 -0
- data/Rakefile +2 -0
- data/drip-ruby.gemspec +4 -11
- data/lib/drip.rb +2 -0
- data/lib/drip/client.rb +48 -66
- data/lib/drip/client/accounts.rb +4 -2
- data/lib/drip/client/broadcasts.rb +4 -2
- data/lib/drip/client/campaign_subscriptions.rb +3 -1
- data/lib/drip/client/campaigns.rb +7 -5
- data/lib/drip/client/configuration.rb +30 -0
- data/lib/drip/client/conversions.rb +4 -2
- data/lib/drip/client/custom_fields.rb +3 -1
- data/lib/drip/client/events.rb +6 -4
- data/lib/drip/client/forms.rb +4 -2
- data/lib/drip/client/http_client.rb +66 -0
- data/lib/drip/client/orders.rb +5 -3
- data/lib/drip/client/shopper_activity.rb +80 -0
- data/lib/drip/client/subscribers.rb +30 -16
- data/lib/drip/client/tags.rb +5 -3
- data/lib/drip/client/users.rb +17 -0
- data/lib/drip/client/webhooks.rb +7 -5
- data/lib/drip/client/workflow_triggers.rb +5 -3
- data/lib/drip/client/workflows.rb +8 -6
- data/lib/drip/collection.rb +2 -0
- data/lib/drip/collections.rb +2 -0
- data/lib/drip/collections/accounts.rb +2 -0
- data/lib/drip/collections/broadcasts.rb +2 -0
- data/lib/drip/collections/campaign_subscriptions.rb +2 -0
- data/lib/drip/collections/campaigns.rb +2 -0
- data/lib/drip/collections/errors.rb +2 -0
- data/lib/drip/collections/orders.rb +2 -0
- data/lib/drip/collections/purchases.rb +2 -0
- data/lib/drip/collections/subscribers.rb +2 -0
- data/lib/drip/collections/tags.rb +2 -0
- data/lib/drip/collections/webhooks.rb +2 -0
- data/lib/drip/collections/workflow_triggers.rb +2 -0
- data/lib/drip/collections/workflows.rb +2 -0
- data/lib/drip/errors.rb +2 -0
- data/lib/drip/request.rb +33 -0
- data/lib/drip/resource.rb +2 -0
- data/lib/drip/resources.rb +2 -0
- data/lib/drip/resources/account.rb +2 -0
- data/lib/drip/resources/broadcast.rb +2 -0
- data/lib/drip/resources/campaign.rb +2 -0
- data/lib/drip/resources/campaign_subscription.rb +2 -0
- data/lib/drip/resources/error.rb +2 -0
- data/lib/drip/resources/order.rb +2 -0
- data/lib/drip/resources/purchase.rb +2 -0
- data/lib/drip/resources/subscriber.rb +2 -0
- data/lib/drip/resources/tag.rb +2 -0
- data/lib/drip/resources/webhook.rb +2 -0
- data/lib/drip/resources/workflow.rb +2 -0
- data/lib/drip/resources/workflow_trigger.rb +2 -0
- data/lib/drip/response.rb +15 -13
- data/lib/drip/version.rb +3 -1
- data/test/drip/client/accounts_test.rb +2 -0
- data/test/drip/client/broadcasts_test.rb +2 -0
- data/test/drip/client/campaign_subscriptions_test.rb +2 -0
- data/test/drip/client/campaigns_test.rb +2 -0
- data/test/drip/client/configuration_test.rb +112 -0
- data/test/drip/client/conversions_test.rb +2 -0
- data/test/drip/client/custom_fields_test.rb +2 -0
- data/test/drip/client/events_test.rb +2 -0
- data/test/drip/client/forms_test.rb +2 -0
- data/test/drip/client/http_client_test.rb +98 -0
- data/test/drip/client/orders_test.rb +2 -0
- data/test/drip/client/shopper_activity_test.rb +189 -0
- data/test/drip/client/subscribers_test.rb +8 -0
- data/test/drip/client/tags_test.rb +2 -0
- data/test/drip/client/users_test.rb +24 -0
- data/test/drip/client/webhooks_test.rb +2 -0
- data/test/drip/client/workflow_triggers_test.rb +2 -0
- data/test/drip/client/workflows_test.rb +2 -0
- data/test/drip/client_test.rb +34 -97
- data/test/drip/collection_test.rb +16 -0
- data/test/drip/collections/account_test.rb +10 -0
- data/test/drip/collections/broadcasts_test.rb +10 -0
- data/test/drip/collections/campaign_subscriptions_test.rb +10 -0
- data/test/drip/collections/campaigns_test.rb +10 -0
- data/test/drip/collections/errors_test.rb +10 -0
- data/test/drip/collections/orders_test.rb +10 -0
- data/test/drip/collections/purchases_test.rb +10 -0
- data/test/drip/collections/tags_test.rb +10 -0
- data/test/drip/collections/webhooks_test.rb +10 -0
- data/test/drip/collections/workflow_triggers_test.rb +10 -0
- data/test/drip/collections/workflows_test.rb +10 -0
- data/test/drip/collections_test.rb +2 -0
- data/test/drip/request_test.rb +60 -0
- data/test/drip/resource_test.rb +14 -0
- data/test/drip/resources/account_test.rb +2 -0
- data/test/drip/resources/order_test.rb +2 -0
- data/test/drip/resources/subscriber_test.rb +2 -0
- data/test/drip/resources/tag_test.rb +15 -0
- data/test/drip/resources_test.rb +2 -0
- data/test/drip/response_test.rb +35 -0
- data/test/test_helper.rb +5 -0
- metadata +50 -109
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require File.dirname(__FILE__) + '/../../test_helper.rb'
|
|
2
4
|
|
|
3
5
|
class Drip::Client::SubscribersTest < Drip::TestCase
|
|
@@ -82,6 +84,12 @@ class Drip::Client::SubscribersTest < Drip::TestCase
|
|
|
82
84
|
assert_equal expected, @client.create_or_update_subscriber(id: 123456)
|
|
83
85
|
assert_requested :post, "https://api.getdrip.com/v2/12345/subscribers", body: '{"subscribers":[{"id":123456}]}', times: 1
|
|
84
86
|
end
|
|
87
|
+
|
|
88
|
+
should "allow request with bigcommerce_subscriber_id keyword argument" do
|
|
89
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
|
90
|
+
assert_equal expected, @client.create_or_update_subscriber(external_ids: { "bigcommerce_subscriber_id" => "2" })
|
|
91
|
+
assert_requested :post, "https://api.getdrip.com/v2/12345/subscribers", body: '{"subscribers":[{"external_ids":{"bigcommerce_subscriber_id":"2"}}]}', times: 1
|
|
92
|
+
end
|
|
85
93
|
end
|
|
86
94
|
|
|
87
95
|
context "#create_or_update_subscribers" do
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require File.dirname(__FILE__) + '/../../test_helper.rb'
|
|
4
|
+
|
|
5
|
+
class Drip::Client::UsersTest < Drip::TestCase
|
|
6
|
+
def setup
|
|
7
|
+
@client = Drip::Client.new { |c| c.account_id = "12345" }
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
context "#user" do
|
|
11
|
+
setup do
|
|
12
|
+
@response_status = 200
|
|
13
|
+
@response_body = "{}"
|
|
14
|
+
|
|
15
|
+
stub_request(:get, "https://api.getdrip.com/v2/user").
|
|
16
|
+
to_return(status: @response_status, body: @response_body, headers: {})
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
should "send the right request" do
|
|
20
|
+
expected = Drip::Response.new(@response_status, JSON.parse(@response_body))
|
|
21
|
+
assert_equal expected, @client.user
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
data/test/drip/client_test.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require File.dirname(__FILE__) + '/../test_helper.rb'
|
|
2
4
|
require "base64"
|
|
3
5
|
|
|
@@ -19,11 +21,6 @@ class Drip::ClientTest < Drip::TestCase
|
|
|
19
21
|
assert_equal "aaaa", client.url_prefix
|
|
20
22
|
end
|
|
21
23
|
|
|
22
|
-
should "have default url prefix" do
|
|
23
|
-
client = Drip::Client.new
|
|
24
|
-
assert_equal "https://api.getdrip.com/v2/", client.url_prefix
|
|
25
|
-
end
|
|
26
|
-
|
|
27
24
|
should "accept access token" do
|
|
28
25
|
client = Drip::Client.new do |config|
|
|
29
26
|
config.access_token = "aaaa"
|
|
@@ -55,36 +52,12 @@ class Drip::ClientTest < Drip::TestCase
|
|
|
55
52
|
assert_equal 20, client.http_open_timeout
|
|
56
53
|
assert_equal 25, client.http_timeout
|
|
57
54
|
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
context "#generate_resource" do
|
|
61
|
-
setup do
|
|
62
|
-
@key = "subscribers"
|
|
63
|
-
@data = { "email" => "foo" }
|
|
64
|
-
@client = Drip::Client.new
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
should "return a JSON API payload" do
|
|
68
|
-
assert_equal({ @key => [@data] }, @client.generate_resource(@key, @data))
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
context "given a personal api key" do
|
|
73
|
-
setup do
|
|
74
|
-
@key = "aaaa"
|
|
75
|
-
@client = Drip::Client.new do |config|
|
|
76
|
-
config.api_key = @key
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
55
|
|
|
80
|
-
should "
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
header = "Basic #{Base64.encode64(@key + ':')}".strip
|
|
87
|
-
assert_requested :get, "https://api.getdrip.com/v2/testpath", headers: { 'Authorization' => header }
|
|
56
|
+
should "accept options after initialization" do
|
|
57
|
+
# Deprecated
|
|
58
|
+
client = Drip::Client.new
|
|
59
|
+
assert_output(nil, /^\[DEPRECATED\] Setting configuration/) { client.account_id = "12345" }
|
|
60
|
+
assert_equal "12345", client.account_id
|
|
88
61
|
end
|
|
89
62
|
end
|
|
90
63
|
|
|
@@ -98,6 +71,7 @@ class Drip::ClientTest < Drip::TestCase
|
|
|
98
71
|
|
|
99
72
|
should "return objects" do
|
|
100
73
|
stub_request(:get, "https://api.getdrip.com/v2/12345/subscribers/jdoe%40example.com").
|
|
74
|
+
with(headers: { "Content-Type" => "application/vnd.api+json" }).
|
|
101
75
|
to_return(status: 200, body: "{\"links\":{\"subscribers.account\":\"https://api.getdrip.com/v2/accounts/{subscribers.account}\"},\"subscribers\":[{\"id\":\"randomid\",\"href\":\"https://api.getdrip.com/v2/1234/subscribers/randomid\",\"status\":\"active\",\"email\":\"jdoe@example.com\",\"time_zone\":null,\"utc_offset\":0,\"visitor_uuid\":null,\"custom_fields\":{\"first_name\":\"John\"},\"tags\":[\"customer\"],\"created_at\":\"2018-06-04T21:29:49Z\",\"ip_address\":null,\"user_agent\":null,\"lifetime_value\":null,\"original_referrer\":null,\"landing_url\":null,\"prospect\":null,\"base_lead_score\":null,\"eu_consent\":\"unknown\",\"lead_score\":null,\"user_id\":\"123\",\"links\":{\"account\":\"1234\"}}]}")
|
|
102
76
|
|
|
103
77
|
response = @client.subscriber('jdoe@example.com')
|
|
@@ -120,85 +94,48 @@ class Drip::ClientTest < Drip::TestCase
|
|
|
120
94
|
@client = Drip::Client.new do |config|
|
|
121
95
|
config.api_key = @key
|
|
122
96
|
config.url_prefix = @url_prefix
|
|
97
|
+
config.account_id = "12345"
|
|
123
98
|
end
|
|
124
99
|
end
|
|
125
100
|
|
|
126
|
-
should "connect to alternate prefix" do
|
|
127
|
-
stub_request(:get, "https://api.example.com/v9001/
|
|
101
|
+
should "connect to alternate prefix with prepended v2" do
|
|
102
|
+
stub_request(:get, "https://api.example.com/v9001/v2/12345/subscribers/blah").
|
|
128
103
|
to_return(status: 200, body: "", headers: {})
|
|
129
|
-
@client.
|
|
104
|
+
@client.subscriber("blah")
|
|
130
105
|
|
|
131
|
-
assert_requested :get, "https://api.example.com/v9001/
|
|
106
|
+
assert_requested :get, "https://api.example.com/v9001/v2/12345/subscribers/blah"
|
|
132
107
|
end
|
|
133
108
|
end
|
|
134
109
|
|
|
135
|
-
context "
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
should "use Bearer token authentication" do
|
|
144
|
-
stub_request(:get, "https://api.getdrip.com/v2/testpath").
|
|
145
|
-
to_return(status: 200, body: "", headers: {})
|
|
146
|
-
@client.get("testpath")
|
|
147
|
-
header = "Bearer #{@key}"
|
|
148
|
-
assert_requested :get, "https://api.getdrip.com/v2/testpath", headers: { 'Authorization' => header }
|
|
110
|
+
context "#generate_resource" do
|
|
111
|
+
# Deprecated
|
|
112
|
+
should "return a resource and note deprecation" do
|
|
113
|
+
client = Drip::Client.new
|
|
114
|
+
resource = nil
|
|
115
|
+
assert_output(nil, /^\[DEPRECATED\] Drip\:\:Client\#generate_resource is deprecated/) { resource = client.generate_resource("hello", {}) }
|
|
116
|
+
assert_equal({ "hello" => [{}] }, resource)
|
|
149
117
|
end
|
|
150
118
|
end
|
|
151
119
|
|
|
152
|
-
context "
|
|
153
|
-
|
|
154
|
-
|
|
120
|
+
context "#content_type" do
|
|
121
|
+
# Deprecated
|
|
122
|
+
should "return default content type and print warning" do
|
|
123
|
+
client = Drip::Client.new
|
|
124
|
+
content_type = nil
|
|
125
|
+
assert_output(nil, /^\[DEPRECATED\] Drip\:\:Client\#content_type is deprecated/) { content_type = client.content_type }
|
|
126
|
+
assert_equal "application/vnd.api+json", content_type
|
|
155
127
|
end
|
|
128
|
+
end
|
|
156
129
|
|
|
157
|
-
|
|
130
|
+
context "#get et all" do
|
|
131
|
+
# Deprecated
|
|
132
|
+
should "delegate with v2 and print deprecation warning" do
|
|
158
133
|
stub_request(:get, "https://api.getdrip.com/v2/testpath").
|
|
159
|
-
to_return(status: 301, body: "", headers: { "Location" => "https://api.example.com/mytestpath" })
|
|
160
|
-
stub_request(:get, "https://api.example.com/mytestpath").
|
|
161
134
|
to_return(status: 200, body: "{}")
|
|
162
|
-
response = @client.get("testpath")
|
|
163
|
-
assert_requested :get, "https://api.getdrip.com/v2/testpath"
|
|
164
|
-
assert_requested :get, "https://api.example.com/mytestpath"
|
|
165
|
-
assert_equal({}, response.body)
|
|
166
|
-
end
|
|
167
135
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
stub_request(:get, "https://api.example.com/mytestpath").
|
|
172
|
-
to_return(status: 302, body: "", headers: { "Location" => "https://api.getdrip.com/v2/testpath" })
|
|
173
|
-
assert_raises(Drip::TooManyRedirectsError) { @client.get("testpath") }
|
|
174
|
-
assert_requested :get, "https://api.getdrip.com/v2/testpath", times: 5
|
|
175
|
-
assert_requested :get, "https://api.example.com/mytestpath", times: 5
|
|
176
|
-
end
|
|
177
|
-
end
|
|
178
|
-
|
|
179
|
-
context "given a get request" do
|
|
180
|
-
setup do
|
|
181
|
-
@client = Drip::Client.new
|
|
182
|
-
@response = mock
|
|
183
|
-
@response.stubs(:code).returns('200')
|
|
184
|
-
@response.stubs(:body).returns('{}')
|
|
185
|
-
|
|
186
|
-
@http = mock
|
|
187
|
-
@http.expects(:request).returns(@response)
|
|
188
|
-
|
|
189
|
-
@request = mock
|
|
190
|
-
@request.stubs(:[]=)
|
|
191
|
-
@request.stubs(:basic_auth)
|
|
192
|
-
end
|
|
193
|
-
|
|
194
|
-
should "encode query and not set body" do
|
|
195
|
-
Net::HTTP::Get.expects(:new).returns(@request)
|
|
196
|
-
Net::HTTP.expects(:start).yields(@http).returns(@response)
|
|
197
|
-
|
|
198
|
-
@request.expects(:body=).never
|
|
199
|
-
URI.expects(:encode_www_form).once
|
|
200
|
-
|
|
201
|
-
response = @client.get("testpath")
|
|
136
|
+
client = Drip::Client.new
|
|
137
|
+
response = nil
|
|
138
|
+
assert_output(nil, /^\[DEPRECATED\] Drip\:\:Client\#get please use the API endpoint specific methods/) { response = client.get("testpath") }
|
|
202
139
|
assert_equal({}, response.body)
|
|
203
140
|
end
|
|
204
141
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require File.dirname(__FILE__) + '/../test_helper.rb'
|
|
2
4
|
|
|
3
5
|
class Drip::CollectionTest < Drip::TestCase
|
|
@@ -42,6 +44,19 @@ class Drip::CollectionTest < Drip::TestCase
|
|
|
42
44
|
end
|
|
43
45
|
end
|
|
44
46
|
|
|
47
|
+
context ".collection_name" do
|
|
48
|
+
should "return default value" do
|
|
49
|
+
assert_equal "resources", Drip::Collection.collection_name
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
context ".resource_name" do
|
|
54
|
+
should "return default value" do
|
|
55
|
+
assert_equal "resource", Drip::Collection.resource_name
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# :nocov:
|
|
45
60
|
class TestCollection < Drip::Collection
|
|
46
61
|
def self.collection_name
|
|
47
62
|
"subscribers"
|
|
@@ -51,4 +66,5 @@ class Drip::CollectionTest < Drip::TestCase
|
|
|
51
66
|
"subscriber"
|
|
52
67
|
end
|
|
53
68
|
end
|
|
69
|
+
# :nocov:
|
|
54
70
|
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require File.dirname(__FILE__) + '/../../test_helper.rb'
|
|
4
|
+
require "drip/collections/accounts"
|
|
5
|
+
|
|
6
|
+
class Drip::AccountsTest < Drip::TestCase
|
|
7
|
+
should "have a resource name" do
|
|
8
|
+
assert_equal "account", Drip::Accounts.resource_name
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require File.dirname(__FILE__) + '/../../test_helper.rb'
|
|
4
|
+
require "drip/collections/broadcasts"
|
|
5
|
+
|
|
6
|
+
class Drip::BroadcastsTest < Drip::TestCase
|
|
7
|
+
should "have a resource name" do
|
|
8
|
+
assert_equal "broadcast", Drip::Broadcasts.resource_name
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require File.dirname(__FILE__) + '/../../test_helper.rb'
|
|
4
|
+
require "drip/collections/campaign_subscriptions"
|
|
5
|
+
|
|
6
|
+
class Drip::CampaignSubscriptionsTest < Drip::TestCase
|
|
7
|
+
should "have a resource name" do
|
|
8
|
+
assert_equal "campaign_subscription", Drip::CampaignSubscriptions.resource_name
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require File.dirname(__FILE__) + '/../../test_helper.rb'
|
|
4
|
+
require "drip/collections/campaigns"
|
|
5
|
+
|
|
6
|
+
class Drip::CampaignsTest < Drip::TestCase
|
|
7
|
+
should "have a resource name" do
|
|
8
|
+
assert_equal "campaign", Drip::Campaigns.resource_name
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require File.dirname(__FILE__) + '/../../test_helper.rb'
|
|
4
|
+
require "drip/collections/errors"
|
|
5
|
+
|
|
6
|
+
class Drip::ErrorsTest < Drip::TestCase
|
|
7
|
+
should "have a resource name" do
|
|
8
|
+
assert_equal "error", Drip::Errors.resource_name
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require File.dirname(__FILE__) + '/../../test_helper.rb'
|
|
4
|
+
require "drip/collections/orders"
|
|
5
|
+
|
|
6
|
+
class Drip::OrdersTest < Drip::TestCase
|
|
7
|
+
should "have a resource name" do
|
|
8
|
+
assert_equal "order", Drip::Orders.resource_name
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require File.dirname(__FILE__) + '/../../test_helper.rb'
|
|
4
|
+
require "drip/collections/purchases"
|
|
5
|
+
|
|
6
|
+
class Drip::PurchasesTest < Drip::TestCase
|
|
7
|
+
should "have a resource name" do
|
|
8
|
+
assert_equal "purchase", Drip::Purchases.resource_name
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require File.dirname(__FILE__) + '/../../test_helper.rb'
|
|
4
|
+
require "drip/collections/tags"
|
|
5
|
+
|
|
6
|
+
class Drip::TagsTest < Drip::TestCase
|
|
7
|
+
should "have a resource name" do
|
|
8
|
+
assert_equal "tag", Drip::Tags.resource_name
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require File.dirname(__FILE__) + '/../../test_helper.rb'
|
|
4
|
+
require "drip/collections/webhooks"
|
|
5
|
+
|
|
6
|
+
class Drip::WebhooksTest < Drip::TestCase
|
|
7
|
+
should "have a resource name" do
|
|
8
|
+
assert_equal "webhook", Drip::Webhooks.resource_name
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require File.dirname(__FILE__) + '/../../test_helper.rb'
|
|
4
|
+
require "drip/collections/workflow_triggers"
|
|
5
|
+
|
|
6
|
+
class Drip::WorkflowTriggersTest < Drip::TestCase
|
|
7
|
+
should "have a resource name" do
|
|
8
|
+
assert_equal "workflow_trigger", Drip::WorkflowTriggers.resource_name
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require File.dirname(__FILE__) + '/../../test_helper.rb'
|
|
4
|
+
require "drip/collections/workflows"
|
|
5
|
+
|
|
6
|
+
class Drip::WorkflowsTest < Drip::TestCase
|
|
7
|
+
should "have a resource name" do
|
|
8
|
+
assert_equal "workflow", Drip::Workflows.resource_name
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require File.dirname(__FILE__) + '/../test_helper.rb'
|
|
4
|
+
require "drip/request"
|
|
5
|
+
|
|
6
|
+
class Drip::RequestTest < Drip::TestCase
|
|
7
|
+
context "basic data" do
|
|
8
|
+
should "pass through data" do
|
|
9
|
+
request = Drip::Request.new(:get, "https://www.example.com/blah", { hello: "world" }, "application/vnd.visio")
|
|
10
|
+
assert_equal :get, request.http_verb
|
|
11
|
+
assert_equal "https://www.example.com/blah", request.url
|
|
12
|
+
assert_equal({ hello: "world" }, request.options)
|
|
13
|
+
assert_equal "application/vnd.visio", request.content_type
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
context "#verb_klass" do
|
|
18
|
+
context "when a supported verb" do
|
|
19
|
+
setup do
|
|
20
|
+
@subject = Drip::Request.new(:get, "https://www.example.com/blah", { hello: "world" }, "application/vnd.visio")
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
should "return a useful http class" do
|
|
24
|
+
assert_equal Net::HTTP::Get, @subject.verb_klass
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
context "when an unsupported verb" do
|
|
29
|
+
setup do
|
|
30
|
+
@subject = Drip::Request.new(:garbage, "https://www.example.com/blah", { hello: "world" }, "application/vnd.visio")
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
should "return nil" do
|
|
34
|
+
assert_nil @subject.verb_klass
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
context "#body" do
|
|
40
|
+
context "when HTTP GET" do
|
|
41
|
+
setup do
|
|
42
|
+
@subject = Drip::Request.new(:get, "https://www.example.com/blah", { hello: "world" }, "application/vnd.visio")
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
should "return nil" do
|
|
46
|
+
assert_nil @subject.body
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
context "when HTTP POST" do
|
|
51
|
+
setup do
|
|
52
|
+
@subject = Drip::Request.new(:post, "https://www.example.com/blah", { hello: "world" }, "application/vnd.visio")
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
should "return JSON" do
|
|
56
|
+
assert_equal '{"hello":"world"}', @subject.body
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|