2024-09-03 13:18:53 +00:00
|
|
|
# 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
|
2024-09-03 15:35:19 +00:00
|
|
|
# TODO: Update the have_cacheable_headers matcher to operate on capybara sessions
|
|
|
|
# Remove this example, rely on system spec (which should use matcher)
|
2024-09-03 13:18:53 +00:00
|
|
|
before { get tag_path(tag) }
|
|
|
|
|
|
|
|
it 'returns http success' do
|
|
|
|
expect(response)
|
|
|
|
.to have_http_status(200)
|
2024-09-03 15:35:19 +00:00
|
|
|
.and have_cacheable_headers.with_vary('Accept, Accept-Language, Cookie')
|
2024-09-03 13:18:53 +00:00
|
|
|
end
|
|
|
|
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)
|
2024-09-03 15:35:19 +00:00
|
|
|
.and have_cacheable_headers.with_vary('Accept, Accept-Language, Cookie')
|
2024-09-03 13:18:53 +00:00
|
|
|
expect(response.content_type)
|
|
|
|
.to start_with('application/activity+json')
|
|
|
|
end
|
|
|
|
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)
|
2024-09-03 15:35:19 +00:00
|
|
|
.and have_cacheable_headers.with_vary('Accept, Accept-Language, Cookie')
|
2024-09-03 13:18:53 +00:00
|
|
|
expect(response.content_type)
|
|
|
|
.to start_with('application/rss+xml')
|
|
|
|
end
|
|
|
|
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
|