thecore_settings 1.1.15 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/.devcontainer/Dockerfile +20 -0
  3. data/.devcontainer/devcontainer.json +33 -0
  4. data/.github/workflows/gempush.yml +34 -0
  5. data/.gitignore +542 -0
  6. data/.rakeTasks +7 -0
  7. data/.rspec +1 -0
  8. data/.ruby-version +1 -0
  9. data/.travis.yml +31 -0
  10. data/CHANGELOG.md +81 -0
  11. data/Gemfile +4 -0
  12. data/Gemfile.lock +275 -0
  13. data/LICENSE.txt +22 -0
  14. data/README.md +169 -0
  15. data/README.rdoc +68 -0
  16. data/Rakefile +6 -34
  17. data/app/{assets/config/thecore_settings_manifest.js → models/.keep} +0 -0
  18. data/app/models/thecore_settings/setting.rb +77 -0
  19. data/app/views/.keep +0 -0
  20. data/app/views/rails_admin/main/_setting_value.html.haml +41 -0
  21. data/bin/rails +13 -0
  22. data/config/locales/en.yml +29 -0
  23. data/config/locales/{thecore_settings.it.yml → it.yml} +2 -2
  24. data/config/locales/pt-BR.yml +28 -0
  25. data/config/locales/ru.yml +29 -0
  26. data/db/migrate/20161227101954_create_rails_admin_settings.rb +4 -4
  27. data/gemfiles/mongoid-6.0.gemfile +5 -0
  28. data/gemfiles/mongoid-6.3.gemfile +5 -0
  29. data/lib/generators/thecore_settings/migration_generator.rb +15 -0
  30. data/lib/generators/thecore_settings/templates/db/migrate/20161227101954_create_thecore_settings.rb +29 -0
  31. data/lib/generators/thecore_settings/templates/migration.rb +29 -0
  32. data/lib/thecore_settings/determine_mime_type.rb +193 -0
  33. data/lib/thecore_settings/dumper.rb +12 -0
  34. data/lib/thecore_settings/engine.rb +17 -3
  35. data/lib/thecore_settings/fallback.rb +21 -0
  36. data/lib/thecore_settings/hex_color_validator.rb +11 -0
  37. data/lib/thecore_settings/kinds.rb +34 -0
  38. data/lib/thecore_settings/mongoid.rb +19 -0
  39. data/lib/thecore_settings/namespaced.rb +210 -0
  40. data/lib/thecore_settings/processing.rb +217 -0
  41. data/lib/thecore_settings/rails_admin_config.rb +71 -0
  42. data/lib/thecore_settings/require_helpers.rb +86 -0
  43. data/lib/thecore_settings/settings.rb +95 -0
  44. data/lib/thecore_settings/storage/carrier_wave_uploader.rb +9 -0
  45. data/lib/thecore_settings/storage/shrine_uploader.rb +14 -0
  46. data/lib/thecore_settings/tasks.rb +35 -0
  47. data/lib/thecore_settings/uploads.rb +57 -0
  48. data/lib/thecore_settings/validation.rb +126 -0
  49. data/lib/thecore_settings/version.rb +1 -1
  50. data/lib/thecore_settings.rb +115 -123
  51. data/spec/advanced_usage_spec.rb +11 -0
  52. data/spec/carrierwave_spec.rb +41 -0
  53. data/spec/database_trickery_spec.rb +48 -0
  54. data/spec/defaults_spec.rb +87 -0
  55. data/spec/enabling_spec.rb +29 -0
  56. data/spec/factories/setting.rb +8 -0
  57. data/spec/label_spec.rb +16 -0
  58. data/spec/migration_spec.rb +20 -0
  59. data/spec/model_spec.rb +105 -0
  60. data/spec/namespaced_spec.rb +67 -0
  61. data/spec/paperclip_spec.rb +38 -0
  62. data/spec/settings_spec.rb +75 -0
  63. data/spec/shrine_spec.rb +34 -0
  64. data/spec/spec_helper.rb +85 -0
  65. data/spec/support/1024x768.gif +0 -0
  66. data/spec/support/database_cleaner.rb +10 -0
  67. data/spec/support/defaults.yml +23 -0
  68. data/spec/support/defaults_w_file.yml +19 -0
  69. data/spec/support/mongoid.rb +6 -0
  70. data/spec/support/mongoid.yml +6 -0
  71. data/spec/types_spec.rb +101 -0
  72. data/thecore_settings.gemspec +44 -0
  73. metadata +326 -63
  74. data/app/assets/stylesheets/rich/editor.css +0 -20
  75. data/config/initializers/rails_admin_requirements.rb +0 -22
  76. data/config/initializers/thecore_settings_abilities.rb +0 -22
  77. data/config/initializers/thecore_settings_post_init.rb +0 -9
  78. data/config/routes.rb +0 -3
  79. data/db/migrate/20161227101956_add_app_name.rb +0 -5
  80. data/lib/tasks/thecore_settings_tasks.rake +0 -4
@@ -0,0 +1,11 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'Settings advanced usage' do
6
+ it 'with defaults' do
7
+ s = Settings.email(default: 'test@example.com')
8
+ expect(s).to eq 'test@example.com'
9
+ expect(Settings.get(:email).to_s).to eq 'test@example.com'
10
+ end
11
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Uploads" do
4
+ if Settings.file_uploads_engine != :carrierwave
5
+ pending "paperclip not detected, skipped. To run use UPLOADS=carrierwave rspec"
6
+ else
7
+ before :each do
8
+ f = "#{File.dirname(__FILE__)}/../uploads/1024x768.gif"
9
+ if File.file?(f)
10
+ File.unlink(f)
11
+ end
12
+ end
13
+ it 'supports file kind' do
14
+ Settings.set('file', File.open("#{File.dirname(__FILE__)}/support/1024x768.gif"), kind: 'file')
15
+
16
+ # because we're not inside Rails
17
+ Settings.get(:file).file.root = '/'
18
+
19
+ expect(Settings.get(:file).file.file.file).to eq "#{File.dirname(__FILE__).gsub('/spec', '/')}uploads/1024x768.gif"
20
+
21
+ expect(File.exists?(Settings.root_file_path.join("uploads/1024x768.gif"))).to be_truthy
22
+ end
23
+
24
+ it 'supports image kind' do
25
+ Settings.set('file', File.open("#{File.dirname(__FILE__)}/support/1024x768.gif"), kind: 'image')
26
+
27
+ # because we're not inside Rails
28
+ Settings.get(:file).file.root = '/'
29
+
30
+ expect(Settings.get(:file).file.file.file).to eq "#{File.dirname(__FILE__).gsub('/spec', '/')}uploads/1024x768.gif"
31
+
32
+ expect(File.exists?(Settings.root_file_path.join("uploads/1024x768.gif"))).to be_truthy
33
+ end
34
+
35
+ it 'supports defaults' do
36
+ Settings.apply_defaults!(File.join(File.dirname(__FILE__), 'support/defaults_w_file.yml'))
37
+ expect(File.exists?(Settings.root_file_path.join("uploads/1024x768.gif"))).to be_truthy
38
+ end
39
+ end
40
+ end
41
+
@@ -0,0 +1,48 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ # this tests check how well thecore_settings handles settings disappearing from DB during execution
6
+ # real usage: app specs with database_cleaner enabled
7
+ describe 'Database trickery' do
8
+
9
+ it "should handle settings disappearing from DB" do
10
+ email = "my@mail.ru"
11
+ email2 = "my2@mail.ru"
12
+ Settings.email = email
13
+ expect(Settings.email).to eq(email)
14
+ ThecoreSettings::Setting.destroy_all
15
+ # settings are still cached
16
+ expect(Settings.email).to eq(email)
17
+
18
+ Settings.email = email2
19
+ expect(Settings.email).to eq(email2)
20
+ end
21
+
22
+ it "should handle settings appearing in DB when settings are loaded" do
23
+ expect(Settings.tst2).to eq('')
24
+ ThecoreSettings::Setting.create!(key: 'tst', raw: 'tst')
25
+ # settings are still cached, but when we try to create a setting it sees updated value in DB
26
+ expect(Settings.tst).to eq('tst')
27
+ end
28
+
29
+ it "should handle settings appearing in DB when settings are not loaded" do
30
+ ThecoreSettings::Setting.create(key: 'tst', raw: 'tst')
31
+ Settings.tst = 'str'
32
+ expect(Settings.tst).to eq('str')
33
+ end
34
+
35
+ it "#destroy_all!" do
36
+ Settings.tst = 'str'
37
+ Settings.destroy_all!
38
+ expect(Settings.tst).to eq('')
39
+ end
40
+
41
+ it "#destroy!" do
42
+ Settings.tst = 'str'
43
+ Settings.tst2 = 'str2'
44
+ Settings.destroy!(:tst)
45
+ expect(Settings.tst).to eq('')
46
+ expect(Settings.tst2).to eq('str2')
47
+ end
48
+ end
@@ -0,0 +1,87 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'Settings loading defaults' do
6
+ before :each do
7
+ Settings.apply_defaults!(File.join(File.dirname(__FILE__), 'support/defaults.yml'))
8
+ end
9
+
10
+ it 'loads twice ok' do
11
+ Settings.apply_defaults!(File.join(File.dirname(__FILE__), 'support/defaults.yml'))
12
+ Settings.apply_defaults!(File.join(File.dirname(__FILE__), 'support/defaults.yml'))
13
+ end
14
+
15
+ it 'sets value' do
16
+ expect(Settings.footer).to eq 'test <b></b>'
17
+ expect(Settings.get(:footer).kind).to eq 'html'
18
+ end
19
+
20
+ it 'sets kind' do
21
+ expect(Settings.get(:phone).phone_kind?).to be_truthy
22
+ expect(Settings.get(:phone).val.city).to eq '906'
23
+ expect(Settings.get(:phone).val.formatted_subscriber).to eq '111-11-11'
24
+ end
25
+
26
+ it 'sets enabled' do
27
+ expect(Settings.phone_enabled?).to eq true
28
+ expect(Settings.disabled_enabled?).to eq false
29
+ expect(Settings.enabled?(:disabled)).to eq false
30
+ end
31
+
32
+ it 'works with namespace' do
33
+ expect(Settings.ns(:main).phone).to eq '906 1111111'
34
+ expect(Settings.ns(:other).footer).to eq 'zzz'
35
+ expect(Settings.footer).to eq 'test <b></b>'
36
+ expect(Settings.ns(:main).footer).to eq 'test <b></b>'
37
+ end
38
+
39
+ it 'works with fallback' do
40
+ expect(Settings.ns(:etc, fallback: :main).phone).to eq '906 1111111'
41
+ expect(Settings.ns(:etc, fallback: :main).footer).to eq 'test <b></b>'
42
+ expect(Settings.ns(:other, fallback: :main).footer).to eq 'zzz'
43
+ expect(Settings.ns(:etc, fallback: :other).footer).to eq 'zzz'
44
+ end
45
+
46
+ it 'works with custom default namespace' do
47
+ Settings.ns_default = 'other'
48
+ Settings.ns_fallback = 'other'
49
+
50
+ expect(Settings.ns(:main).phone).to eq '906 1111111'
51
+ expect(Settings.ns(:other).footer).to eq 'zzz'
52
+ expect(Settings.ns(:main).footer).to eq 'test <b></b>'
53
+ expect(Settings.footer).to eq 'zzz'
54
+
55
+ expect(Settings.ns(:main).phone).to eq '906 1111111'
56
+ expect(Settings.ns(:main).true_setting).to be true
57
+ expect(Settings.ns(:main).false_setting).to be false
58
+ expect(Settings.ns(:other).footer).to eq 'zzz'
59
+ expect(Settings.ns(:main).footer).to eq 'test <b></b>'
60
+ expect(Settings.footer).to eq 'zzz'
61
+
62
+ expect(Settings.ns(:etc, fallback: :main).phone).to eq '906 1111111'
63
+ expect(Settings.ns(:etc, fallback: :main).footer).to eq 'test <b></b>'
64
+ expect(Settings.ns(:other, fallback: :main).footer).to eq 'zzz'
65
+ expect(Settings.ns(:etc, fallback: :other).footer).to eq 'zzz'
66
+
67
+ Settings.ns_default = :etc
68
+ Settings.ns_fallback = :main
69
+ expect(Settings.phone).to eq '906 1111111'
70
+ expect(Settings.footer).to eq 'test <b></b>'
71
+
72
+ Settings.ns_fallback = :other
73
+ expect(Settings.footer).to eq 'zzz'
74
+
75
+ Settings.ns_default = :other
76
+ Settings.ns_fallback = :main
77
+ expect(Settings.footer).to eq 'zzz'
78
+ end
79
+
80
+ it "doesn't overwrite" do
81
+ Settings.ns(:main).phone = '906 2222222'
82
+ Settings.ns(:other).footer = 'xxx'
83
+ Settings.apply_defaults!(File.join(File.dirname(__FILE__), 'support/defaults.yml'))
84
+ expect(Settings.ns(:main).phone).to eq '906 2222222'
85
+ expect(Settings.ns(:other).footer).to eq 'xxx'
86
+ end
87
+ end
@@ -0,0 +1,29 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'Settings enabling and disabling' do
6
+ it 'works for name_enabled? and name_enabled =' do
7
+ Settings.zzz = '123'
8
+ expect(Settings.zzz).to eq '123'
9
+ expect(Settings.get(:zzz).enabled).to eq true
10
+ expect(Settings.enabled?(:zzz)).to eq true
11
+ expect(Settings.zzz_enabled?).to eq true
12
+
13
+ expect(Settings.zzz).to eq '123'
14
+ Settings.zzz_enabled = false
15
+ expect(Settings.zzz_enabled?).to eq false
16
+ expect(Settings.get(:zzz).enabled).to eq false
17
+ expect(Settings.enabled?(:zzz)).to eq false
18
+ expect(Settings.zzz).to eq ''
19
+ Settings.unload!
20
+ expect(Settings.zzz).to eq ''
21
+ expect(Settings.get(:zzz).raw).to eq '123'
22
+
23
+ Settings.zzz_enabled = true
24
+ expect(Settings.zzz).to eq '123'
25
+ expect(Settings.zzz_enabled?).to eq true
26
+ expect(Settings.get(:zzz).enabled).to eq true
27
+ expect(Settings.enabled?(:zzz)).to eq true
28
+ end
29
+ end
@@ -0,0 +1,8 @@
1
+ # coding: utf-8
2
+
3
+ FactoryBot.define do
4
+ factory :setting, class: ThecoreSettings::Setting do
5
+ sequence(:key){|n| "setting_#{n}" }
6
+ raw { "Контент 1" }
7
+ end
8
+ end
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'Settings label' do
6
+ it "should have label" do
7
+ label = "E-Mail"
8
+ Settings.email(label: label, default: "my@mail.ru")
9
+ expect(Settings.get(:email).name).to eq(label)
10
+ end
11
+
12
+ it "should properly set label as key if blank" do
13
+ Settings.email(default: "my@mail.ru")
14
+ expect(Settings.get(:email).name).to eq('email')
15
+ end
16
+ end
@@ -0,0 +1,20 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'Migrating from old versions' do
6
+ it 'sets ns' do
7
+ coll = ThecoreSettings::Setting.collection
8
+ if coll.respond_to?(:insert_one)
9
+ coll.insert_one({enabled: true, key: 'test', raw: '9060000000', type: 'phone'})
10
+ else
11
+ coll.insert({enabled: true, key: 'test', raw: '9060000000', type: 'phone'})
12
+ end
13
+ ThecoreSettings.migrate!
14
+ expect(ThecoreSettings::Setting.first.key).to eq 'test'
15
+ expect(ThecoreSettings::Setting.first.raw).to eq '9060000000'
16
+ expect(ThecoreSettings::Setting.first.ns).to eq 'main'
17
+ expect(ThecoreSettings::Setting.first.kind).to eq 'phone'
18
+ end
19
+ end
20
+
@@ -0,0 +1,105 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe ThecoreSettings::Setting do
6
+ it { is_expected.to have_fields(:enabled, :key, :kind, :raw) }
7
+
8
+ it "correctly return content when enabled" do
9
+ setting = FactoryBot.create(:setting)
10
+ expect(setting.to_s).to eq "Контент 1"
11
+ end
12
+
13
+ it "return empty string when disabled" do
14
+ setting = FactoryBot.create(:setting, enabled: false)
15
+ expect(setting.to_s).to eq ""
16
+ end
17
+
18
+ it "correctly process {{year}}" do
19
+ setting = FactoryBot.create(:setting, raw: '&copy; {{year}} company')
20
+ expect(setting.val).to eq "&copy; #{Time.now.strftime('%Y')} company"
21
+ end
22
+
23
+ it "correctly process {{year|2010}}" do
24
+ setting = FactoryBot.create(:setting, raw: '&copy; {{year|2010}} company')
25
+ expect(setting.val).to eq "&copy; 2010-#{Time.now.strftime('%Y')} company"
26
+ end
27
+
28
+ it "correctly process {{year|current_year}}" do
29
+ setting = FactoryBot.create(:setting, raw: '&copy; {{year|' + Time.now.strftime('%Y') + '}} company')
30
+ expect(setting.val).to eq "&copy; #{Time.now.strftime('%Y')} company"
31
+ expect(setting.val.class.name).not_to eq "ActiveSupport::SafeBuffer"
32
+ end
33
+
34
+ it 'return html_safe string when in html mode' do
35
+ setting = FactoryBot.create(:setting, raw: '&copy; {{year}} company', kind: 'html')
36
+ expect(setting.val).to eq "&copy; #{Time.now.strftime('%Y')} company"
37
+ expect(setting.val.class.name).to eq "ActiveSupport::SafeBuffer"
38
+ end
39
+
40
+ it 'sanitize html when in sanitized mode' do
41
+ setting = FactoryBot.create(:setting, raw: '&copy; {{year}} company <a href="javascript:alert()">test</a>', kind: 'sanitized')
42
+ expect(setting.val).to eq "© #{Time.now.strftime('%Y')} company <a>test</a>"
43
+ expect(setting.val.class.name).to eq "ActiveSupport::SafeBuffer"
44
+ end
45
+
46
+ it 'sanitize html when in sanitize mode' do
47
+ if defined?(Rails)
48
+ setting = FactoryBot.create(:setting, raw: '&copy; {{year}} company <a href="javascript:alert()">test</a>', kind: 'sanitize')
49
+ expect(setting.val).to eq "© #{Time.now.strftime('%Y')} company <a>test</a>"
50
+ expect(setting.val.class.name).to eq "ActiveSupport::SafeBuffer"
51
+ else
52
+ expect {
53
+ FactoryBot.create(:setting, raw: '&copy; {{year}} company <a href="javascript:alert()">test</a>', kind: 'sanitize')
54
+ }.to raise_error(ThecoreSettings::NoRailsError)
55
+ end
56
+ end
57
+
58
+ it 'sanitize html when in sanitize_code mode' do
59
+ if defined?(Rails)
60
+ setting = FactoryBot.create(:setting, raw: '&copy; {{year}} company <a href="javascript:alert()">test</a>', kind: 'sanitize_code')
61
+ expect(setting.val).to eq "© #{Time.now.strftime('%Y')} company <a>test</a>"
62
+ expect(setting.val.class.name).to eq "ActiveSupport::SafeBuffer"
63
+ else
64
+ expect {
65
+ FactoryBot.create(:setting, raw: '&copy; {{year}} company <a href="javascript:alert()">test</a>', kind: 'sanitize_code')
66
+ }.to raise_error(ThecoreSettings::NoRailsError)
67
+ end
68
+ end
69
+
70
+ it 'remove html when in strip_tags mode' do
71
+ if defined?(Rails)
72
+ setting = FactoryBot.create(:setting, raw: '&copy; {{year}} company <a href="javascript:alert()">test</a>', kind: 'strip_tags')
73
+ expect(setting.val).to eq "© #{Time.now.strftime('%Y')} company test"
74
+ expect(setting.val.class.name).to eq "ActiveSupport::SafeBuffer"
75
+ else
76
+ expect {
77
+ FactoryBot.create(:setting, raw: '&copy; {{year}} company <a href="javascript:alert()">test</a>', kind: 'strip_tags')
78
+ }.to raise_error(ThecoreSettings::NoRailsError)
79
+ end
80
+ end
81
+
82
+ it 'formats text and cleans html in simple_format mode' do
83
+ if defined?(Rails)
84
+ setting = FactoryBot.create(:setting, raw: "&copy; {{year}}\n\ncompany <a href='javascript:alert()'>test</a>", kind: 'simple_format')
85
+ expect(setting.val).to eq "<p>© #{Time.now.strftime('%Y')}</p>\n\n<p>company <a>test</a></p>"
86
+ expect(setting.val.class.name).to eq "ActiveSupport::SafeBuffer"
87
+ else
88
+ expect {
89
+ FactoryBot.create(:setting, raw: "&copy; {{year}}\n\ncompany <a href='javascript:alert()'>test</a>", kind: 'simple_format')
90
+ }.to raise_error(ThecoreSettings::NoRailsError)
91
+ end
92
+ end
93
+
94
+ it 'formats text and DOESNT html in simple_format_raw mode' do
95
+ if defined?(Rails)
96
+ setting = FactoryBot.create(:setting, raw: "&copy; {{year}}\n\ncompany <a href='javascript:alert()'>test</a>", kind: 'simple_format_raw')
97
+ expect(setting.val).to eq "<p>&copy; #{Time.now.strftime('%Y')}</p>\n\n<p>company <a href='javascript:alert()'>test</a></p>"
98
+ expect(setting.val.class.name).to eq "ActiveSupport::SafeBuffer"
99
+ else
100
+ expect {
101
+ FactoryBot.create(:setting, raw: "&copy; {{year}}\n\ncompany <a href='javascript:alert()'>test</a>", kind: 'simple_format_raw')
102
+ }.to raise_error(ThecoreSettings::NoRailsError)
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,67 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'Namespaced settings' do
6
+ before :each do
7
+ Settings.destroy_all!
8
+ end
9
+
10
+ it 'sets namespaced' do
11
+ Settings.ns(:other).test = 'test'
12
+ end
13
+
14
+ it 'reads namespaced from cache' do
15
+ ns = Settings.ns(:other)
16
+ ns.test = 'test'
17
+ expect(ns.test).to eq 'test'
18
+ end
19
+
20
+ it 'reads namespaced from db' do
21
+ Settings.ns(:other).test = 'test'
22
+ expect(Settings.ns(:other).test).to eq 'test'
23
+ end
24
+
25
+ it 'destroys' do
26
+ Settings.ns(:other).test = 'test'
27
+ Settings.ns(:other).destroy_all!
28
+ expect(Settings.ns(:other).test).to eq ''
29
+ end
30
+
31
+ it 'sets kind' do
32
+ expect {
33
+ Settings.ns(:other).set(:phone, 'test', kind: 'phone')
34
+ }.to raise_error
35
+ Settings.ns(:other).set(:phone, '906 111 11 11', kind: 'phone')
36
+ expect(Settings.get(:phone, ns: 'other').phone_kind?).to be_truthy
37
+ expect(Settings.get(:phone, ns: 'other').val.city).to eq '906'
38
+ expect(Settings.get(:phone, ns: 'other').val.formatted_subscriber).to eq '111-11-11'
39
+
40
+ ns = Settings.ns(:other)
41
+ expect(ns.get(:phone).phone_kind?).to be_truthy
42
+ expect(ns.get(:phone).val.city).to eq '906'
43
+ expect(ns.get(:phone).val.formatted_subscriber).to eq '111-11-11'
44
+ end
45
+
46
+ it 'works with custom defaults' do
47
+ Settings.ns_default = 'hitfood'
48
+ Settings.ns_fallback = 'main'
49
+ expect(Settings.test).to eq ''
50
+ Settings.test = 'zzz'
51
+ expect(Settings.get(:test, ns: 'hitfood').raw).to eq 'zzz'
52
+ expect(Settings.get(:test, ns: 'main').raw).to eq ''
53
+ end
54
+
55
+ it 'falls back to default ns' do
56
+ Settings.ns_default = 'main'
57
+ Settings.ns_fallback = 'main'
58
+
59
+ Settings.ns(:main).test = 'main'
60
+ Settings.ns(:other).test = 'other'
61
+
62
+ expect(Settings.ns('main').test).to eq 'main'
63
+ expect(Settings.ns('other').test).to eq 'other'
64
+ expect(Settings.ns('other1').test).to eq 'main'
65
+ expect(Settings.ns('other2', fallback: nil).test).to eq ''
66
+ end
67
+ end