Merge remote-tracking branch 'parent/main' into upstream-20250403
This commit is contained in:
commit
32f5604499
265 changed files with 6227 additions and 3383 deletions
28
spec/requests/api/fasp/debug/v0/callback/responses_spec.rb
Normal file
28
spec/requests/api/fasp/debug/v0/callback/responses_spec.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Api::Fasp::Debug::V0::Callback::Responses', feature: :fasp do
|
||||
include ProviderRequestHelper
|
||||
|
||||
describe 'POST /api/fasp/debug/v0/callback/responses' do
|
||||
let(:provider) { Fabricate(:debug_fasp) }
|
||||
|
||||
it 'create a record of the callback' do
|
||||
payload = { test: 'call' }
|
||||
headers = request_authentication_headers(provider,
|
||||
url: api_fasp_debug_v0_callback_responses_url,
|
||||
method: :post,
|
||||
body: payload)
|
||||
|
||||
expect do
|
||||
post api_fasp_debug_v0_callback_responses_path, headers:, params: payload, as: :json
|
||||
end.to change(Fasp::DebugCallback, :count).by(1)
|
||||
expect(response).to have_http_status(201)
|
||||
|
||||
debug_callback = Fasp::DebugCallback.last
|
||||
expect(debug_callback.fasp_provider).to eq provider
|
||||
expect(debug_callback.request_body).to eq '{"test":"call"}'
|
||||
end
|
||||
end
|
||||
end
|
42
spec/requests/api/fasp/registrations_spec.rb
Normal file
42
spec/requests/api/fasp/registrations_spec.rb
Normal file
|
@ -0,0 +1,42 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Api::Fasp::Registrations', feature: :fasp do
|
||||
describe 'POST /api/fasp/registration' do
|
||||
subject do
|
||||
post api_fasp_registration_path, params:
|
||||
end
|
||||
|
||||
context 'when given valid data' do
|
||||
let(:params) do
|
||||
{
|
||||
name: 'Test Provider',
|
||||
baseUrl: 'https://newprovider.example.com/fasp',
|
||||
serverId: '123',
|
||||
publicKey: '9qgjOfWRhozWc9dwx5JmbshizZ7TyPBhYk9+b5tE3e4=',
|
||||
}
|
||||
end
|
||||
|
||||
it 'creates a new provider' do
|
||||
expect { subject }.to change(Fasp::Provider, :count).by(1)
|
||||
|
||||
expect(response).to have_http_status 200
|
||||
end
|
||||
end
|
||||
|
||||
context 'when given invalid data' do
|
||||
let(:params) do
|
||||
{
|
||||
name: 'incomplete',
|
||||
}
|
||||
end
|
||||
|
||||
it 'does not create a provider and returns an error code' do
|
||||
expect { subject }.to_not change(Fasp::Provider, :count)
|
||||
|
||||
expect(response).to have_http_status 422
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
55
spec/requests/settings/pictures_spec.rb
Normal file
55
spec/requests/settings/pictures_spec.rb
Normal file
|
@ -0,0 +1,55 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Settings Pictures' do
|
||||
let!(:user) { Fabricate(:user) }
|
||||
|
||||
before { sign_in user }
|
||||
|
||||
describe 'DELETE /settings/profile/pictures/:id' do
|
||||
context 'with invalid picture id' do
|
||||
it 'returns http bad request' do
|
||||
delete settings_profile_picture_path(id: 'invalid')
|
||||
|
||||
expect(response)
|
||||
.to have_http_status(400)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with valid picture id' do
|
||||
before { stub_service }
|
||||
|
||||
context 'when account updates correctly' do
|
||||
let(:service) { instance_double(UpdateAccountService, call: true) }
|
||||
|
||||
it 'updates the account' do
|
||||
delete settings_profile_picture_path(id: 'avatar')
|
||||
|
||||
expect(response)
|
||||
.to redirect_to(settings_profile_path)
|
||||
.and have_http_status(303)
|
||||
expect(service)
|
||||
.to have_received(:call).with(user.account, { 'avatar' => nil, 'avatar_remote_url' => '' })
|
||||
end
|
||||
end
|
||||
|
||||
context 'when account cannot update' do
|
||||
let(:service) { instance_double(UpdateAccountService, call: false) }
|
||||
|
||||
it 'redirects to profile' do
|
||||
delete settings_profile_picture_path(id: 'avatar')
|
||||
|
||||
expect(response)
|
||||
.to redirect_to(settings_profile_path)
|
||||
end
|
||||
end
|
||||
|
||||
def stub_service
|
||||
allow(UpdateAccountService)
|
||||
.to receive(:new)
|
||||
.and_return(service)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue