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

@ -1,45 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe TagsController do
render_views
describe 'GET #show' do
let(:format) { 'html' }
let(:tag) { Fabricate(:tag, name: 'test') }
let(:tag_name) { tag&.name }
before do
get :show, params: { id: tag_name, format: format }
end
context 'when tag exists' do
context 'when requested as HTML' do
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 'when requested as JSON' do
let(:format) { 'json' }
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
end
context 'when tag does not exist' do
let(:tag_name) { 'hoge' }
it 'returns http not found' do
expect(response).to have_http_status(404)
end
end
end
end