闭社主体 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.

45 lines
1.3 KiB

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