|
10 | 10 | end
|
11 | 11 |
|
12 | 12 | context 'unauthenticated' do
|
13 |
| - it 'responds 403' do |
| 13 | + it 'responds 403 for post' do |
14 | 14 | post('/v3/v2_subscription/123/share', {})
|
15 | 15 |
|
16 | 16 | expect(last_response.status).to eq(403)
|
17 | 17 | end
|
| 18 | + |
| 19 | + it 'responds 403 for delete' do |
| 20 | + delete('/v3/v2_subscription/123/share', {}) |
| 21 | + |
| 22 | + expect(last_response.status).to eq(403) |
| 23 | + end |
18 | 24 | end
|
19 | 25 |
|
20 |
| - context 'authenticated' do |
| 26 | + context 'authenticated create share' do |
21 | 27 | let(:user) { FactoryBot.create(:user) }
|
22 | 28 | let(:token) { Travis::Api::App::AccessToken.create(user: user, app_id: 1) }
|
23 | 29 | let(:headers) {{ 'HTTP_AUTHORIZATION' => "token #{token}",
|
|
41 | 47 | expect(stubbed_request).to have_been_made.once
|
42 | 48 | end
|
43 | 49 | end
|
| 50 | + |
| 51 | + context 'authenticated delete share' do |
| 52 | + let(:user) { FactoryBot.create(:user) } |
| 53 | + let(:token) { Travis::Api::App::AccessToken.create(user: user, app_id: 1) } |
| 54 | + let(:headers) {{ 'HTTP_AUTHORIZATION' => "token #{token}", |
| 55 | + 'CONTENT_TYPE' => 'application/json' }} |
| 56 | + let(:subscription_id) { rand(999) } |
| 57 | + |
| 58 | + let!(:stubbed_request) do |
| 59 | + stub_request(:delete, "#{billing_url}/v2/subscriptions/#{subscription_id}/share?plan=#{subscription_id}&receiver=#{receiver.id}&requested_by=#{user.id}").with( |
| 60 | + headers: { |
| 61 | + 'X-Travis-User-Id' => user.id |
| 62 | + } |
| 63 | + ) |
| 64 | + .to_return(status: 204) |
| 65 | + end |
| 66 | + |
| 67 | + it 'deletes subscription share' do |
| 68 | + delete("/v3/v2_subscription/#{subscription_id}/share", JSON.generate(data), headers) |
| 69 | + expect(last_response.status).to eq(204) |
| 70 | + expect(stubbed_request).to have_been_made.once |
| 71 | + end |
| 72 | + end |
44 | 73 | end
|
0 commit comments