notifications_controller_spec.rb 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. it 'returns http success' do
  11. get :show
  12. expect(response).to have_http_status(200)
  13. end
  14. end
  15. describe 'PUT #update' do
  16. it 'updates notifications settings' do
  17. user.settings['notification_emails'] = user.settings['notification_emails'].merge('follow' => false)
  18. user.settings['interactions'] = user.settings['interactions'].merge('must_be_follower' => true)
  19. put :update, params: {
  20. user: {
  21. notification_emails: { follow: '1' },
  22. interactions: { must_be_follower: '0' },
  23. },
  24. }
  25. expect(response).to redirect_to(settings_preferences_notifications_path)
  26. user.reload
  27. expect(user.settings['notification_emails']['follow']).to be true
  28. expect(user.settings['interactions']['must_be_follower']).to be false
  29. end
  30. end
  31. end