tuning 0.3.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +80 -17
  4. data/Rakefile +3 -0
  5. data/lib/tuning.rb +7 -2
  6. data/lib/tuning/extensions/action_controller/base.rb +45 -0
  7. data/lib/tuning/extensions/action_mailer/base.rb +22 -0
  8. data/lib/tuning/extensions/action_view/base.rb +31 -0
  9. data/lib/tuning/extensions/active_record/base.rb +25 -0
  10. data/lib/tuning/locales/en.yml +12 -0
  11. data/lib/tuning/locales/es.yml +12 -0
  12. data/lib/tuning/railtie.rb +17 -3
  13. data/lib/tuning/validations/complexity.rb +22 -0
  14. data/lib/tuning/validations/count.rb +42 -0
  15. data/lib/tuning/validations/time.rb +38 -0
  16. data/lib/tuning/version.rb +1 -1
  17. data/test/controllers_test.rb +21 -0
  18. data/test/dummy/Rakefile +1 -2
  19. data/test/dummy/app/assets/javascripts/application.js +2 -2
  20. data/test/dummy/app/assets/stylesheets/application.css +6 -4
  21. data/test/dummy/app/mailers/user_mailer.rb +7 -0
  22. data/test/dummy/app/models/shop.rb +2 -0
  23. data/test/dummy/app/views/layouts/application.html.erb +0 -12
  24. data/test/dummy/app/views/layouts/market.html.erb +3 -0
  25. data/test/dummy/app/views/user_mailer/invite.text.erb +7 -0
  26. data/test/dummy/bin/bundle +0 -0
  27. data/test/dummy/bin/rails +1 -1
  28. data/test/dummy/bin/rake +0 -0
  29. data/test/dummy/bin/setup +29 -0
  30. data/test/dummy/config.ru +1 -1
  31. data/test/dummy/config/application.rb +3 -1
  32. data/test/dummy/config/boot.rb +1 -1
  33. data/test/dummy/config/database.yml +4 -22
  34. data/test/dummy/config/database.yml.travis +12 -0
  35. data/test/dummy/config/environment.rb +1 -1
  36. data/test/dummy/config/environments/development.rb +14 -2
  37. data/test/dummy/config/environments/production.rb +20 -25
  38. data/test/dummy/config/environments/test.rb +8 -10
  39. data/test/dummy/config/initializers/assets.rb +11 -0
  40. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  41. data/test/dummy/config/initializers/mime_types.rb +1 -2
  42. data/test/dummy/config/initializers/session_store.rb +1 -1
  43. data/test/dummy/config/locales/en.yml +22 -9
  44. data/test/dummy/config/routes.rb +2 -7
  45. data/test/dummy/config/secrets.yml +22 -0
  46. data/test/dummy/db/migrate/20161020200126_create_shops.rb +9 -0
  47. data/test/dummy/db/migrate/20161022144717_create_records.rb +6 -0
  48. data/test/dummy/db/schema.rb +15 -1
  49. data/test/dummy/log/test.log +70 -0
  50. data/test/dummy/public/404.html +20 -11
  51. data/test/dummy/public/422.html +20 -11
  52. data/test/dummy/public/500.html +19 -10
  53. data/test/helpers_test.rb +39 -0
  54. data/test/mailers_test.rb +10 -0
  55. data/test/records_test.rb +16 -0
  56. data/test/test_helper.rb +5 -18
  57. data/test/validations_test.rb +192 -0
  58. metadata +66 -47
  59. data/lib/tuning/action_controller/base.rb +0 -54
  60. data/lib/tuning/action_view/base.rb +0 -16
  61. data/test/active_trail_test.rb +0 -33
  62. data/test/content_tag_if_test.rb +0 -17
  63. data/test/dummy/README.rdoc +0 -28
  64. data/test/dummy/app/controllers/status_controller.rb +0 -27
  65. data/test/dummy/config/initializers/secret_token.rb +0 -13
  66. data/test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  67. data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  68. data/test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  69. data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  70. data/test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  71. data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  72. data/test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  73. data/test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  74. data/test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  75. data/test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  76. data/test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  77. data/test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  78. data/test/status_test.rb +0 -55
@@ -1,16 +0,0 @@
1
- module Tuning
2
- module ActionView
3
- module Base
4
- extend ActiveSupport::Concern
5
-
6
- def active_trail?(path)
7
- (path == '/' && request.path == path) or request.path.start_with?(path)
8
- end
9
-
10
- def content_tag_if(condition, name, options={}, &block)
11
- condition ? content_tag(name, options, &block) : capture(&block)
12
- end
13
-
14
- end
15
- end
16
- end
@@ -1,33 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ActiveTrailTest < ActionView::TestCase
4
-
5
- test 'active trail in path' do
6
- set_path '/some-path/other-path'
7
- assert active_trail?('/')
8
- assert active_trail?('/some-path')
9
- end
10
-
11
- test 'active trail same as path' do
12
- set_path '/'
13
- assert active_trail?('/')
14
-
15
- set_path '/some-path'
16
- assert active_trail?('/some-path')
17
- end
18
-
19
- test 'active trail not in path' do
20
- set_path '/'
21
- assert !active_trail?('/some-path')
22
-
23
- set_path '/some-path'
24
- assert !active_trail?('/other-path')
25
- end
26
-
27
- private
28
-
29
- def set_path(path)
30
- self.request = OpenStruct.new(path: path)
31
- end
32
-
33
- end
@@ -1,17 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ContentTagIfTest < ActionView::TestCase
4
-
5
- test 'true condition' do
6
- assert_equal '<a>content</a>', content_tag_if(1 == 1, 'a') { 'content' }
7
- end
8
-
9
- test 'false condition' do
10
- assert_equal 'content', content_tag_if(1 == 2, 'a') { 'content' }
11
- end
12
-
13
- test 'attributes options' do
14
- assert_equal '<a href="#">content</a>', content_tag_if(1 == 1, 'a', href: '#') { 'content' }
15
- end
16
-
17
- end
@@ -1,28 +0,0 @@
1
- == README
2
-
3
- This README would normally document whatever steps are necessary to get the
4
- application up and running.
5
-
6
- Things you may want to cover:
7
-
8
- * Ruby version
9
-
10
- * System dependencies
11
-
12
- * Configuration
13
-
14
- * Database creation
15
-
16
- * Database initialization
17
-
18
- * How to run the test suite
19
-
20
- * Services (job queues, cache servers, search engines, etc.)
21
-
22
- * Deployment instructions
23
-
24
- * ...
25
-
26
-
27
- Please feel free to use a different markup language if you do not plan to run
28
- <tt>rake doc:app</tt>.
@@ -1,27 +0,0 @@
1
- class StatusController < ApplicationController
2
-
3
- def exception_action
4
- raise 'error'
5
- end
6
-
7
- def error_action
8
- error
9
- end
10
-
11
- def not_found_action
12
- not_found
13
- end
14
-
15
- def unauthorized_action
16
- unauthorized
17
- end
18
-
19
- def forbidden_action
20
- forbidden
21
- end
22
-
23
- def unprocessable_entity_action
24
- unprocessable_entity
25
- end
26
-
27
- end
@@ -1,13 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Your secret key is used for verifying the integrity of signed cookies.
4
- # If you change this key, all old signed cookies will become invalid!
5
-
6
- # Make sure the secret is at least 30 characters and all random,
7
- # no regular words or you'll be exposed to dictionary attacks.
8
- # You can use `rake secret` to generate a secure secret key.
9
-
10
- # Make sure your secret_key_base is kept private
11
- # if you're sharing your code publicly.
12
- Dummy::Application.config.secret_token = 'ebf2469bae653bb0ed9bc16c4485757036de73fd148942a3bf9940519149c443a572c3a9ab83386de40a0084743ab2db6a455f0218b553815c53ce04c697c300'
13
- Dummy::Application.config.secret_key_base = 'ebf2469bae653bb0ed9bc16c4485757036de73fd148942a3bf9940519149c443a572c3a9ab83386de40a0084743ab2db6a455f0218b553815c53ce04c697c300'
data/test/status_test.rb DELETED
@@ -1,55 +0,0 @@
1
- require 'test_helper'
2
-
3
- class StatusTest < ActionDispatch::IntegrationTest
4
-
5
- test 'error' do
6
- get '/error.json'
7
- assert_response 500
8
- assert_equal '', response.body.strip
9
-
10
- get '/error'
11
- assert_response 500
12
- assert_equal File.read(Rails.root.join('public', '500.html')), response.body
13
- end
14
-
15
- test 'not found' do
16
- get '/not_found.json'
17
- assert_response 404
18
- assert_equal '', response.body.strip
19
-
20
- get '/not_found'
21
- assert_response 404
22
- assert_equal File.read(Rails.root.join('public', '404.html')), response.body
23
- end
24
-
25
- test 'unauthorized' do
26
- get '/unauthorized.json'
27
- assert_response 401
28
- assert_equal '', response.body.strip
29
-
30
- get '/unauthorized'
31
- assert_response 401
32
- assert_equal File.read(Rails.root.join('public', '422.html')), response.body
33
- end
34
-
35
- test 'forbidden' do
36
- get '/forbidden.json'
37
- assert_response 403
38
- assert_equal '', response.body.strip
39
-
40
- get '/forbidden'
41
- assert_response 403
42
- assert_equal File.read(Rails.root.join('public', '422.html')), response.body
43
- end
44
-
45
- test 'unprocessable entity' do
46
- get '/unprocessable_entity.json'
47
- assert_response 422
48
- assert_equal '', response.body.strip
49
-
50
- get '/unprocessable_entity'
51
- assert_response 422
52
- assert_equal File.read(Rails.root.join('public', '422.html')), response.body
53
- end
54
-
55
- end