tuning 0.3.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/README.md +80 -17
- data/Rakefile +3 -0
- data/lib/tuning.rb +7 -2
- data/lib/tuning/extensions/action_controller/base.rb +45 -0
- data/lib/tuning/extensions/action_mailer/base.rb +22 -0
- data/lib/tuning/extensions/action_view/base.rb +31 -0
- data/lib/tuning/extensions/active_record/base.rb +25 -0
- data/lib/tuning/locales/en.yml +12 -0
- data/lib/tuning/locales/es.yml +12 -0
- data/lib/tuning/railtie.rb +17 -3
- data/lib/tuning/validations/complexity.rb +22 -0
- data/lib/tuning/validations/count.rb +42 -0
- data/lib/tuning/validations/time.rb +38 -0
- data/lib/tuning/version.rb +1 -1
- data/test/controllers_test.rb +21 -0
- data/test/dummy/Rakefile +1 -2
- data/test/dummy/app/assets/javascripts/application.js +2 -2
- data/test/dummy/app/assets/stylesheets/application.css +6 -4
- data/test/dummy/app/mailers/user_mailer.rb +7 -0
- data/test/dummy/app/models/shop.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +0 -12
- data/test/dummy/app/views/layouts/market.html.erb +3 -0
- data/test/dummy/app/views/user_mailer/invite.text.erb +7 -0
- data/test/dummy/bin/bundle +0 -0
- data/test/dummy/bin/rails +1 -1
- data/test/dummy/bin/rake +0 -0
- data/test/dummy/bin/setup +29 -0
- data/test/dummy/config.ru +1 -1
- data/test/dummy/config/application.rb +3 -1
- data/test/dummy/config/boot.rb +1 -1
- data/test/dummy/config/database.yml +4 -22
- data/test/dummy/config/database.yml.travis +12 -0
- data/test/dummy/config/environment.rb +1 -1
- data/test/dummy/config/environments/development.rb +14 -2
- data/test/dummy/config/environments/production.rb +20 -25
- data/test/dummy/config/environments/test.rb +8 -10
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/mime_types.rb +1 -2
- data/test/dummy/config/initializers/session_store.rb +1 -1
- data/test/dummy/config/locales/en.yml +22 -9
- data/test/dummy/config/routes.rb +2 -7
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/db/migrate/20161020200126_create_shops.rb +9 -0
- data/test/dummy/db/migrate/20161022144717_create_records.rb +6 -0
- data/test/dummy/db/schema.rb +15 -1
- data/test/dummy/log/test.log +70 -0
- data/test/dummy/public/404.html +20 -11
- data/test/dummy/public/422.html +20 -11
- data/test/dummy/public/500.html +19 -10
- data/test/helpers_test.rb +39 -0
- data/test/mailers_test.rb +10 -0
- data/test/records_test.rb +16 -0
- data/test/test_helper.rb +5 -18
- data/test/validations_test.rb +192 -0
- metadata +66 -47
- data/lib/tuning/action_controller/base.rb +0 -54
- data/lib/tuning/action_view/base.rb +0 -16
- data/test/active_trail_test.rb +0 -33
- data/test/content_tag_if_test.rb +0 -17
- data/test/dummy/README.rdoc +0 -28
- data/test/dummy/app/controllers/status_controller.rb +0 -27
- data/test/dummy/config/initializers/secret_token.rb +0 -13
- data/test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/status_test.rb +0 -55
data/lib/tuning/version.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ControllersTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
test 'render' do
|
6
|
+
controller = ActionController::Base.new
|
7
|
+
controller.expects(:run_callbacks).with(:render)
|
8
|
+
controller.render
|
9
|
+
end
|
10
|
+
|
11
|
+
test 'callbacks' do
|
12
|
+
controller = ActionController::Base
|
13
|
+
%i(before after around).each do |callback|
|
14
|
+
assert controller.respond_to?("#{callback}_render")
|
15
|
+
assert controller.respond_to?("append_#{callback}_render")
|
16
|
+
assert controller.respond_to?("prepend_#{callback}_render")
|
17
|
+
assert controller.respond_to?("skip_#{callback}_render")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
data/test/dummy/Rakefile
CHANGED
@@ -2,12 +2,12 @@
|
|
2
2
|
// listed below.
|
3
3
|
//
|
4
4
|
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
-
// or vendor/assets/javascripts
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
6
|
//
|
7
7
|
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
8
|
// compiled file.
|
9
9
|
//
|
10
|
-
// Read Sprockets README (https://github.com/
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
11
|
// about supported directives.
|
12
12
|
//
|
13
13
|
//= require_tree .
|
@@ -3,11 +3,13 @@
|
|
3
3
|
* listed below.
|
4
4
|
*
|
5
5
|
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
-
* or vendor/assets/stylesheets
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
7
|
*
|
8
|
-
* You're free to add application-wide styles to this file and they'll appear at the
|
9
|
-
* compiled file
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
+
* file per style scope.
|
10
12
|
*
|
11
|
-
*= require_self
|
12
13
|
*= require_tree .
|
14
|
+
*= require_self
|
13
15
|
*/
|
data/test/dummy/bin/bundle
CHANGED
File without changes
|
data/test/dummy/bin/rails
CHANGED
data/test/dummy/bin/rake
CHANGED
File without changes
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
# path to your application root.
|
5
|
+
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
6
|
+
|
7
|
+
Dir.chdir APP_ROOT do
|
8
|
+
# This script is a starting point to setup your application.
|
9
|
+
# Add necessary setup steps to this file:
|
10
|
+
|
11
|
+
puts '== Installing dependencies =='
|
12
|
+
system 'gem install bundler --conservative'
|
13
|
+
system 'bundle check || bundle install'
|
14
|
+
|
15
|
+
# puts "\n== Copying sample files =="
|
16
|
+
# unless File.exist?('config/database.yml')
|
17
|
+
# system 'cp config/database.yml.sample config/database.yml'
|
18
|
+
# end
|
19
|
+
|
20
|
+
puts "\n== Preparing database =="
|
21
|
+
system 'bin/rake db:setup'
|
22
|
+
|
23
|
+
puts "\n== Removing old logs and tempfiles =="
|
24
|
+
system 'rm -f log/*'
|
25
|
+
system 'rm -rf tmp/cache'
|
26
|
+
|
27
|
+
puts "\n== Restarting application server =="
|
28
|
+
system 'touch tmp/restart.txt'
|
29
|
+
end
|
data/test/dummy/config.ru
CHANGED
@@ -18,6 +18,8 @@ module Dummy
|
|
18
18
|
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
19
19
|
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
20
20
|
# config.i18n.default_locale = :de
|
21
|
+
|
22
|
+
# Do not swallow errors in after_commit/after_rollback callbacks.
|
23
|
+
config.active_record.raise_in_transactional_callbacks = true
|
21
24
|
end
|
22
25
|
end
|
23
|
-
|
data/test/dummy/config/boot.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Set up gems listed in the Gemfile.
|
2
2
|
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
|
3
3
|
|
4
|
-
require 'bundler/setup' if File.
|
4
|
+
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
5
5
|
$LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
|
@@ -1,25 +1,7 @@
|
|
1
|
-
# SQLite version 3.x
|
2
|
-
# gem install sqlite3
|
3
|
-
#
|
4
|
-
# Ensure the SQLite 3 gem is defined in your Gemfile
|
5
|
-
# gem 'sqlite3'
|
6
1
|
development:
|
7
|
-
adapter:
|
8
|
-
database:
|
9
|
-
pool: 5
|
10
|
-
timeout: 5000
|
2
|
+
adapter: postgresql
|
3
|
+
database: tuning_development
|
11
4
|
|
12
|
-
# Warning: The database defined as "test" will be erased and
|
13
|
-
# re-generated from your development database when you run "rake".
|
14
|
-
# Do not set this db to the same as development or production.
|
15
5
|
test:
|
16
|
-
adapter:
|
17
|
-
database:
|
18
|
-
pool: 5
|
19
|
-
timeout: 5000
|
20
|
-
|
21
|
-
production:
|
22
|
-
adapter: sqlite3
|
23
|
-
database: db/production.sqlite3
|
24
|
-
pool: 5
|
25
|
-
timeout: 5000
|
6
|
+
adapter: postgresql
|
7
|
+
database: tuning_test
|
@@ -0,0 +1,12 @@
|
|
1
|
+
mysql: &mysql
|
2
|
+
adapter: <%= 'jdbc' if RUBY_ENGINE == 'jruby' %>mysql<%= '2' if RUBY_ENGINE != 'jruby' %>
|
3
|
+
|
4
|
+
postgres: &postgres
|
5
|
+
adapter: <%= 'jdbc' if RUBY_ENGINE == 'jruby' %>postgresql
|
6
|
+
|
7
|
+
sqlite: &sqlite
|
8
|
+
adapter: <%= 'jdbc' if RUBY_ENGINE == 'jruby' %>sqlite3
|
9
|
+
|
10
|
+
test:
|
11
|
+
<<: *<%= ENV['DB'] %>
|
12
|
+
database: <%= ENV['DB'] == 'sqlite' ? 'db/travis.sqlite3' : 'travis' %>
|
@@ -10,7 +10,7 @@ Dummy::Application.configure do
|
|
10
10
|
config.eager_load = false
|
11
11
|
|
12
12
|
# Show full error reports and disable caching.
|
13
|
-
config.consider_all_requests_local
|
13
|
+
config.consider_all_requests_local = true
|
14
14
|
config.action_controller.perform_caching = false
|
15
15
|
|
16
16
|
# Don't care if the mailer can't send.
|
@@ -19,11 +19,23 @@ Dummy::Application.configure do
|
|
19
19
|
# Print deprecation notices to the Rails logger.
|
20
20
|
config.active_support.deprecation = :log
|
21
21
|
|
22
|
-
# Raise an error on page load if there are pending migrations
|
22
|
+
# Raise an error on page load if there are pending migrations.
|
23
23
|
config.active_record.migration_error = :page_load
|
24
24
|
|
25
25
|
# Debug mode disables concatenation and preprocessing of assets.
|
26
26
|
# This option may cause significant delays in view rendering with a large
|
27
27
|
# number of complex assets.
|
28
28
|
config.assets.debug = true
|
29
|
+
|
30
|
+
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
|
31
|
+
# yet still be able to expire them through the digest params.
|
32
|
+
config.assets.digest = true
|
33
|
+
|
34
|
+
# Adds additional error checking when serving assets at runtime.
|
35
|
+
# Checks for improperly declared sprockets dependencies.
|
36
|
+
# Raises helpful error messages.
|
37
|
+
config.assets.raise_runtime_errors = true
|
38
|
+
|
39
|
+
# Raises error for missing translations
|
40
|
+
# config.action_view.raise_on_missing_translations = true
|
29
41
|
end
|
@@ -5,26 +5,24 @@ Dummy::Application.configure do
|
|
5
5
|
config.cache_classes = true
|
6
6
|
|
7
7
|
# Eager load code on boot. This eager loads most of Rails and
|
8
|
-
# your application in memory, allowing both
|
8
|
+
# your application in memory, allowing both threaded web servers
|
9
9
|
# and those relying on copy on write to perform better.
|
10
10
|
# Rake tasks automatically ignore this option for performance.
|
11
11
|
config.eager_load = true
|
12
12
|
|
13
13
|
# Full error reports are disabled and caching is turned on.
|
14
|
-
config.consider_all_requests_local
|
14
|
+
config.consider_all_requests_local = false
|
15
15
|
config.action_controller.perform_caching = true
|
16
16
|
|
17
17
|
# Enable Rack::Cache to put a simple HTTP cache in front of your application
|
18
18
|
# Add `rack-cache` to your Gemfile before enabling this.
|
19
|
-
# For large-scale production use, consider using a caching reverse proxy like
|
19
|
+
# For large-scale production use, consider using a caching reverse proxy like
|
20
|
+
# NGINX, varnish or squid.
|
20
21
|
# config.action_dispatch.rack_cache = true
|
21
22
|
|
22
|
-
# Disable
|
23
|
-
|
24
|
-
|
25
|
-
else
|
26
|
-
config.serve_static_assets = false
|
27
|
-
end
|
23
|
+
# Disable serving static files from the `/public` folder by default since
|
24
|
+
# Apache or NGINX already handles this.
|
25
|
+
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
|
28
26
|
|
29
27
|
# Compress JavaScripts and CSS.
|
30
28
|
config.assets.js_compressor = :uglifier
|
@@ -33,21 +31,22 @@ Dummy::Application.configure do
|
|
33
31
|
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
34
32
|
config.assets.compile = false
|
35
33
|
|
36
|
-
#
|
34
|
+
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
|
35
|
+
# yet still be able to expire them through the digest params.
|
37
36
|
config.assets.digest = true
|
38
37
|
|
39
|
-
#
|
40
|
-
config.assets.version = '1.0'
|
38
|
+
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
|
41
39
|
|
42
40
|
# Specifies the header that your server uses for sending files.
|
43
|
-
# config.action_dispatch.x_sendfile_header =
|
44
|
-
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for
|
41
|
+
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
|
42
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
|
45
43
|
|
46
44
|
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
47
45
|
# config.force_ssl = true
|
48
46
|
|
49
|
-
#
|
50
|
-
|
47
|
+
# Use the lowest log level to ensure availability of diagnostic information
|
48
|
+
# when problems arise.
|
49
|
+
config.log_level = :debug
|
51
50
|
|
52
51
|
# Prepend all log lines with the following tags.
|
53
52
|
# config.log_tags = [ :subdomain, :uuid ]
|
@@ -59,26 +58,22 @@ Dummy::Application.configure do
|
|
59
58
|
# config.cache_store = :mem_cache_store
|
60
59
|
|
61
60
|
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
62
|
-
# config.action_controller.asset_host =
|
63
|
-
|
64
|
-
# Precompile additional assets.
|
65
|
-
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
66
|
-
# config.assets.precompile += %w( search.js )
|
61
|
+
# config.action_controller.asset_host = 'http://assets.example.com'
|
67
62
|
|
68
63
|
# Ignore bad email addresses and do not raise email delivery errors.
|
69
64
|
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
70
65
|
# config.action_mailer.raise_delivery_errors = false
|
71
66
|
|
72
67
|
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
73
|
-
# the I18n.default_locale when a translation
|
68
|
+
# the I18n.default_locale when a translation cannot be found).
|
74
69
|
config.i18n.fallbacks = true
|
75
70
|
|
76
71
|
# Send deprecation notices to registered listeners.
|
77
72
|
config.active_support.deprecation = :notify
|
78
73
|
|
79
|
-
# Disable automatic flushing of the log to improve performance.
|
80
|
-
# config.autoflush_log = false
|
81
|
-
|
82
74
|
# Use default logging formatter so that PID and timestamp are not suppressed.
|
83
75
|
config.log_formatter = ::Logger::Formatter.new
|
76
|
+
|
77
|
+
# Do not dump schema after migrations.
|
78
|
+
config.active_record.dump_schema_after_migration = false
|
84
79
|
end
|
@@ -12,13 +12,9 @@ Dummy::Application.configure do
|
|
12
12
|
# preloads Rails for running tests, you may have to set it to true.
|
13
13
|
config.eager_load = false
|
14
14
|
|
15
|
-
# Configure static
|
16
|
-
|
17
|
-
|
18
|
-
else
|
19
|
-
config.serve_static_assets = false
|
20
|
-
end
|
21
|
-
config.static_cache_control = "public, max-age=3600"
|
15
|
+
# Configure static file server for tests with Cache-Control for performance.
|
16
|
+
config.serve_static_files = true
|
17
|
+
config.static_cache_control = 'public, max-age=3600'
|
22
18
|
|
23
19
|
# Show full error reports and disable caching.
|
24
20
|
config.consider_all_requests_local = true
|
@@ -35,10 +31,12 @@ Dummy::Application.configure do
|
|
35
31
|
# ActionMailer::Base.deliveries array.
|
36
32
|
config.action_mailer.delivery_method = :test
|
37
33
|
|
34
|
+
# Randomize the order test cases are executed.
|
35
|
+
config.active_support.test_order = :random
|
36
|
+
|
38
37
|
# Print deprecation notices to the stderr.
|
39
38
|
config.active_support.deprecation = :stderr
|
40
39
|
|
41
|
-
|
42
|
-
|
43
|
-
end
|
40
|
+
# Raises error for missing translations
|
41
|
+
# config.action_view.raise_on_missing_translations = true
|
44
42
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Version of your assets, change this if you want to expire all your assets.
|
4
|
+
Rails.application.config.assets.version = '1.0'
|
5
|
+
|
6
|
+
# Add additional assets to the asset load path
|
7
|
+
# Rails.application.config.assets.paths << Emoji.images_path
|
8
|
+
|
9
|
+
# Precompile additional assets.
|
10
|
+
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
11
|
+
# Rails.application.config.assets.precompile += %w( search.js )
|
@@ -1,10 +1,23 @@
|
|
1
|
+
# Files in the config/locales directory are used for internationalization
|
2
|
+
# and are automatically loaded by Rails. If you want to use locales other
|
3
|
+
# than English, add the necessary files in this directory.
|
4
|
+
#
|
5
|
+
# To use the locales, use `I18n.t`:
|
6
|
+
#
|
7
|
+
# I18n.t 'hello'
|
8
|
+
#
|
9
|
+
# In views, this is aliased to just `t`:
|
10
|
+
#
|
11
|
+
# <%= t('hello') %>
|
12
|
+
#
|
13
|
+
# To use a different locale, set it with `I18n.locale`:
|
14
|
+
#
|
15
|
+
# I18n.locale = :es
|
16
|
+
#
|
17
|
+
# This would use the information in config/locales/es.yml.
|
18
|
+
#
|
19
|
+
# To learn more, please read the Rails Internationalization guide
|
20
|
+
# available at http://guides.rubyonrails.org/i18n.html.
|
21
|
+
|
1
22
|
en:
|
2
|
-
|
3
|
-
index:
|
4
|
-
title: 'index title'
|
5
|
-
description: 'index description'
|
6
|
-
keywords: 'index keywords'
|
7
|
-
variable:
|
8
|
-
title: 'variable %{name}'
|
9
|
-
description: 'variable %{name}'
|
10
|
-
keywords: 'variable %{name}'
|
23
|
+
hello: "Hello world"
|