You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.2 KiB

  1. require 'rails_helper'
  2. RSpec.describe IntentsController, type: :controller do
  3. render_views
  4. let(:user) { Fabricate(:user) }
  5. before { sign_in user, scope: :user }
  6. describe 'GET #show' do
  7. subject { get :show, params: { uri: uri } }
  8. context 'when schema is web+mastodon' do
  9. context 'when host is follow' do
  10. let(:uri) { 'web+mastodon://follow?uri=test' }
  11. it { is_expected.to redirect_to authorize_interaction_path(uri: 'test') }
  12. end
  13. context 'when host is share' do
  14. let(:uri) { 'web+mastodon://share?text=test' }
  15. it { is_expected.to redirect_to share_path(text: 'test') }
  16. end
  17. context 'when host is none of the above' do
  18. let(:uri) { 'web+mastodon://test' }
  19. it { is_expected.to have_http_status 404 }
  20. end
  21. end
  22. context 'when schema is not web+mastodon' do
  23. let(:uri) { 'api+mastodon://test.com' }
  24. it { is_expected.to have_http_status 404 }
  25. end
  26. context 'when uri param is blank' do
  27. let(:uri) { '' }
  28. it { is_expected.to have_http_status 404 }
  29. end
  30. context 'when uri is invalid' do
  31. let(:uri) { 'invalid uri://test.com' }
  32. it { is_expected.to have_http_status 404 }
  33. end
  34. end
  35. end