thecore_settings 1.1.15 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.devcontainer/Dockerfile +20 -0
- data/.devcontainer/devcontainer.json +33 -0
- data/.github/workflows/gempush.yml +34 -0
- data/.gitignore +542 -0
- data/.rakeTasks +7 -0
- data/.rspec +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +31 -0
- data/CHANGELOG.md +81 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +275 -0
- data/LICENSE.txt +22 -0
- data/README.md +169 -0
- data/README.rdoc +68 -0
- data/Rakefile +6 -34
- data/app/assets/images/thecore_settings/.keep +0 -0
- data/app/assets/javascripts/thecore_settings/.keep +0 -0
- data/app/assets/stylesheets/thecore_settings/.keep +0 -0
- data/app/controllers/.keep +0 -0
- data/app/helpers/.keep +0 -0
- data/app/mailers/.keep +0 -0
- data/app/models/.keep +0 -0
- data/app/models/rails_admin_settings/setting.rb +77 -0
- data/app/views/.keep +0 -0
- data/app/views/rails_admin/main/_setting_value.html.haml +41 -0
- data/assets/javascripts/rails_admin/custom/thecore_settings.rb +2 -0
- data/bin/rails +13 -0
- data/config/locales/en.yml +29 -0
- data/config/locales/pt-BR.yml +28 -0
- data/config/locales/ru.yml +29 -0
- data/gemfiles/mongoid-6.0.gemfile +5 -0
- data/gemfiles/mongoid-6.3.gemfile +5 -0
- data/lib/generators/rails_admin_settings/migration_generator.rb +15 -0
- data/lib/generators/rails_admin_settings/templates/db/migrate/20161227101954_create_thecore_settings.rb +29 -0
- data/lib/generators/rails_admin_settings/templates/migration.rb +29 -0
- data/lib/thecore_settings/determine_mime_type.rb +193 -0
- data/lib/thecore_settings/dumper.rb +12 -0
- data/lib/thecore_settings/engine.rb +17 -3
- data/lib/thecore_settings/fallback.rb +21 -0
- data/lib/thecore_settings/hex_color_validator.rb +11 -0
- data/lib/thecore_settings/kinds.rb +34 -0
- data/lib/thecore_settings/mongoid.rb +19 -0
- data/lib/thecore_settings/namespaced.rb +210 -0
- data/lib/thecore_settings/processing.rb +217 -0
- data/lib/thecore_settings/rails_admin_config.rb +71 -0
- data/lib/thecore_settings/require_helpers.rb +86 -0
- data/lib/thecore_settings/settings.rb +95 -0
- data/lib/thecore_settings/storage/carrier_wave_uploader.rb +9 -0
- data/lib/thecore_settings/storage/shrine_uploader.rb +14 -0
- data/lib/thecore_settings/tasks.rb +35 -0
- data/lib/thecore_settings/uploads.rb +57 -0
- data/lib/thecore_settings/validation.rb +126 -0
- data/lib/thecore_settings/version.rb +1 -1
- data/lib/thecore_settings.rb +115 -123
- data/log/development.log +0 -0
- data/spec/advanced_usage_spec.rb +11 -0
- data/spec/carrierwave_spec.rb +41 -0
- data/spec/database_trickery_spec.rb +48 -0
- data/spec/defaults_spec.rb +87 -0
- data/spec/enabling_spec.rb +29 -0
- data/spec/factories/setting.rb +8 -0
- data/spec/label_spec.rb +16 -0
- data/spec/migration_spec.rb +20 -0
- data/spec/model_spec.rb +105 -0
- data/spec/namespaced_spec.rb +67 -0
- data/spec/paperclip_spec.rb +38 -0
- data/spec/settings_spec.rb +75 -0
- data/spec/shrine_spec.rb +34 -0
- data/spec/spec_helper.rb +85 -0
- data/spec/support/1024x768.gif +0 -0
- data/spec/support/database_cleaner.rb +10 -0
- data/spec/support/defaults.yml +23 -0
- data/spec/support/defaults_w_file.yml +19 -0
- data/spec/support/mongoid.rb +6 -0
- data/spec/support/mongoid.yml +6 -0
- data/spec/types_spec.rb +101 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/config/manifest.js +4 -0
- data/test/dummy/app/assets/images/.keep +0 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/javascripts/cable.js +13 -0
- data/test/dummy/app/assets/javascripts/channels/.keep +0 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/channels/application_cable/channel.rb +4 -0
- data/test/dummy/app/channels/application_cable/connection.rb +4 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/controllers/concerns/.keep +0 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/jobs/application_job.rb +2 -0
- data/test/dummy/app/mailers/application_mailer.rb +4 -0
- data/test/dummy/app/models/application_record.rb +3 -0
- data/test/dummy/app/models/concerns/.keep +0 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +34 -0
- data/test/dummy/bin/update +29 -0
- data/test/dummy/config/application.rb +15 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/cable.yml +9 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +54 -0
- data/test/dummy/config/environments/production.rb +86 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/new_framework_defaults.rb +24 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/puma.rb +47 -0
- data/test/dummy/config/routes.rb +3 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/config/spring.rb +6 -0
- data/test/dummy/config.ru +5 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/lib/assets/.keep +0 -0
- data/test/dummy/log/.keep +0 -0
- data/test/dummy/log/development.log +16 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/test/dummy/public/apple-touch-icon.png +0 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/tmp/.keep +0 -0
- data/test/integration/navigation_test.rb +8 -0
- data/test/test_helper.rb +19 -0
- data/test/thecore_settings_test.rb +7 -0
- data/thecore_settings.gemspec +44 -0
- metadata +457 -54
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
|
4
|
+
describe "Uploads" do
|
5
|
+
if Settings.file_uploads_engine != :paperclip
|
6
|
+
pending "paperclip not detected, skipped. To run use UPLOADS=paperclip rspec"
|
7
|
+
else
|
8
|
+
Paperclip.options[:log] = false
|
9
|
+
before :each do
|
10
|
+
f = "#{File.dirname(__FILE__)}/../uploads/1024x768.gif"
|
11
|
+
if File.file?(f)
|
12
|
+
File.unlink(f)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
it 'supports file kind' do
|
16
|
+
Settings.set('file', File.open("#{File.dirname(__FILE__)}/support/1024x768.gif"), kind: 'file')
|
17
|
+
expect(Settings.get(:file).file_file_name).to eq '1024x768.gif'
|
18
|
+
expect(Settings.get(:file).file_file_size).to eq 4357
|
19
|
+
expect(Settings.file[0..21]).to eq '/uploads/1024x768.gif?'
|
20
|
+
expect(File.exists?("#{File.dirname(__FILE__)}/../uploads/1024x768.gif")).to be_truthy
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'supports image kind' do
|
24
|
+
Settings.set('file', File.open("#{File.dirname(__FILE__)}/support/1024x768.gif"), kind: 'image')
|
25
|
+
expect(Settings.get(:file).file_file_name).to eq '1024x768.gif'
|
26
|
+
expect(Settings.get(:file).file_file_size).to eq 4357
|
27
|
+
expect(Settings.file[0..21]).to eq '/uploads/1024x768.gif?'
|
28
|
+
|
29
|
+
expect(File.exists?("#{File.dirname(__FILE__)}/../uploads/1024x768.gif")).to be_truthy
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'supports defaults' do
|
33
|
+
Settings.apply_defaults!(File.join(File.dirname(__FILE__), 'support/defaults_w_file.yml'))
|
34
|
+
expect(File.exists?(Settings.root_file_path.join("uploads/1024x768.gif"))).to be_truthy
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe 'Settings' do
|
6
|
+
it "should works as RailsSettings" do
|
7
|
+
Settings.destroy_all!
|
8
|
+
|
9
|
+
email = "my@mail.ru"
|
10
|
+
Settings.email = email
|
11
|
+
expect(Settings.email).to eq(email)
|
12
|
+
end
|
13
|
+
|
14
|
+
it '#get should return new setting when setting does not exist' do
|
15
|
+
t = Settings.get(:test)
|
16
|
+
expect(t.class.name).to eq 'ThecoreSettings::Setting'
|
17
|
+
expect(t.persisted?).to eq true
|
18
|
+
expect(t.value).to eq ''
|
19
|
+
end
|
20
|
+
|
21
|
+
it '#name should return empty string when setting does not exist' do
|
22
|
+
expect(Settings.test).to eq ''
|
23
|
+
expect(Settings['test'].value).to eq ''
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should save default" do
|
27
|
+
Settings.destroy_all!
|
28
|
+
|
29
|
+
email = "my@mail.ru"
|
30
|
+
email2 = "my2@mail.ru"
|
31
|
+
Settings.save_default(:email, email)
|
32
|
+
expect(Settings.email).to eq(email)
|
33
|
+
Settings.email = email2
|
34
|
+
expect(Settings.email).to eq(email2)
|
35
|
+
Settings.save_default(:email, email)
|
36
|
+
expect(Settings.email).to eq(email2)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should properly unload' do
|
40
|
+
Settings.load!
|
41
|
+
expect(Settings.loaded).to eq true
|
42
|
+
Settings.unload!
|
43
|
+
expect(Settings.loaded).to eq false
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should work with kind and default' do
|
47
|
+
expect(Settings.phone(kind: 'phone', default: '906 111 11 11')).to eq '+7 (906) 111-11-11'
|
48
|
+
Settings.phone = '906 222 22 22'
|
49
|
+
expect(Settings.phone(kind: 'phone', default: '906 111 11 11')).to eq '+7 (906) 222-22-22'
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should properly store settings to DB' do
|
53
|
+
Settings.unload!
|
54
|
+
expect(Settings.loaded).to eq false
|
55
|
+
Settings.temp = '123'
|
56
|
+
expect(Settings.loaded).to eq true
|
57
|
+
Settings.unload!
|
58
|
+
expect(Settings.loaded).to eq false
|
59
|
+
expect(Settings.temp).to eq '123'
|
60
|
+
expect(Settings.loaded).to eq true
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should support yaml kind' do
|
64
|
+
Settings.tdata(kind: 'yaml')
|
65
|
+
Settings.tdata = ['one', 'two', 'three']
|
66
|
+
expect(YAML.safe_load(Settings.get(:tdata).raw)).to eq ['one', 'two', 'three']
|
67
|
+
expect(Settings.tdata).to eq ['one', 'two', 'three']
|
68
|
+
end
|
69
|
+
|
70
|
+
it '#enabled? sets defaults' do
|
71
|
+
expect(Settings.enabled?(:phone, kind: 'phone')).to eq true
|
72
|
+
expect(Settings.get(:phone).kind).to eq 'phone'
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
data/spec/shrine_spec.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
|
4
|
+
describe "Uploads" do
|
5
|
+
if Settings.file_uploads_engine != :shrine
|
6
|
+
pending "shrine not detected, skipped. To run use UPLOADS=shrine rspec"
|
7
|
+
else
|
8
|
+
before :each do
|
9
|
+
f = "#{File.dirname(__FILE__)}/../uploads/1024x768.gif"
|
10
|
+
if File.file?(f)
|
11
|
+
File.unlink(f)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
it 'supports file kind' do
|
15
|
+
Settings.set('file', File.open("#{File.dirname(__FILE__)}/support/1024x768.gif"), kind: 'file')
|
16
|
+
expect(Settings.get(:file).file.metadata["filename"]).to eq '1024x768.gif'
|
17
|
+
expect(Settings.get(:file).file.metadata["size"]).to eq 4357
|
18
|
+
expect(Settings.get(:file).file.metadata["mime_type"]).to eq "image/gif"
|
19
|
+
expect(Settings.get(:file).file.id.split(".").last).to eq "gif"
|
20
|
+
expect(Settings.file.split("/").second + "/" + Settings.file.split("/").last.split(".").last).to eq "uploads/gif"
|
21
|
+
expect(File.exists?("public/uploads/#{Settings.get(:file).file.id}")).to be_truthy
|
22
|
+
end
|
23
|
+
it 'supports image kind' do
|
24
|
+
Settings.set('file', File.open("#{File.dirname(__FILE__)}/support/1024x768.gif"), kind: 'image')
|
25
|
+
expect(Settings.get(:file).file.metadata["filename"]).to eq '1024x768.gif'
|
26
|
+
expect(Settings.get(:file).file.metadata["size"]).to eq 4357
|
27
|
+
expect(Settings.get(:file).file.metadata["mime_type"]).to eq "image/gif"
|
28
|
+
expect(Settings.get(:file).file.id.split(".").last).to eq "gif"
|
29
|
+
expect(Settings.file.split("/").second + "/" + Settings.file.split("/").last.split(".").last).to eq "uploads/gif"
|
30
|
+
expect(File.exists?("public/uploads/#{Settings.get(:file).file.id}")).to be_truthy
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
|
5
|
+
require 'simplecov'
|
6
|
+
SimpleCov.start
|
7
|
+
|
8
|
+
require 'bundler/setup'
|
9
|
+
require 'active_support'
|
10
|
+
require 'active_support/core_ext'
|
11
|
+
|
12
|
+
unless ENV['ACTIVERECORD']
|
13
|
+
require 'mongoid'
|
14
|
+
end
|
15
|
+
|
16
|
+
require 'database_cleaner'
|
17
|
+
require 'factory_bot'
|
18
|
+
require 'mongoid-rspec'
|
19
|
+
|
20
|
+
if ENV['UPLOADS'] == 'paperclip'
|
21
|
+
require "mongoid-paperclip"
|
22
|
+
end
|
23
|
+
if ENV['UPLOADS'] == 'carrierwave'
|
24
|
+
require "carrierwave/mongoid"
|
25
|
+
CarrierWave.configure do |config|
|
26
|
+
config.asset_host = proc do |file|
|
27
|
+
"http://localhost"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
if ENV['UPLOADS'] == 'shrine'
|
32
|
+
require "shrine"
|
33
|
+
require "shrine/storage/file_system"
|
34
|
+
Shrine.storages = {
|
35
|
+
cache: Shrine::Storage::FileSystem.new("public", prefix: "uploads/cache"), # temporary
|
36
|
+
store: Shrine::Storage::FileSystem.new("public", prefix: "uploads"), # permanent
|
37
|
+
}
|
38
|
+
|
39
|
+
if ENV['ACTIVERECORD']
|
40
|
+
Shrine.plugin :activerecord
|
41
|
+
end
|
42
|
+
Shrine.plugin :cached_attachment_data # for retaining the cached file across form redisplays
|
43
|
+
Shrine.plugin :restore_cached_data # re-extract metadata when attaching a cached file
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
I18n.enforce_available_locales = true
|
49
|
+
I18n.load_path << File.join(File.dirname(__FILE__), "..", "config", "locales", "en.yml")
|
50
|
+
|
51
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each do |f|
|
52
|
+
require f
|
53
|
+
end
|
54
|
+
|
55
|
+
if ENV['RAILS'] == '1'
|
56
|
+
require "active_model/railtie"
|
57
|
+
require "action_controller/railtie"
|
58
|
+
require "action_view/railtie"
|
59
|
+
module RAS
|
60
|
+
class Application < Rails::Application
|
61
|
+
end
|
62
|
+
end
|
63
|
+
# Initialize the Rails application.
|
64
|
+
Rails.application.initialize!
|
65
|
+
end
|
66
|
+
|
67
|
+
require 'thecore_settings'
|
68
|
+
|
69
|
+
|
70
|
+
if ENV['UPLOADS'] == 'paperclip'
|
71
|
+
module ThecoreSettings::Uploads
|
72
|
+
def self.paperclip_options
|
73
|
+
{path: "#{File.dirname(__FILE__)}/../uploads/:filename", url: '/uploads/:filename'}
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
Dir["#{File.dirname(__FILE__)}/factories/**/*.rb"].each do |f|
|
80
|
+
require f
|
81
|
+
end
|
82
|
+
|
83
|
+
#RSpec.configure do |config|
|
84
|
+
#config.expect_with(:rspec) { |c| c.syntax = :should }
|
85
|
+
#end
|
Binary file
|
@@ -0,0 +1,23 @@
|
|
1
|
+
main:
|
2
|
+
footer:
|
3
|
+
kind: html
|
4
|
+
value: 'test <b></b>'
|
5
|
+
|
6
|
+
phone:
|
7
|
+
kind: 'phone'
|
8
|
+
value: '906 1111111'
|
9
|
+
|
10
|
+
true_setting:
|
11
|
+
kind: 'boolean'
|
12
|
+
value: true
|
13
|
+
|
14
|
+
false_setting:
|
15
|
+
kind: 'boolean'
|
16
|
+
value: false
|
17
|
+
|
18
|
+
disabled:
|
19
|
+
enabled: false
|
20
|
+
|
21
|
+
other:
|
22
|
+
footer:
|
23
|
+
value: 'zzz'
|
data/spec/types_spec.rb
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe 'Settings kind' do
|
6
|
+
it 'boolean' do
|
7
|
+
expect(Settings.get(:testbool, kind: 'boolean').value).to be(false)
|
8
|
+
expect(Settings.get(:testbool, default: true, kind: 'boolean').value).to be(false)
|
9
|
+
expect(Settings.get(:testbool2, default: true, kind: 'boolean').value).to be(true)
|
10
|
+
expect(Settings.testbool2).to be(true)
|
11
|
+
Settings.set(:testbool3, true, kind: 'boolean')
|
12
|
+
expect(Settings.testbool3).to be(true)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'html' do
|
16
|
+
expect(Settings.get(:email, kind: 'html', default: 'test@example.com').to_s).to eq 'test@example.com'
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'integer' do
|
20
|
+
expect(Settings.get(:testint, kind: 'integer').value).to eq 0
|
21
|
+
expect(Settings.get(:testint, default: 5, kind: 'integer').value).to eq 0
|
22
|
+
expect(Settings.get(:testint2, default: 5, kind: 'integer').value).to eq 5
|
23
|
+
expect(Settings.testint2).to eq 5
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'float' do
|
27
|
+
expect(Settings.get(:testfloat, kind: 'float').value).to eq 0
|
28
|
+
expect(Settings.get(:testfloat, default: 5.2, kind: 'float').value).to eq 0
|
29
|
+
expect(Settings.get(:testfloat2, default: 5.5, kind: 'float').value).to eq 5.5
|
30
|
+
expect(Settings.testfloat2).to eq 5.5
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'does yaml' do
|
34
|
+
Settings.set(:data, '[one, two, three]', kind: 'yaml')
|
35
|
+
expect(Settings.get(:data).raw).to eq '[one, two, three]'
|
36
|
+
expect(Settings.data).to eq ['one', 'two', 'three']
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'does json' do
|
40
|
+
Settings.set(:data, '{"a": 1, "b": 2}', kind: 'json')
|
41
|
+
expect(Settings.get(:data).raw).to eq '{"a": 1, "b": 2}'
|
42
|
+
expect(Settings.data).to eq({"a" => 1, "b" => 2})
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'phone' do
|
46
|
+
Settings.set(:tphone, '906 111 11 11', kind: 'phone')
|
47
|
+
expect(Settings.get(:tphone).val.class.name).to eq 'RussianPhone::Number'
|
48
|
+
expect(Settings.tphone.class.name).to eq 'RussianPhone::Number'
|
49
|
+
expect(Settings.tphone).to eq '906 111 11 11'
|
50
|
+
expect(Settings.get(:tphone).phone_kind?).to be_truthy
|
51
|
+
expect(Settings.get(:tphone).val.city).to eq '906'
|
52
|
+
expect(Settings.get(:tphone).val.formatted_subscriber).to eq '111-11-11'
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'supports phones kind' do
|
56
|
+
Settings.set(:tphone, ['906 111 11 11', '907 111 11 11'] * "\n", kind: 'phones')
|
57
|
+
expect(Settings.get(:tphone).val.class.name).to eq 'Array'
|
58
|
+
expect(Settings.tphone.class.name).to eq 'Array'
|
59
|
+
expect(Settings.get(:tphone).val.first.class.name).to eq 'RussianPhone::Number'
|
60
|
+
expect(Settings.tphone.first.class.name).to eq 'RussianPhone::Number'
|
61
|
+
expect(Settings.tphone.first).to eq '906 111 11 11'
|
62
|
+
expect(Settings.get(:tphone).phones_kind?).to be_truthy
|
63
|
+
expect(Settings.get(:tphone).val.first.city).to eq '906'
|
64
|
+
expect(Settings.get(:tphone).val.last.city).to eq '907'
|
65
|
+
expect(Settings.get(:tphone).val.first.formatted_subscriber).to eq '111-11-11'
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'defaults for phone' do
|
69
|
+
Settings.dphone(kind: 'phone')
|
70
|
+
expect(Settings.get(:dphone).phone_kind?).to be_truthy
|
71
|
+
expect(Settings.dphone.formatted_area).to eq ''
|
72
|
+
expect(Settings.dphone.formatted_subscriber).to eq ''
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'email validates' do
|
76
|
+
Settings.eml(kind: 'email')
|
77
|
+
expect(Settings.get(:eml).email_kind?).to be_truthy
|
78
|
+
expect { Settings.eml = '1' }.to raise_error
|
79
|
+
Settings.eml = 'test@example.com'
|
80
|
+
expect(Settings.eml).to eq 'test@example.com'
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'url processing' do
|
84
|
+
Settings.url(kind: 'url')
|
85
|
+
expect(Settings.get(:url).url_kind?).to be_truthy
|
86
|
+
expect(Settings.get(:url).color_kind?).to be_falsey
|
87
|
+
Settings.url = 'test.ru'
|
88
|
+
expect(Settings.url).to eq 'http://test.ru'
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'color' do
|
92
|
+
Settings.col(kind: 'color')
|
93
|
+
expect(Settings.get(:col).color_kind?).to be_truthy
|
94
|
+
expect { Settings.col = 'test'}.to raise_error
|
95
|
+
Settings.col = 'ffffff'
|
96
|
+
expect(Settings.col).to eq 'ffffff'
|
97
|
+
expect {
|
98
|
+
Settings.col = 'zzzzzz'
|
99
|
+
}.to raise_error
|
100
|
+
end
|
101
|
+
end
|
data/test/dummy/Rakefile
ADDED
File without changes
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|