thecore_settings 2.0.7 → 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 (48) 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 -1
  5. metadata +24 -213
  6. data/.devcontainer/Dockerfile +0 -20
  7. data/.devcontainer/devcontainer.json +0 -33
  8. data/.github/workflows/gempush.yml +0 -34
  9. data/.gitignore +0 -542
  10. data/.rakeTasks +0 -7
  11. data/.rspec +0 -1
  12. data/.ruby-version +0 -1
  13. data/.travis.yml +0 -31
  14. data/CHANGELOG.md +0 -81
  15. data/Gemfile +0 -4
  16. data/Gemfile.lock +0 -274
  17. data/LICENSE.txt +0 -22
  18. data/README.rdoc +0 -68
  19. data/app/models/.keep +0 -0
  20. data/app/views/.keep +0 -0
  21. data/app/views/rails_admin/main/_setting_value.html.haml +0 -41
  22. data/bin/rails +0 -13
  23. data/gemfiles/mongoid-6.0.gemfile +0 -5
  24. data/gemfiles/mongoid-6.3.gemfile +0 -5
  25. data/lib/generators/thecore_settings/migration_generator.rb +0 -15
  26. data/lib/generators/thecore_settings/templates/migration.rb +0 -29
  27. data/spec/advanced_usage_spec.rb +0 -11
  28. data/spec/carrierwave_spec.rb +0 -41
  29. data/spec/database_trickery_spec.rb +0 -48
  30. data/spec/defaults_spec.rb +0 -87
  31. data/spec/enabling_spec.rb +0 -29
  32. data/spec/factories/setting.rb +0 -8
  33. data/spec/label_spec.rb +0 -16
  34. data/spec/migration_spec.rb +0 -20
  35. data/spec/model_spec.rb +0 -105
  36. data/spec/namespaced_spec.rb +0 -67
  37. data/spec/paperclip_spec.rb +0 -38
  38. data/spec/settings_spec.rb +0 -75
  39. data/spec/shrine_spec.rb +0 -34
  40. data/spec/spec_helper.rb +0 -85
  41. data/spec/support/1024x768.gif +0 -0
  42. data/spec/support/database_cleaner.rb +0 -10
  43. data/spec/support/defaults.yml +0 -23
  44. data/spec/support/defaults_w_file.yml +0 -19
  45. data/spec/support/mongoid.rb +0 -6
  46. data/spec/support/mongoid.yml +0 -6
  47. data/spec/types_spec.rb +0 -101
  48. data/thecore_settings.gemspec +0 -44
data/Gemfile.lock DELETED
@@ -1,274 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- thecore_settings (2.0.6)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- actioncable (5.2.6)
10
- actionpack (= 5.2.6)
11
- nio4r (~> 2.0)
12
- websocket-driver (>= 0.6.1)
13
- actionmailer (5.2.6)
14
- actionpack (= 5.2.6)
15
- actionview (= 5.2.6)
16
- activejob (= 5.2.6)
17
- mail (~> 2.5, >= 2.5.4)
18
- rails-dom-testing (~> 2.0)
19
- actionpack (5.2.6)
20
- actionview (= 5.2.6)
21
- activesupport (= 5.2.6)
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.6)
27
- activesupport (= 5.2.6)
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.6)
33
- activesupport (= 5.2.6)
34
- globalid (>= 0.3.6)
35
- activemodel (5.2.6)
36
- activesupport (= 5.2.6)
37
- activerecord (5.2.6)
38
- activemodel (= 5.2.6)
39
- activesupport (= 5.2.6)
40
- arel (>= 9.0)
41
- activestorage (5.2.6)
42
- actionpack (= 5.2.6)
43
- activerecord (= 5.2.6)
44
- marcel (~> 1.0.0)
45
- activesupport (5.2.6)
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.0)
51
- public_suffix (>= 2.0.2, < 5.0)
52
- arel (9.0.0)
53
- ast (2.4.2)
54
- bson (4.12.1)
55
- builder (3.2.4)
56
- carrierwave (2.2.2)
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.3.0)
65
- carrierwave (>= 0.8, < 3)
66
- mongoid (>= 3.0, < 8.0)
67
- mongoid-grid_fs (>= 1.3, < 3.0)
68
- climate_control (0.2.0)
69
- concurrent-ruby (1.1.9)
70
- content_disposition (1.0.0)
71
- crass (1.0.6)
72
- database_cleaner (2.0.1)
73
- database_cleaner-active_record (~> 2.0.0)
74
- database_cleaner-active_record (2.0.1)
75
- activerecord (>= 5.a)
76
- database_cleaner-core (~> 2.0.0)
77
- database_cleaner-core (2.0.1)
78
- diff-lcs (1.4.4)
79
- docile (1.4.0)
80
- down (5.2.4)
81
- addressable (~> 2.8)
82
- erubi (1.10.0)
83
- factory_bot (6.2.0)
84
- activesupport (>= 5.0.0)
85
- ffi (1.15.4)
86
- geocoder (1.6.7)
87
- globalid (0.5.2)
88
- activesupport (>= 5.0)
89
- i18n (1.8.10)
90
- concurrent-ruby (~> 1.0)
91
- image_processing (1.12.1)
92
- mini_magick (>= 4.9.5, < 5)
93
- ruby-vips (>= 2.0.17, < 3)
94
- loofah (2.12.0)
95
- crass (~> 1.0.2)
96
- nokogiri (>= 1.5.9)
97
- mail (2.7.1)
98
- mini_mime (>= 0.1.1)
99
- marcel (1.0.2)
100
- method_source (1.0.0)
101
- mime-types (3.3.1)
102
- mime-types-data (~> 3.2015)
103
- mime-types-data (3.2021.0901)
104
- mimemagic (0.3.10)
105
- nokogiri (~> 1)
106
- rake
107
- mini_magick (4.11.0)
108
- mini_mime (1.1.1)
109
- mini_portile2 (2.6.1)
110
- minitest (5.14.4)
111
- mongo (2.15.1)
112
- bson (>= 4.8.2, < 5.0.0)
113
- mongoid (6.4.8)
114
- activemodel (>= 5.1, < 6.0.0)
115
- mongo (>= 2.5.1, < 3.0.0)
116
- mongoid-compatibility (0.5.1)
117
- activesupport
118
- mongoid (>= 2.0)
119
- mongoid-grid_fs (2.4.0)
120
- mime-types (>= 1.0, < 4.0)
121
- mongoid (>= 3.0, < 8.0)
122
- mongoid-paperclip (0.0.11)
123
- mongoid
124
- paperclip (>= 2.3.6, != 4.3.0)
125
- mongoid-rspec (4.1.0)
126
- activesupport (>= 3.0.0)
127
- mongoid (>= 3.1)
128
- mongoid-compatibility (>= 0.5.1)
129
- rspec-core (~> 3.3)
130
- rspec-expectations (~> 3.3)
131
- rspec-mocks (~> 3.3)
132
- nio4r (2.5.8)
133
- nokogiri (1.12.5)
134
- mini_portile2 (~> 2.6.1)
135
- racc (~> 1.4)
136
- paperclip (6.1.0)
137
- activemodel (>= 4.2.0)
138
- activesupport (>= 4.2.0)
139
- mime-types
140
- mimemagic (~> 0.3.0)
141
- terrapin (~> 0.6.0)
142
- parallel (1.21.0)
143
- parser (3.0.2.0)
144
- ast (~> 2.4.1)
145
- public_suffix (4.0.6)
146
- racc (1.5.2)
147
- rack (2.2.3)
148
- rack-test (1.1.0)
149
- rack (>= 1.0, < 3)
150
- rails (5.2.6)
151
- actioncable (= 5.2.6)
152
- actionmailer (= 5.2.6)
153
- actionpack (= 5.2.6)
154
- actionview (= 5.2.6)
155
- activejob (= 5.2.6)
156
- activemodel (= 5.2.6)
157
- activerecord (= 5.2.6)
158
- activestorage (= 5.2.6)
159
- activesupport (= 5.2.6)
160
- bundler (>= 1.3.0)
161
- railties (= 5.2.6)
162
- sprockets-rails (>= 2.0.0)
163
- rails-dom-testing (2.0.3)
164
- activesupport (>= 4.2.0)
165
- nokogiri (>= 1.6)
166
- rails-html-sanitizer (1.4.2)
167
- loofah (~> 2.3)
168
- railties (5.2.6)
169
- actionpack (= 5.2.6)
170
- activesupport (= 5.2.6)
171
- method_source
172
- rake (>= 0.8.7)
173
- thor (>= 0.19.0, < 2.0)
174
- rainbow (3.0.0)
175
- rake (13.0.6)
176
- regexp_parser (2.1.1)
177
- rexml (3.2.5)
178
- rspec (3.10.0)
179
- rspec-core (~> 3.10.0)
180
- rspec-expectations (~> 3.10.0)
181
- rspec-mocks (~> 3.10.0)
182
- rspec-core (3.10.1)
183
- rspec-support (~> 3.10.0)
184
- rspec-expectations (3.10.1)
185
- diff-lcs (>= 1.2.0, < 2.0)
186
- rspec-support (~> 3.10.0)
187
- rspec-mocks (3.10.2)
188
- diff-lcs (>= 1.2.0, < 2.0)
189
- rspec-support (~> 3.10.0)
190
- rspec-support (3.10.2)
191
- rubocop (1.21.0)
192
- parallel (~> 1.10)
193
- parser (>= 3.0.0.0)
194
- rainbow (>= 2.2.2, < 4.0)
195
- regexp_parser (>= 1.8, < 3.0)
196
- rexml
197
- rubocop-ast (>= 1.9.1, < 2.0)
198
- ruby-progressbar (~> 1.7)
199
- unicode-display_width (>= 1.4.0, < 3.0)
200
- rubocop-ast (1.12.0)
201
- parser (>= 3.0.1.1)
202
- rubocop-rspec (2.5.0)
203
- rubocop (~> 1.19)
204
- ruby-progressbar (1.11.0)
205
- ruby-vips (2.1.3)
206
- ffi (~> 1.12)
207
- russian_phone (0.7.0)
208
- safe_yaml (1.0.5)
209
- sanitize (6.0.0)
210
- crass (~> 1.0.2)
211
- nokogiri (>= 1.12.0)
212
- shrine (3.4.0)
213
- content_disposition (~> 1.0)
214
- down (~> 5.1)
215
- shrine-mongoid (1.0.0)
216
- mongoid (>= 5.0)
217
- shrine (>= 3.0.0.beta3, < 4)
218
- simplecov (0.21.2)
219
- docile (~> 1.1)
220
- simplecov-html (~> 0.11)
221
- simplecov_json_formatter (~> 0.1)
222
- simplecov-html (0.12.3)
223
- simplecov_json_formatter (0.1.3)
224
- sprockets (4.0.2)
225
- concurrent-ruby (~> 1.0)
226
- rack (> 1, < 3)
227
- sprockets-rails (3.2.2)
228
- actionpack (>= 4.0)
229
- activesupport (>= 4.0)
230
- sprockets (>= 3.0.0)
231
- ssrf_filter (1.0.7)
232
- terrapin (0.6.0)
233
- climate_control (>= 0.0.3, < 1.0)
234
- thor (1.1.0)
235
- thread_safe (0.3.6)
236
- tzinfo (1.2.9)
237
- thread_safe (~> 0.1)
238
- unicode-display_width (2.1.0)
239
- validates_email_format_of (1.6.3)
240
- i18n
241
- websocket-driver (0.7.5)
242
- websocket-extensions (>= 0.1.0)
243
- websocket-extensions (0.1.5)
244
-
245
- PLATFORMS
246
- ruby
247
-
248
- DEPENDENCIES
249
- addressable
250
- bundler
251
- carrierwave-mongoid
252
- database_cleaner
253
- factory_bot
254
- geocoder
255
- image_processing
256
- mini_magick
257
- mongoid (~> 6.3)
258
- mongoid-paperclip
259
- mongoid-rspec
260
- rails
261
- rake
262
- rspec
263
- rubocop-rspec
264
- russian_phone
265
- safe_yaml
266
- sanitize
267
- shrine (~> 3.0)
268
- shrine-mongoid (~> 1.0)
269
- simplecov
270
- thecore_settings!
271
- validates_email_format_of
272
-
273
- BUNDLED WITH
274
- 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,13 +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('../..', __FILE__)
6
- ENGINE_PATH = File.expand_path('../../lib/thecore_settings/engine', __FILE__)
7
-
8
- # Set up gems listed in the Gemfile.
9
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
10
- require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
11
-
12
- require 'rails/all'
13
- 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,15 +0,0 @@
1
- require 'rails/generators'
2
- require 'rails/generators/active_record'
3
-
4
- module ThecoreSettings
5
- class MigrationGenerator < Rails::Generators::Base
6
- include ActiveRecord::Generators::Migration
7
- source_root File.expand_path('../templates', __FILE__)
8
-
9
- desc 'RocketCMS migration generator'
10
- def install
11
- migration_template "migration.rb", "db/migrate/create_thecore_settings.rb"
12
- end
13
- end
14
- end
15
-
@@ -1,29 +0,0 @@
1
- class CreateThecoreSettings < ActiveRecord::Migration[5.0]
2
- def change
3
- create_table :thecore_settings do |t|
4
- t.boolean :enabled, default: true
5
- t.string :kind, null: false, default: 'string'
6
- t.string :ns, default: 'main'
7
- t.string :key, null: false
8
- if Object.const_defined?('Geocoder')
9
- t.float :latitude
10
- t.float :longitude
11
- end
12
- t.text :raw
13
- t.string :label
14
- if defined?(Paperclip)
15
- t.attachment :file
16
- elsif defined?(CarrierWave)
17
- t.string :file
18
- elsif defined?(Shrine)
19
- t.text :file_data
20
-
21
- end
22
- t.timestamps
23
- end
24
-
25
- add_index :thecore_settings, :key
26
- add_index :thecore_settings, [:ns, :key], unique: true
27
- end
28
- end
29
-
@@ -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