intents_controller_spec.rb 1.2 KB

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