logo

mastofe

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

user_settings_decorator_spec.rb (2483B)


  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe UserSettingsDecorator do
  4. describe 'update' do
  5. let(:user) { Fabricate(:user) }
  6. let(:settings) { described_class.new(user) }
  7. it 'updates the user settings value for email notifications' do
  8. values = { 'notification_emails' => { 'follow' => '1' } }
  9. settings.update(values)
  10. expect(user.settings['notification_emails']['follow']).to eq true
  11. end
  12. it 'updates the user settings value for interactions' do
  13. values = { 'interactions' => { 'must_be_follower' => '0' } }
  14. settings.update(values)
  15. expect(user.settings['interactions']['must_be_follower']).to eq false
  16. end
  17. it 'updates the user settings value for privacy' do
  18. values = { 'setting_default_privacy' => 'public' }
  19. settings.update(values)
  20. expect(user.settings['default_privacy']).to eq 'public'
  21. end
  22. it 'updates the user settings value for sensitive' do
  23. values = { 'setting_default_sensitive' => '1' }
  24. settings.update(values)
  25. expect(user.settings['default_sensitive']).to eq true
  26. end
  27. it 'updates the user settings value for unfollow modal' do
  28. values = { 'setting_unfollow_modal' => '0' }
  29. settings.update(values)
  30. expect(user.settings['unfollow_modal']).to eq false
  31. end
  32. it 'updates the user settings value for boost modal' do
  33. values = { 'setting_boost_modal' => '1' }
  34. settings.update(values)
  35. expect(user.settings['boost_modal']).to eq true
  36. end
  37. it 'updates the user settings value for delete toot modal' do
  38. values = { 'setting_delete_modal' => '0' }
  39. settings.update(values)
  40. expect(user.settings['delete_modal']).to eq false
  41. end
  42. it 'updates the user settings value for gif auto play' do
  43. values = { 'setting_auto_play_gif' => '0' }
  44. settings.update(values)
  45. expect(user.settings['auto_play_gif']).to eq false
  46. end
  47. it 'updates the user settings value for system font in UI' do
  48. values = { 'setting_system_font_ui' => '0' }
  49. settings.update(values)
  50. expect(user.settings['system_font_ui']).to eq false
  51. end
  52. it 'decoerces setting values before applying' do
  53. values = {
  54. 'setting_delete_modal' => 'false',
  55. 'setting_boost_modal' => 'true',
  56. }
  57. settings.update(values)
  58. expect(user.settings['delete_modal']).to eq false
  59. expect(user.settings['boost_modal']).to eq true
  60. end
  61. end
  62. end