Merge commit 'e1dbbf6c9db6dbf3f356dae4c59fa05299372370' into glitch-soc/merge-upstream
This commit is contained in:
commit
745c445e7e
32 files changed
+329
-155
No files matched your search
@@ -15,6 +15,8 @@ RSpec.describe 'API V1 Trends Tags' do
|
||||
.and not_have_http_link_header
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.headers['Deprecation'])
|
||||
.to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
@@ -31,6 +33,8 @@ RSpec.describe 'API V1 Trends Tags' do
|
||||
.and have_http_link_header(api_v1_trends_tags_url(offset: 2)).for(rel: 'next')
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.headers['Deprecation'])
|
||||
.to be_nil
|
||||
end
|
||||
|
||||
def prepare_trends
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'deprecated API V1 Trends Tags' do
|
||||
describe 'GET /api/v1/trends' do
|
||||
context 'when trends are disabled' do
|
||||
before { Setting.trends = false }
|
||||
|
||||
it 'returns http success' do
|
||||
get '/api/v1/trends'
|
||||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and not_have_http_link_header
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.headers['Deprecation'])
|
||||
.to start_with '@'
|
||||
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 '/api/v1/trends'
|
||||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and have_http_link_header(api_v1_trends_tags_url(offset: 2)).for(rel: 'next')
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.headers['Deprecation'])
|
||||
.to start_with '@'
|
||||
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
|
||||
@@ -158,14 +158,13 @@ RSpec.describe 'Notifications' do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body[:notification_groups]).to contain_exactly(
|
||||
a_hash_including(
|
||||
type: 'favourite',
|
||||
sample_account_ids: have_attributes(size: 5),
|
||||
page_min_id: notification_ids.first.to_s,
|
||||
page_max_id: notification_ids.last.to_s
|
||||
)
|
||||
)
|
||||
expect(response.parsed_body[:notification_groups].size)
|
||||
.to eq(1)
|
||||
expect(response.parsed_body.dig(:notification_groups, 0))
|
||||
.to include(type: 'favourite')
|
||||
.and(include(sample_account_ids: have_attributes(size: 5)))
|
||||
.and(include(page_max_id: notification_ids.last.to_s))
|
||||
.and(include(page_min_id: notification_ids.first.to_s))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -180,14 +179,13 @@ RSpec.describe 'Notifications' do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body[:notification_groups]).to contain_exactly(
|
||||
a_hash_including(
|
||||
type: 'favourite',
|
||||
sample_account_ids: have_attributes(size: 5),
|
||||
page_min_id: notification_ids.first.to_s,
|
||||
page_max_id: notification_ids.last.to_s
|
||||
)
|
||||
)
|
||||
expect(response.parsed_body[:notification_groups].size)
|
||||
.to eq(1)
|
||||
expect(response.parsed_body.dig(:notification_groups, 0))
|
||||
.to include(type: 'favourite')
|
||||
.and(include(sample_account_ids: have_attributes(size: 5)))
|
||||
.and(include(page_max_id: notification_ids.last.to_s))
|
||||
.and(include(page_min_id: notification_ids.first.to_s))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user