remote_interaction_controller_spec.rb 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe RemoteInteractionController, type: :controller do
  4. render_views
  5. let(:status) { Fabricate(:status) }
  6. describe 'GET #new' do
  7. it 'returns 200' do
  8. get :new, params: { id: status.id }
  9. expect(response).to have_http_status(200)
  10. end
  11. end
  12. describe 'POST #create' do
  13. context '@remote_follow is valid' do
  14. it 'returns 302' do
  15. allow_any_instance_of(RemoteFollow).to receive(:valid?) { true }
  16. allow_any_instance_of(RemoteFollow).to receive(:addressable_template) do
  17. Addressable::Template.new('https://hoge.com')
  18. end
  19. post :create, params: { id: status.id, remote_follow: { acct: '@hoge' } }
  20. expect(response).to have_http_status(302)
  21. end
  22. end
  23. context '@remote_follow is invalid' do
  24. it 'returns 200' do
  25. allow_any_instance_of(RemoteFollow).to receive(:valid?) { false }
  26. post :create, params: { id: status.id, remote_follow: { acct: '@hoge' } }
  27. expect(response).to have_http_status(200)
  28. end
  29. end
  30. end
  31. end