logo

mastofe

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

scoped_settings_spec.rb (999B)


  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe Settings::ScopedSettings do
  4. let(:object) { Fabricate(:user) }
  5. let(:scoped_setting) { described_class.new(object) }
  6. let(:val) { 'whatever' }
  7. let(:methods) { %i(auto_play_gif default_sensitive unfollow_modal boost_modal delete_modal reduce_motion system_font_ui noindex theme) }
  8. describe '.initialize' do
  9. it 'sets @object' do
  10. scoped_setting = described_class.new(object)
  11. expect(scoped_setting.instance_variable_get(:@object)).to be object
  12. end
  13. end
  14. describe '#method_missing' do
  15. it 'sets scoped_setting.method_name = val' do
  16. methods.each do |key|
  17. scoped_setting.send("#{key}=", val)
  18. expect(scoped_setting.send(key)).to eq val
  19. end
  20. end
  21. end
  22. describe '#[]= and #[]' do
  23. it 'sets [key] = val' do
  24. methods.each do |key|
  25. scoped_setting[key] = val
  26. expect(scoped_setting[key]).to eq val
  27. end
  28. end
  29. end
  30. end