0
0
Fork 0

Convert tags controller spec to system and request specs (#31708)

This commit is contained in:
Matt Jankowski 2024-09-03 09:18:53 -04:00 committed by GitHub
parent 0437dd9e77
commit 219458d7d4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 75 additions and 45 deletions

View file

@ -0,0 +1,59 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Tags' do
describe 'GET /tags/:id' do
context 'when tag exists' do
let(:tag) { Fabricate :tag }
context 'with HTML format' do
# TODO: Convert the cacheable response shared example into a matcher,
# remove this example, rely on system spec (which should use matcher)
before { get tag_path(tag) }
it 'returns http success' do
expect(response)
.to have_http_status(200)
end
it_behaves_like 'cacheable response', expects_vary: 'Accept, Accept-Language, Cookie'
end
context 'with JSON format' do
before { get tag_path(tag, format: :json) }
it 'returns http success' do
expect(response)
.to have_http_status(200)
expect(response.content_type)
.to start_with('application/activity+json')
end
it_behaves_like 'cacheable response', expects_vary: 'Accept, Accept-Language, Cookie'
end
context 'with RSS format' do
before { get tag_path(tag, format: :rss) }
it 'returns http success' do
expect(response)
.to have_http_status(200)
expect(response.content_type)
.to start_with('application/rss+xml')
end
it_behaves_like 'cacheable response', expects_vary: 'Accept, Accept-Language, Cookie'
end
end
context 'when tag does not exist' do
before { get tag_path('missing') }
it 'returns http not found' do
expect(response)
.to have_http_status(404)
end
end
end
end