Merge commit '04f0468016b450ace8e0ce707b4c21aa18b51262' into glitch-soc/merge-upstream
This commit is contained in:
commit
94d8cdc494
57 files changed
+930
-546
No files matched your search
@@ -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
|
||||
@@ -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
|
||||
Reference in new issue
Block a user