notifications_controller_spec.rb 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. 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' 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. it 'updates notifications settings' do
  22. user.settings.update('notification_emails.follow': false, 'interactions.must_be_follower': true)
  23. user.save
  24. put :update, params: {
  25. user: {
  26. settings_attributes: {
  27. 'notification_emails.follow': '1',
  28. 'interactions.must_be_follower': '0',
  29. },
  30. },
  31. }
  32. expect(response).to redirect_to(settings_preferences_notifications_path)
  33. user.reload
  34. expect(user.settings['notification_emails.follow']).to be true
  35. expect(user.settings['interactions.must_be_follower']).to be false
  36. end
  37. end
  38. end