0
0
Fork 0

Move api/v1/trends/* to request specs (#28949)

This commit is contained in:
Matt Jankowski 2024-01-26 12:40:39 -05:00 committed by GitHub
parent 0b0ca6f3b8
commit 7adcc0aae3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 18 deletions

View file

@ -1,39 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Api::V1::Trends::LinksController do
render_views
describe 'GET #index' do
context 'when trends are disabled' do
before { Setting.trends = false }
it 'returns http success' do
get :index
expect(response).to have_http_status(200)
end
end
context 'when trends are enabled' do
before { Setting.trends = true }
it 'returns http success' do
prepare_trends
stub_const('Api::V1::Trends::LinksController::DEFAULT_LINKS_LIMIT', 2)
get :index
expect(response).to have_http_status(200)
expect(response.headers).to include('Link')
end
def prepare_trends
Fabricate.times(3, :preview_card, trendable: true, language: 'en').each do |link|
2.times { |i| Trends.links.add(link, i) }
end
Trends::Links.new(threshold: 1).refresh
end
end
end
end

View file

@ -1,39 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Api::V1::Trends::StatusesController do
render_views
describe 'GET #index' do
context 'when trends are disabled' do
before { Setting.trends = false }
it 'returns http success' do
get :index
expect(response).to have_http_status(200)
end
end
context 'when trends are enabled' do
before { Setting.trends = true }
it 'returns http success' do
prepare_trends
stub_const('Api::BaseController::DEFAULT_STATUSES_LIMIT', 2)
get :index
expect(response).to have_http_status(200)
expect(response.headers).to include('Link')
end
def prepare_trends
Fabricate.times(3, :status, trendable: true, language: 'en').each do |status|
2.times { |i| Trends.statuses.add(status, i) }
end
Trends::Statuses.new(threshold: 1, decay_threshold: -1).refresh
end
end
end
end

View file

@ -1,40 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe Api::V1::Trends::TagsController do
render_views
describe 'GET #index' do
context 'when trends are disabled' do
before { Setting.trends = false }
it 'returns http success' do
get :index
expect(response).to have_http_status(200)
expect(response.headers).to_not include('Link')
end
end
context 'when trends are enabled' do
before { Setting.trends = true }
it 'returns http success' do
prepare_trends
stub_const('Api::V1::Trends::TagsController::DEFAULT_TAGS_LIMIT', 2)
get :index
expect(response).to have_http_status(200)
expect(response.headers).to include('Link')
end
def prepare_trends
Fabricate.times(3, :tag, trendable: true).each do |tag|
2.times { |i| Trends.tags.add(tag, i) }
end
Trends::Tags.new(threshold: 1).refresh
end
end
end
end