statuses_cleanup_controller_spec.rb 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe StatusesCleanupController do
  4. render_views
  5. before do
  6. @user = Fabricate(:user)
  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