logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

preferences_controller_spec.rb (1148B)


  1. require 'rails_helper'
  2. describe Settings::PreferencesController do
  3. render_views
  4. let(:user) { Fabricate(:user, filtered_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', filtered_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.filtered_languages).to eq ['es', 'fr']
  21. end
  22. it 'updates user settings' do
  23. user.settings['boost_modal'] = false
  24. user.settings['delete_modal'] = true
  25. put :update, params: {
  26. user: {
  27. setting_boost_modal: '1',
  28. setting_delete_modal: '0',
  29. }
  30. }
  31. expect(response).to redirect_to(settings_preferences_path)
  32. user.reload
  33. expect(user.settings['boost_modal']).to be true
  34. expect(user.settings['delete_modal']).to be false
  35. end
  36. end
  37. end