mirror of
https://github.com/mastodon/mastodon.git
synced 2026-04-14 00:58:09 -05:00
Some checks failed
Ruby Linting / lint (push) Has been cancelled
Test one step migrations / pre_job (push) Has been cancelled
Test two step migrations / pre_job (push) Has been cancelled
Ruby Testing / build (production) (push) Has been cancelled
Ruby Testing / build (test) (push) Has been cancelled
Test one step migrations / test (14-alpine) (push) Has been cancelled
Test one step migrations / test (15-alpine) (push) Has been cancelled
Test two step migrations / test (14-alpine) (push) Has been cancelled
Test two step migrations / test (15-alpine) (push) Has been cancelled
Ruby Testing / test (1, .ruby-version) (push) Has been cancelled
Ruby Testing / test (1, 3.1) (push) Has been cancelled
Ruby Testing / test (1, 3.3) (push) Has been cancelled
Ruby Testing / test (2, .ruby-version) (push) Has been cancelled
Ruby Testing / test (2, 3.1) (push) Has been cancelled
Ruby Testing / test (2, 3.3) (push) Has been cancelled
Ruby Testing / test (3, .ruby-version) (push) Has been cancelled
Ruby Testing / test (3, 3.1) (push) Has been cancelled
Ruby Testing / test (3, 3.3) (push) Has been cancelled
Ruby Testing / test (4, .ruby-version) (push) Has been cancelled
Ruby Testing / test (4, 3.1) (push) Has been cancelled
Ruby Testing / test (4, 3.3) (push) Has been cancelled
Ruby Testing / End to End testing (.ruby-version) (push) Has been cancelled
Ruby Testing / End to End testing (3.1) (push) Has been cancelled
Ruby Testing / End to End testing (3.3) (push) Has been cancelled
Ruby Testing / Testing search (.ruby-version) (push) Has been cancelled
Ruby Testing / Testing search (3.1) (push) Has been cancelled
Ruby Testing / Testing search (3.3) (push) Has been cancelled
71 lines
1.8 KiB
Ruby
71 lines
1.8 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
RSpec.describe Settings::PrivacyController do
|
|
render_views
|
|
|
|
let!(:user) { Fabricate(:user) }
|
|
let(:account) { user.account }
|
|
|
|
before do
|
|
sign_in user, scope: :user
|
|
end
|
|
|
|
describe 'GET #show' do
|
|
before do
|
|
get :show
|
|
end
|
|
|
|
it 'returns http success with private cache control headers', :aggregate_failures do
|
|
expect(response)
|
|
.to have_http_status(200)
|
|
expect(response.headers['Cache-Control']).to include('private, no-store')
|
|
end
|
|
end
|
|
|
|
describe 'PUT #update' do
|
|
context 'when update succeeds' do
|
|
before do
|
|
allow(ActivityPub::UpdateDistributionWorker).to receive(:perform_in)
|
|
end
|
|
|
|
it 'updates the user profile' do
|
|
put :update, params: { account: { discoverable: '1', settings: { indexable: '1' } } }
|
|
|
|
expect(account.reload.discoverable)
|
|
.to be(true)
|
|
|
|
expect(response)
|
|
.to redirect_to(settings_privacy_path)
|
|
|
|
expect(ActivityPub::UpdateDistributionWorker)
|
|
.to have_received(:perform_in).with(anything, account.id)
|
|
end
|
|
end
|
|
|
|
context 'when update fails' do
|
|
before do
|
|
allow(UpdateAccountService).to receive(:new).and_return(failing_update_service)
|
|
allow(ActivityPub::UpdateDistributionWorker).to receive(:perform_in)
|
|
end
|
|
|
|
it 'updates the user profile' do
|
|
put :update, params: { account: { discoverable: '1', settings: { indexable: '1' } } }
|
|
|
|
expect(response)
|
|
.to render_template(:show)
|
|
|
|
expect(ActivityPub::UpdateDistributionWorker)
|
|
.to_not have_received(:perform_in)
|
|
end
|
|
|
|
private
|
|
|
|
def failing_update_service
|
|
instance_double(UpdateAccountService, call: false)
|
|
end
|
|
end
|
|
end
|
|
end
|