statuses_cleanup_controller_spec.rb 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe StatusesCleanupController do
  4. render_views
  5. let!(:user) { Fabricate(:user) }
  6. before do
  7. sign_in user, scope: :user
  8. end
  9. describe 'GET #show' do
  10. before do
  11. get :show
  12. end
  13. it 'returns http success' do
  14. expect(response).to have_http_status(200)
  15. end
  16. it 'returns private cache control headers' do
  17. expect(response.headers['Cache-Control']).to include('private, no-store')
  18. end
  19. end
  20. describe 'PUT #update' do
  21. before do
  22. put :update, params: { account_statuses_cleanup_policy: { enabled: true, min_status_age: 2.weeks.seconds, keep_direct: false, keep_polls: true } }
  23. end
  24. it 'updates the account status cleanup policy' do
  25. expect(user.account.statuses_cleanup_policy.enabled).to be true
  26. expect(user.account.statuses_cleanup_policy.keep_direct).to be false
  27. expect(user.account.statuses_cleanup_policy.keep_polls).to be true
  28. end
  29. it 'redirects' do
  30. expect(response).to redirect_to(statuses_cleanup_path)
  31. end
  32. end
  33. end