闭社主体 forked from https://github.com/tootsuite/mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.4 KiB

  1. require 'rails_helper'
  2. describe Settings::PreferencesController do
  3. render_views
  4. let(:user) { Fabricate(:user, allowed_languages: []) }
  5. before do
  6. sign_in user, scope: :user
  7. end
  8. describe 'GET #show' do
  9. it 'returns http success' do
  10. get :show
  11. expect(response).to have_http_status(:success)
  12. end
  13. end
  14. describe 'PUT #update' do
  15. it 'updates the user record' do
  16. put :update, params: { user: { locale: 'en', allowed_languages: ['es', 'fr', ''] } }
  17. expect(response).to redirect_to(settings_preferences_path)
  18. user.reload
  19. expect(user.locale).to eq 'en'
  20. expect(user.allowed_languages).to eq ['es', 'fr']
  21. end
  22. it 'updates user settings' do
  23. user.settings['boost_modal'] = false
  24. user.settings['notification_emails'] = user.settings['notification_emails'].merge('follow' => false)
  25. user.settings['interactions'] = user.settings['interactions'].merge('must_be_follower' => true)
  26. put :update, params: {
  27. user: {
  28. setting_boost_modal: '1',
  29. notification_emails: { follow: '1' },
  30. interactions: { must_be_follower: '0' },
  31. }
  32. }
  33. expect(response).to redirect_to(settings_preferences_path)
  34. user.reload
  35. expect(user.settings['boost_modal']).to be true
  36. expect(user.settings['notification_emails']['follow']).to be true
  37. expect(user.settings['interactions']['must_be_follower']).to be false
  38. end
  39. end
  40. end