Use dynamic list for allowed user preference params

This commit is contained in:
2024-05-23 00:23:42 +02:00
parent b541e95bb7
commit bad3b7a2be
3 changed files with 18 additions and 5 deletions

View File

@@ -38,4 +38,15 @@ RSpec.describe UserPreferences, type: :model do
expect(res['lightning_notify_sats_received_threshold']).to eq(1000)
end
end
describe ".pref_keys" do
let(:default_prefs) { YAML.load_file("#{Rails.root}/config/default_preferences.yml") }
it "returns the keys of all default preferences as an array of symbols" do
expect(UserPreferences.pref_keys).to be_a(Array)
expect(UserPreferences.pref_keys).to include(:lightning_notify_sats_received)
expect(UserPreferences.pref_keys).to include(:xmpp_exchange_contacts_with_invitees)
expect(UserPreferences.pref_keys.length).to eq(default_prefs.keys.length)
end
end
end