1
0
Fork 0
forked from gitea/nas

Merge remote-tracking branch 'parent/main' into upstream-20240828

This commit is contained in:
KMY 2024-08-28 20:26:35 +09:00
commit b39054ff3c
136 changed files with 1803 additions and 977 deletions

View file

@ -0,0 +1,33 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'API OEmbed' do
describe 'GET /api/oembed' do
before { host! Rails.configuration.x.local_domain }
context 'when status is public' do
let(:status) { Fabricate(:status, visibility: :public) }
it 'returns success with private cache control headers' do
get '/api/oembed', params: { url: short_account_status_url(status.account, status) }
expect(response)
.to have_http_status(200)
expect(response.headers['Cache-Control'])
.to include('private, no-store')
end
end
context 'when status is not public' do
let(:status) { Fabricate(:status, visibility: :direct) }
it 'returns not found' do
get '/api/oembed', params: { url: short_account_status_url(status.account, status) }
expect(response)
.to have_http_status(404)
end
end
end
end

View file

@ -0,0 +1,41 @@
# frozen_string_literal: true
require 'rails_helper'
RSpec.describe '/api/web/settings' do
describe 'PATCH /api/web/settings' do
let(:user) { Fabricate :user }
context 'when signed in' do
before { sign_in(user) }
it 'updates setting and responds with success' do
patch '/api/web/settings', params: { data: { 'onboarded' => true } }
expect(user_web_setting.data)
.to include('onboarded' => 'true')
expect(response)
.to have_http_status(200)
end
end
context 'when not signed in' do
it 'responds with unprocessable and does not modify setting' do
patch '/api/web/settings', params: { data: { 'onboarded' => true } }
expect(user_web_setting)
.to be_nil
expect(response)
.to have_http_status(422)
end
end
def user_web_setting
Web::Setting
.where(user: user)
.first
end
end
end