notifications_controller_spec.rb 1012 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe Settings::Preferences::NotificationsController 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 with private cache control headers', :aggregate_failures do
  14. expect(response).to have_http_status(200)
  15. expect(response.headers['Cache-Control']).to include('private, no-store')
  16. end
  17. end
  18. describe 'PUT #update' do
  19. it 'updates notifications settings' do
  20. user.settings.update('notification_emails.follow': false)
  21. user.save
  22. put :update, params: {
  23. user: {
  24. settings_attributes: {
  25. 'notification_emails.follow': '1',
  26. },
  27. },
  28. }
  29. expect(response).to redirect_to(settings_preferences_notifications_path)
  30. user.reload
  31. expect(user.settings['notification_emails.follow']).to be true
  32. end
  33. end
  34. end