2023-02-22 01:55:31 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-11-05 15:20:05 +01:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2023-05-04 05:49:53 +02:00
|
|
|
RSpec.describe TagsController do
|
2016-11-18 23:08:52 +01:00
|
|
|
render_views
|
2016-11-05 15:20:05 +01:00
|
|
|
|
|
|
|
describe 'GET #show' do
|
2023-04-19 16:07:29 +02:00
|
|
|
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
|
2017-05-25 16:07:38 +02:00
|
|
|
|
|
|
|
context 'when tag exists' do
|
2023-04-19 16:07:29 +02:00
|
|
|
context 'when requested as HTML' do
|
|
|
|
it 'returns http success' do
|
|
|
|
expect(response).to have_http_status(200)
|
|
|
|
end
|
|
|
|
|
2024-02-27 12:50:21 +01:00
|
|
|
it_behaves_like 'cacheable response', expects_vary: 'Accept, Accept-Language, Cookie'
|
2023-04-19 16:07:29 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when requested as JSON' do
|
|
|
|
let(:format) { 'json' }
|
|
|
|
|
|
|
|
it 'returns http success' do
|
|
|
|
expect(response).to have_http_status(200)
|
|
|
|
end
|
|
|
|
|
2024-02-27 12:50:21 +01:00
|
|
|
it_behaves_like 'cacheable response', expects_vary: 'Accept, Accept-Language, Cookie'
|
2017-05-25 16:07:38 +02:00
|
|
|
end
|
2016-11-05 15:20:05 +01:00
|
|
|
end
|
2017-04-28 15:11:21 +02:00
|
|
|
|
2017-05-25 16:07:38 +02:00
|
|
|
context 'when tag does not exist' do
|
2023-04-19 16:07:29 +02:00
|
|
|
let(:tag_name) { 'hoge' }
|
|
|
|
|
2022-10-20 14:35:29 +02:00
|
|
|
it 'returns http not found' do
|
2018-04-21 21:35:07 +02:00
|
|
|
expect(response).to have_http_status(404)
|
2017-05-25 16:07:38 +02:00
|
|
|
end
|
2017-04-28 15:11:21 +02:00
|
|
|
end
|
2016-11-05 15:20:05 +01:00
|
|
|
end
|
|
|
|
end
|