File tree 2 files changed +42
-3
lines changed
2 files changed +42
-3
lines changed Original file line number Diff line number Diff line change @@ -41,10 +41,13 @@ def upload_raw(data)
41
41
42
42
private
43
43
44
+ def post_path
45
+ parsed_uri = URI . parse ( server_url )
46
+ "#{ parsed_uri . path } /documents"
47
+ end
48
+
44
49
def do_post ( data )
45
- posturi = URI . parse ( server_url )
46
- posturi . path += '/documents'
47
- connection . post ( posturi . path , data )
50
+ connection . post ( post_path , data )
48
51
end
49
52
50
53
def connection
Original file line number Diff line number Diff line change 126
126
127
127
end
128
128
129
+ describe :post_path do
130
+
131
+ let ( :post_path ) { uploader . send ( :post_path ) }
132
+
133
+ context "when the server URL doesn't have a path" do
134
+
135
+ let ( :base ) { 'http://example.com/' }
136
+
137
+ it 'should return /documents' do
138
+ expect ( post_path ) . to eq ( '/documents' )
139
+ end
140
+
141
+ end
142
+
143
+ context "when the server URL has a path" do
144
+
145
+ let ( :base ) { 'http://example.com/friend' }
146
+
147
+ it 'should return /documents' do
148
+ expect ( post_path ) . to eq ( '/friend/documents' )
149
+ end
150
+
151
+ end
152
+
153
+ context "when the server URL has a path that ends with slash" do
154
+
155
+ let ( :base ) { 'http://example.com/friend/' }
156
+
157
+ it 'should return /documents appended to the path without a duplicate slash' do
158
+ expect ( post_path ) . to eq ( '/friend/documents' )
159
+ end
160
+
161
+ end
162
+
163
+ end
164
+
129
165
describe :server_url do
130
166
131
167
let ( :server_url ) { uploader . server_url }
You can’t perform that action at this time.
0 commit comments