diff options
author | Matt Jankowski <mjankowski@thoughtbot.com> | 2017-05-30 20:15:09 -0400 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2017-05-31 02:15:09 +0200 |
commit | 83435c49ea4f31d80d81658d8faa69ed5350e26f (patch) | |
tree | 8166430a7729713ee1b0bc4a38d83967c06d3ecc /spec | |
parent | 93de41b39b5aa287671cdf80ee26b5b96e0cf612 (diff) |
Clean up api/subscriptions controller (#3448)
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/api/subscriptions_controller_spec.rb | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/spec/controllers/api/subscriptions_controller_spec.rb b/spec/controllers/api/subscriptions_controller_spec.rb index 97e36420d..76f9740ca 100644 --- a/spec/controllers/api/subscriptions_controller_spec.rb +++ b/spec/controllers/api/subscriptions_controller_spec.rb @@ -6,16 +6,29 @@ RSpec.describe Api::SubscriptionsController, type: :controller do let(:account) { Fabricate(:account, username: 'gargron', domain: 'quitter.no', remote_url: 'topic_url', secret: 'abc') } describe 'GET #show' do - before do - get :show, params: { :id => account.id, 'hub.topic' => 'topic_url', 'hub.challenge' => '456', 'hub.lease_seconds' => "#{86400 * 30}" } - end + context 'with valid subscription' do + before do + get :show, params: { :id => account.id, 'hub.topic' => 'topic_url', 'hub.challenge' => '456', 'hub.lease_seconds' => "#{86400 * 30}" } + end - it 'returns http success' do - expect(response).to have_http_status(:success) + it 'returns http success' do + expect(response).to have_http_status(:success) + end + + it 'echoes back the challenge' do + expect(response.body).to match '456' + end end - it 'echoes back the challenge' do - expect(response.body).to match '456' + context 'with invalid subscription' do + before do + expect_any_instance_of(Account).to receive_message_chain(:subscription, :valid?).and_return(false) + get :show, params: { :id => account.id } + end + + it 'returns http success' do + expect(response).to have_http_status(:missing) + end end end |