thecore_settings 2.0.9 → 3.0.0

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 (47) hide show
  1. checksums.yaml +4 -4
  2. data/app/views/rails_admin/main/_setting_value.html.erb +51 -0
  3. data/lib/thecore_settings/rails_admin_config.rb +1 -1
  4. data/lib/thecore_settings/version.rb +2 -3
  5. metadata +25 -212
  6. data/.devcontainer/Dockerfile +0 -20
  7. data/.devcontainer/devcontainer.json +0 -33
  8. data/.github/workflows/gempush.yml +0 -33
  9. data/.gitignore +0 -542
  10. data/.rakeTasks +0 -7
  11. data/.rspec +0 -1
  12. data/.ruby-gemset +0 -1
  13. data/.ruby-version +0 -1
  14. data/.travis.yml +0 -31
  15. data/CHANGELOG.md +0 -81
  16. data/Gemfile +0 -6
  17. data/Gemfile.lock +0 -290
  18. data/LICENSE.txt +0 -22
  19. data/README.rdoc +0 -68
  20. data/app/models/.keep +0 -0
  21. data/app/views/.keep +0 -0
  22. data/app/views/rails_admin/main/_setting_value.html.haml +0 -41
  23. data/bin/rails +0 -14
  24. data/gemfiles/mongoid-6.0.gemfile +0 -5
  25. data/gemfiles/mongoid-6.3.gemfile +0 -5
  26. data/spec/advanced_usage_spec.rb +0 -11
  27. data/spec/carrierwave_spec.rb +0 -41
  28. data/spec/database_trickery_spec.rb +0 -48
  29. data/spec/defaults_spec.rb +0 -87
  30. data/spec/enabling_spec.rb +0 -29
  31. data/spec/factories/setting.rb +0 -8
  32. data/spec/label_spec.rb +0 -16
  33. data/spec/migration_spec.rb +0 -20
  34. data/spec/model_spec.rb +0 -105
  35. data/spec/namespaced_spec.rb +0 -67
  36. data/spec/paperclip_spec.rb +0 -38
  37. data/spec/settings_spec.rb +0 -75
  38. data/spec/shrine_spec.rb +0 -34
  39. data/spec/spec_helper.rb +0 -85
  40. data/spec/support/1024x768.gif +0 -0
  41. data/spec/support/database_cleaner.rb +0 -10
  42. data/spec/support/defaults.yml +0 -23
  43. data/spec/support/defaults_w_file.yml +0 -19
  44. data/spec/support/mongoid.rb +0 -6
  45. data/spec/support/mongoid.yml +0 -6
  46. data/spec/types_spec.rb +0 -101
  47. data/thecore_settings.gemspec +0 -45
data/Gemfile.lock DELETED
@@ -1,290 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- thecore_settings (2.0.9)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- actioncable (5.2.8.1)
10
- actionpack (= 5.2.8.1)
11
- nio4r (~> 2.0)
12
- websocket-driver (>= 0.6.1)
13
- actionmailer (5.2.8.1)
14
- actionpack (= 5.2.8.1)
15
- actionview (= 5.2.8.1)
16
- activejob (= 5.2.8.1)
17
- mail (~> 2.5, >= 2.5.4)
18
- rails-dom-testing (~> 2.0)
19
- actionpack (5.2.8.1)
20
- actionview (= 5.2.8.1)
21
- activesupport (= 5.2.8.1)
22
- rack (~> 2.0, >= 2.0.8)
23
- rack-test (>= 0.6.3)
24
- rails-dom-testing (~> 2.0)
25
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
26
- actionview (5.2.8.1)
27
- activesupport (= 5.2.8.1)
28
- builder (~> 3.1)
29
- erubi (~> 1.4)
30
- rails-dom-testing (~> 2.0)
31
- rails-html-sanitizer (~> 1.0, >= 1.0.3)
32
- activejob (5.2.8.1)
33
- activesupport (= 5.2.8.1)
34
- globalid (>= 0.3.6)
35
- activemodel (5.2.8.1)
36
- activesupport (= 5.2.8.1)
37
- activerecord (5.2.8.1)
38
- activemodel (= 5.2.8.1)
39
- activesupport (= 5.2.8.1)
40
- arel (>= 9.0)
41
- activestorage (5.2.8.1)
42
- actionpack (= 5.2.8.1)
43
- activerecord (= 5.2.8.1)
44
- marcel (~> 1.0.0)
45
- activesupport (5.2.8.1)
46
- concurrent-ruby (~> 1.0, >= 1.0.2)
47
- i18n (>= 0.7, < 2)
48
- minitest (~> 5.1)
49
- tzinfo (~> 1.1)
50
- addressable (2.8.1)
51
- public_suffix (>= 2.0.2, < 6.0)
52
- arel (9.0.0)
53
- ast (2.4.2)
54
- bson (4.15.0)
55
- builder (3.2.4)
56
- carrierwave (2.2.3)
57
- activemodel (>= 5.0.0)
58
- activesupport (>= 5.0.0)
59
- addressable (~> 2.6)
60
- image_processing (~> 1.1)
61
- marcel (~> 1.0.0)
62
- mini_mime (>= 0.1.3)
63
- ssrf_filter (~> 1.0)
64
- carrierwave-mongoid (1.4.0)
65
- carrierwave (>= 0.8, < 3)
66
- mongoid (>= 3.0, < 9.0)
67
- mongoid-grid_fs (>= 1.3, < 3.0)
68
- climate_control (0.2.0)
69
- concurrent-ruby (1.2.2)
70
- content_disposition (1.0.0)
71
- crass (1.0.6)
72
- database_cleaner (2.0.2)
73
- database_cleaner-active_record (>= 2, < 3)
74
- database_cleaner-active_record (2.1.0)
75
- activerecord (>= 5.a)
76
- database_cleaner-core (~> 2.0.0)
77
- database_cleaner-core (2.0.1)
78
- date (3.3.3)
79
- diff-lcs (1.5.0)
80
- docile (1.4.0)
81
- down (5.4.0)
82
- addressable (~> 2.8)
83
- erubi (1.12.0)
84
- factory_bot (6.2.1)
85
- activesupport (>= 5.0.0)
86
- ffi (1.15.5)
87
- geocoder (1.8.1)
88
- globalid (1.1.0)
89
- activesupport (>= 5.0)
90
- i18n (1.12.0)
91
- concurrent-ruby (~> 1.0)
92
- image_processing (1.12.2)
93
- mini_magick (>= 4.9.5, < 5)
94
- ruby-vips (>= 2.0.17, < 3)
95
- json (2.6.3)
96
- kt-paperclip (7.1.1)
97
- activemodel (>= 4.2.0)
98
- activesupport (>= 4.2.0)
99
- marcel (~> 1.0.1)
100
- mime-types
101
- terrapin (~> 0.6.0)
102
- loofah (2.19.1)
103
- crass (~> 1.0.2)
104
- nokogiri (>= 1.5.9)
105
- mail (2.8.1)
106
- mini_mime (>= 0.1.1)
107
- net-imap
108
- net-pop
109
- net-smtp
110
- marcel (1.0.2)
111
- method_source (1.0.0)
112
- mime-types (3.4.1)
113
- mime-types-data (~> 3.2015)
114
- mime-types-data (3.2023.0218.1)
115
- mini_magick (4.12.0)
116
- mini_mime (1.1.2)
117
- mini_portile2 (2.8.1)
118
- minitest (5.18.0)
119
- mongo (2.18.2)
120
- bson (>= 4.14.1, < 5.0.0)
121
- mongoid (6.4.8)
122
- activemodel (>= 5.1, < 6.0.0)
123
- mongo (>= 2.5.1, < 3.0.0)
124
- mongoid-compatibility (0.6.0)
125
- activesupport
126
- mongoid (>= 2.0)
127
- mongoid-grid_fs (2.5.0)
128
- mime-types (>= 1.0, < 4.0)
129
- mongoid (>= 3.0, < 9.0)
130
- mongoid-paperclip (0.1.0)
131
- kt-paperclip
132
- mongoid
133
- mongoid-rspec (4.1.0)
134
- activesupport (>= 3.0.0)
135
- mongoid (>= 3.1)
136
- mongoid-compatibility (>= 0.5.1)
137
- rspec-core (~> 3.3)
138
- rspec-expectations (~> 3.3)
139
- rspec-mocks (~> 3.3)
140
- net-imap (0.3.4)
141
- date
142
- net-protocol
143
- net-pop (0.1.2)
144
- net-protocol
145
- net-protocol (0.2.1)
146
- timeout
147
- net-smtp (0.3.3)
148
- net-protocol
149
- nio4r (2.5.8)
150
- nokogiri (1.14.2)
151
- mini_portile2 (~> 2.8.0)
152
- racc (~> 1.4)
153
- parallel (1.22.1)
154
- parser (3.2.1.1)
155
- ast (~> 2.4.1)
156
- public_suffix (5.0.1)
157
- racc (1.6.2)
158
- rack (2.2.6.4)
159
- rack-test (2.1.0)
160
- rack (>= 1.3)
161
- rails (5.2.8.1)
162
- actioncable (= 5.2.8.1)
163
- actionmailer (= 5.2.8.1)
164
- actionpack (= 5.2.8.1)
165
- actionview (= 5.2.8.1)
166
- activejob (= 5.2.8.1)
167
- activemodel (= 5.2.8.1)
168
- activerecord (= 5.2.8.1)
169
- activestorage (= 5.2.8.1)
170
- activesupport (= 5.2.8.1)
171
- bundler (>= 1.3.0)
172
- railties (= 5.2.8.1)
173
- sprockets-rails (>= 2.0.0)
174
- rails-dom-testing (2.0.3)
175
- activesupport (>= 4.2.0)
176
- nokogiri (>= 1.6)
177
- rails-html-sanitizer (1.5.0)
178
- loofah (~> 2.19, >= 2.19.1)
179
- railties (5.2.8.1)
180
- actionpack (= 5.2.8.1)
181
- activesupport (= 5.2.8.1)
182
- method_source
183
- rake (>= 0.8.7)
184
- thor (>= 0.19.0, < 2.0)
185
- rainbow (3.1.1)
186
- rake (13.0.6)
187
- regexp_parser (2.7.0)
188
- rexml (3.2.5)
189
- rspec (3.12.0)
190
- rspec-core (~> 3.12.0)
191
- rspec-expectations (~> 3.12.0)
192
- rspec-mocks (~> 3.12.0)
193
- rspec-core (3.12.1)
194
- rspec-support (~> 3.12.0)
195
- rspec-expectations (3.12.2)
196
- diff-lcs (>= 1.2.0, < 2.0)
197
- rspec-support (~> 3.12.0)
198
- rspec-mocks (3.12.4)
199
- diff-lcs (>= 1.2.0, < 2.0)
200
- rspec-support (~> 3.12.0)
201
- rspec-support (3.12.0)
202
- rubocop (1.48.1)
203
- json (~> 2.3)
204
- parallel (~> 1.10)
205
- parser (>= 3.2.0.0)
206
- rainbow (>= 2.2.2, < 4.0)
207
- regexp_parser (>= 1.8, < 3.0)
208
- rexml (>= 3.2.5, < 4.0)
209
- rubocop-ast (>= 1.26.0, < 2.0)
210
- ruby-progressbar (~> 1.7)
211
- unicode-display_width (>= 2.4.0, < 3.0)
212
- rubocop-ast (1.28.0)
213
- parser (>= 3.2.1.0)
214
- rubocop-capybara (2.17.1)
215
- rubocop (~> 1.41)
216
- rubocop-rspec (2.19.0)
217
- rubocop (~> 1.33)
218
- rubocop-capybara (~> 2.17)
219
- ruby-progressbar (1.13.0)
220
- ruby-vips (2.1.4)
221
- ffi (~> 1.12)
222
- russian_phone (0.7.0)
223
- safe_yaml (1.0.5)
224
- sanitize (6.0.1)
225
- crass (~> 1.0.2)
226
- nokogiri (>= 1.12.0)
227
- shrine (3.4.0)
228
- content_disposition (~> 1.0)
229
- down (~> 5.1)
230
- shrine-mongoid (1.0.0)
231
- mongoid (>= 5.0)
232
- shrine (>= 3.0.0.beta3, < 4)
233
- simplecov (0.22.0)
234
- docile (~> 1.1)
235
- simplecov-html (~> 0.11)
236
- simplecov_json_formatter (~> 0.1)
237
- simplecov-html (0.12.3)
238
- simplecov_json_formatter (0.1.4)
239
- sprockets (4.2.0)
240
- concurrent-ruby (~> 1.0)
241
- rack (>= 2.2.4, < 4)
242
- sprockets-rails (3.4.2)
243
- actionpack (>= 5.2)
244
- activesupport (>= 5.2)
245
- sprockets (>= 3.0.0)
246
- ssrf_filter (1.1.1)
247
- terrapin (0.6.0)
248
- climate_control (>= 0.0.3, < 1.0)
249
- thor (1.2.1)
250
- thread_safe (0.3.6)
251
- timeout (0.3.2)
252
- tzinfo (1.2.11)
253
- thread_safe (~> 0.1)
254
- unicode-display_width (2.4.2)
255
- validates_email_format_of (1.7.2)
256
- i18n
257
- websocket-driver (0.7.5)
258
- websocket-extensions (>= 0.1.0)
259
- websocket-extensions (0.1.5)
260
-
261
- PLATFORMS
262
- ruby
263
-
264
- DEPENDENCIES
265
- addressable
266
- bundler
267
- carrierwave-mongoid
268
- database_cleaner
269
- factory_bot
270
- geocoder
271
- image_processing
272
- mini_magick
273
- mongoid (~> 6.3)
274
- mongoid-paperclip
275
- mongoid-rspec
276
- rails
277
- rake
278
- rspec
279
- rubocop-rspec
280
- russian_phone
281
- safe_yaml
282
- sanitize
283
- shrine (~> 3.0)
284
- shrine-mongoid (~> 1.0)
285
- simplecov
286
- thecore_settings!
287
- validates_email_format_of
288
-
289
- BUNDLED WITH
290
- 2.1.4
data/LICENSE.txt DELETED
@@ -1,22 +0,0 @@
1
- Copyright (c) 2013 Gleb Tv
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc DELETED
@@ -1,68 +0,0 @@
1
- === Rails Admin
2
-
3
- Since 1.4.7, it is the user's responsibility to create assets/javascripts/rails_admin/custom/ui.js and include rich
4
-
5
- //= require rich/base
6
-
7
- To use Rich in your RA forms, use the following in your initializer:
8
-
9
- config.model Post do
10
- edit do
11
- field :title
12
- field :body, :rich_editor do
13
- config({
14
- :insert_many => true
15
- })
16
- end
17
- end
18
- end
19
-
20
- To use the image picker on a string field, do this:
21
-
22
- field :title, :rich_picker do
23
- config({
24
- :allowed_styles => [:original],
25
- :view_mode => "list"
26
- })
27
- end
28
-
29
- == Rich in production mode
30
-
31
- Rich works just fine in production mode. To accommodate the structure of the CKEditor source, Rich extends the <tt>assets:precompile</tt> task to make sure the full CKEditor source tree is copied to your assets folder. So the following works as you would expect:
32
-
33
- rake assets:precompile
34
-
35
- Rich will also clean up these CKEditor files when you clean your assets. Like this:
36
-
37
- rake assets:clean
38
-
39
- Although generally not necessary, the underlying Rich tasks can be invoked directly.
40
-
41
- rake rich:assetize_ckeditor
42
- rake rich:clean_ckeditor
43
-
44
- == Configuration and overrides
45
-
46
- Take a look at the generated <tt>rich.rb</tt> initializer and – if you want to dig deeper – the Rich sourcecode. The initializer guides you through the most important settings and configuration options.
47
-
48
- === Localization
49
-
50
- Localization should be automatic. Rich uses the currently set locale (<tt>I18n.locale</tt>) for it's editor and file browser.
51
-
52
- === CKEditor configuration
53
-
54
- Rich attempts to provide you with a sensible set of buttons and capabilities. But of course, you might disagree. To that end, you can configure CKEditor through the <tt>config</tt> directive, either globally through the initializer, or per editor instance as an option.
55
-
56
- Rich also includes a few settings that manipulate CKEditor settings, but are a bit easier to use. For example, you can set <tt>:allow_embeds</tt> to <tt>true</tt> to load a media embed plugin (think Youtube, Vimeo, etc.)
57
-
58
- === Editor styles
59
-
60
- When you run the generator a css file is created for you in <tt>app/assets/stylesheets/rich/editor.css</tt>. Use this stylesheet to define the contents of the Styles drop down in CKEditor.
61
-
62
- === Image configuration & (re)processing
63
-
64
- The styles you define in the initializer are passed to Paperclip directly, so the syntax is identical. See https://github.com/thoughtbot/paperclip/wiki/Thumbnail-Generation for more information. You can also set additional processing options using <tt>convert_options</tt>. See your Rich initializer for more information.
65
-
66
- When you change styles after uploading files, you will need to re-process those old files. To accomplish this, run the following command (avoid the standard Paperclip task!).
67
-
68
- rake rich:refresh_assets
data/app/models/.keep DELETED
File without changes
data/app/views/.keep DELETED
File without changes
@@ -1,41 +0,0 @@
1
- - if ['string', 'integer', 'float', 'phone', 'email', 'address', 'url', 'domain'].include?(@object.type)
2
- = form.text_field :raw, :value => field.value
3
- - if @object.type == 'boolean'
4
- = form.check_box :raw, {:value => field.value}, 'true', 'false'
5
- - if @object.type == 'color'
6
- = form.text_field :raw, :value => field.value, 'data-color' => true, style: "background-color: ##{field.value}"
7
- - elsif %w(text simple_format simple_format_raw strip_tags yaml json phones).include?( @object.type )
8
- = form.text_area :raw, :value => field.value, :rows => 10, :cols => 80
9
- - elsif @object.type == 'code' || @object.type == 'sanitize_code'
10
- :ruby
11
- js_data = {
12
- csspath: asset_path('ckeditor/plugins/codemirror/css/codemirror.min.css'),
13
- jspath: asset_path('ckeditor/plugins/codemirror/js/codemirror.min.js'),
14
- options: {
15
- mode: 'htmlmixed',
16
- theme: 'monokai',
17
- lineNumbers: true
18
- },
19
- locations: {
20
- mode: asset_path('ckeditor/plugins/codemirror/js/codemirror.mode.htmlmixed.min.js'),
21
- theme: asset_path('ckeditor/plugins/codemirror/theme/monokai.css')
22
- }
23
- }
24
-
25
- = form.text_area field.method_name, field.html_attributes.reverse_merge(data: { richtext: 'codemirror', options: js_data.to_json }).reverse_merge({ value: field.form_value })
26
- - elsif @object.type == 'html' || @object.type == 'sanitized' || @object.type == 'sanitize'
27
- - if form.respond_to?(:cktext_area)
28
- = javascript_include_tag "ckeditor/init"
29
- = form.cktext_area :raw, :value => field.value, :rows => 10, :cols => 80
30
- - elsif Object.const_defined?('Rich')
31
- = form.text_area :raw, :value => field.value, :rows => 10, :cols => 80
32
-
33
- = javascript_include_tag "rich/base.js"
34
- :javascript
35
- var instance = CKEDITOR.instances['#{form.dom_id(field)}'];
36
- if(instance) { CKEDITOR.remove(instance); }
37
- CKEDITOR.replace('#{form.dom_id(field)}', #{Rich.options().to_json.html_safe});
38
- - else
39
- .alert.alert-error
40
- = t('admin.settings.no_ckeditor_detected')
41
- = form.text_area :raw, :value => field.value, :rows => 10, :cols => 80
data/bin/rails DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # This command will automatically be run when you run "rails" with Rails gems
3
- # installed from the root of your application.
4
-
5
- ENGINE_ROOT = File.expand_path('..', __dir__)
6
- ENGINE_PATH = File.expand_path('../lib/thecore_settings/engine', __dir__)
7
- APP_PATH = File.expand_path('../test/dummy/config/application', __dir__)
8
-
9
- # Set up gems listed in the Gemfile.
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
11
- require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
12
-
13
- require "rails/all"
14
- require "rails/engine/commands"
@@ -1,5 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gem "mongoid", "~> 6.0.0"
4
-
5
- gemspec path: "../"
@@ -1,5 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gem "mongoid", "~> 6.3.0"
4
-
5
- gemspec path: "../"
@@ -1,11 +0,0 @@
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
@@ -1,41 +0,0 @@
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
-
@@ -1,48 +0,0 @@
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
@@ -1,87 +0,0 @@
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
@@ -1,29 +0,0 @@
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
@@ -1,8 +0,0 @@
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