1
0

profiles_controller_spec.rb 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe Settings::ProfilesController do
  4. render_views
  5. let!(:user) { Fabricate(:user) }
  6. let(:account) { user.account }
  7. before do
  8. sign_in user, scope: :user
  9. end
  10. describe 'GET #show' do
  11. before do
  12. get :show
  13. end
  14. it 'returns http success with private cache control headers', :aggregate_failures do
  15. expect(response).to have_http_status(200)
  16. expect(response.headers['Cache-Control']).to include('private, no-store')
  17. end
  18. end
  19. describe 'PUT #update' do
  20. before do
  21. user.account.update(display_name: 'Old name')
  22. end
  23. it 'updates the user profile' do
  24. allow(ActivityPub::UpdateDistributionWorker).to receive(:perform_async)
  25. put :update, params: { account: { display_name: 'New name' } }
  26. expect(account.reload.display_name).to eq 'New name'
  27. expect(response).to redirect_to(settings_profile_path)
  28. expect(ActivityPub::UpdateDistributionWorker).to have_received(:perform_async).with(account.id)
  29. end
  30. end
  31. describe 'PUT #update with new profile image' do
  32. it 'updates profile image' do
  33. allow(ActivityPub::UpdateDistributionWorker).to receive(:perform_async)
  34. expect(account.avatar.instance.avatar_file_name).to be_nil
  35. put :update, params: { account: { avatar: fixture_file_upload('avatar.gif', 'image/gif') } }
  36. expect(response).to redirect_to(settings_profile_path)
  37. expect(account.reload.avatar.instance.avatar_file_name).to_not be_nil
  38. expect(ActivityPub::UpdateDistributionWorker).to have_received(:perform_async).with(account.id)
  39. end
  40. end
  41. end