Merge remote-tracking branch 'parent/main' into upstream-20250328
This commit is contained in:
commit
12ed20b6d5
257 changed files with 3505 additions and 2010 deletions
|
@ -74,12 +74,45 @@ RSpec.describe '/api/v1/accounts' do
|
|||
|
||||
describe 'POST /api/v1/accounts' do
|
||||
subject do
|
||||
post '/api/v1/accounts', headers: headers, params: { username: 'test', password: '12345678', email: 'hello@world.tld', agreement: agreement }
|
||||
post '/api/v1/accounts', headers: headers, params: { username: 'test', password: '12345678', email: 'hello@world.tld', agreement: agreement, date_of_birth: date_of_birth }
|
||||
end
|
||||
|
||||
let(:client_app) { Fabricate(:application) }
|
||||
let(:token) { Doorkeeper::AccessToken.find_or_create_for(application: client_app, resource_owner: nil, scopes: 'read write', use_refresh_token: false) }
|
||||
let(:agreement) { nil }
|
||||
let(:date_of_birth) { nil }
|
||||
|
||||
context 'when age verification is enabled' do
|
||||
before do
|
||||
Setting.min_age = 16
|
||||
end
|
||||
|
||||
let(:agreement) { 'true' }
|
||||
|
||||
context 'when date of birth is below age limit' do
|
||||
let(:date_of_birth) { 13.years.ago.strftime('%d.%m.%Y') }
|
||||
|
||||
it 'returns http unprocessable entity' do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when date of birth is over age limit' do
|
||||
let(:date_of_birth) { 17.years.ago.strftime('%d.%m.%Y') }
|
||||
|
||||
it 'creates a user', :aggregate_failures do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when given truthy agreement' do
|
||||
let(:agreement) { 'true' }
|
||||
|
|
|
@ -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
|
||||
|
|
48
spec/requests/api/v1/trends_spec.rb
Normal file
48
spec/requests/api/v1/trends_spec.rb
Normal file
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue