tags_controller_spec.rb 874 B

123456789101112131415161718192021222324252627
  1. require 'rails_helper'
  2. RSpec.describe TagsController, type: :controller do
  3. render_views
  4. describe 'GET #show' do
  5. let!(:tag) { Fabricate(:tag, name: 'test') }
  6. let!(:local) { Fabricate(:status, tags: [tag], text: 'local #test') }
  7. let!(:remote) { Fabricate(:status, tags: [tag], text: 'remote #test', account: Fabricate(:account, domain: 'remote')) }
  8. let!(:late) { Fabricate(:status, tags: [tag], text: 'late #test') }
  9. context 'when tag exists' do
  10. it 'redirects to web version' do
  11. get :show, params: { id: 'test', max_id: late.id }
  12. expect(response).to redirect_to('/web/tags/test')
  13. end
  14. end
  15. context 'when tag does not exist' do
  16. it 'returns http missing for non-existent tag' do
  17. get :show, params: { id: 'none' }
  18. expect(response).to have_http_status(404)
  19. end
  20. end
  21. end
  22. end