tuning 4.0.1.2 → 5.1.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 (59) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +4 -4
  4. data/Rakefile +1 -3
  5. data/lib/tuning/railtie.rb +2 -0
  6. data/lib/tuning/version.rb +1 -1
  7. metadata +15 -125
  8. data/test/controller_test.rb +0 -22
  9. data/test/dummy/Rakefile +0 -5
  10. data/test/dummy/app/assets/javascripts/application.js +0 -13
  11. data/test/dummy/app/assets/stylesheets/application.css +0 -15
  12. data/test/dummy/app/controllers/application_controller.rb +0 -5
  13. data/test/dummy/app/controllers/users_controller.rb +0 -7
  14. data/test/dummy/app/helpers/application_helper.rb +0 -2
  15. data/test/dummy/app/mailers/user_mailer.rb +0 -7
  16. data/test/dummy/app/models/session.rb +0 -6
  17. data/test/dummy/app/models/user.rb +0 -5
  18. data/test/dummy/app/views/layouts/application.html.erb +0 -2
  19. data/test/dummy/app/views/layouts/market.html.erb +0 -3
  20. data/test/dummy/app/views/user_mailer/invite.text.erb +0 -7
  21. data/test/dummy/app/views/users/index.json.ruby +0 -3
  22. data/test/dummy/bin/bundle +0 -4
  23. data/test/dummy/bin/rails +0 -5
  24. data/test/dummy/bin/rake +0 -5
  25. data/test/dummy/bin/setup +0 -30
  26. data/test/dummy/config.ru +0 -4
  27. data/test/dummy/config/application.rb +0 -25
  28. data/test/dummy/config/boot.rb +0 -5
  29. data/test/dummy/config/database.yml +0 -10
  30. data/test/dummy/config/database.yml.travis +0 -3
  31. data/test/dummy/config/environment.rb +0 -5
  32. data/test/dummy/config/environments/development.rb +0 -41
  33. data/test/dummy/config/environments/production.rb +0 -79
  34. data/test/dummy/config/environments/test.rb +0 -42
  35. data/test/dummy/config/initializers/assets.rb +0 -11
  36. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  37. data/test/dummy/config/initializers/cookies_serializer.rb +0 -3
  38. data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  39. data/test/dummy/config/initializers/inflections.rb +0 -16
  40. data/test/dummy/config/initializers/mime_types.rb +0 -4
  41. data/test/dummy/config/initializers/session_store.rb +0 -3
  42. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  43. data/test/dummy/config/locales/en.yml +0 -23
  44. data/test/dummy/config/routes.rb +0 -3
  45. data/test/dummy/config/secrets.yml +0 -22
  46. data/test/dummy/db/migrate/20161020200126_create_users.rb +0 -9
  47. data/test/dummy/db/schema.rb +0 -25
  48. data/test/dummy/log/development.log +0 -63
  49. data/test/dummy/log/test.log +0 -6565
  50. data/test/dummy/public/404.html +0 -61
  51. data/test/dummy/public/422.html +0 -61
  52. data/test/dummy/public/500.html +0 -60
  53. data/test/dummy/public/favicon.ico +0 -0
  54. data/test/helper_test.rb +0 -51
  55. data/test/mailer_test.rb +0 -13
  56. data/test/record_test.rb +0 -16
  57. data/test/test_helper.rb +0 -14
  58. data/test/validation_test.rb +0 -172
  59. data/test/view_test.rb +0 -14
@@ -1,61 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The page you were looking for doesn't exist (404)</title>
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <style>
7
- body {
8
- background-color: #EFEFEF;
9
- color: #2E2F30;
10
- text-align: center;
11
- font-family: arial, sans-serif;
12
- margin: 0;
13
- }
14
- div.dialog {
15
- width: 95%;
16
- max-width: 33em;
17
- margin: 4em auto 0;
18
- }
19
- div.dialog > div {
20
- border: 1px solid #CCC;
21
- border-right-color: #999;
22
- border-left-color: #999;
23
- border-bottom-color: #BBB;
24
- border-top: #B00100 solid 4px;
25
- border-top-left-radius: 9px;
26
- border-top-right-radius: 9px;
27
- background-color: white;
28
- padding: 7px 12% 0;
29
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
30
- }
31
- h1 {
32
- font-size: 100%;
33
- color: #730E15;
34
- line-height: 1.5em;
35
- }
36
- div.dialog > p {
37
- margin: 0 0 1em;
38
- padding: 1em;
39
- background-color: #F7F7F7;
40
- border: 1px solid #CCC;
41
- border-right-color: #999;
42
- border-left-color: #999;
43
- border-bottom-color: #999;
44
- border-bottom-left-radius: 4px;
45
- border-bottom-right-radius: 4px;
46
- border-top-color: #DADADA;
47
- color: #666;
48
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
49
- }
50
- </style>
51
- </head>
52
- <body>
53
- <div class="dialog">
54
- <div>
55
- <h1>The page you were looking for doesn't exist.</h1>
56
- <p>You may have mistyped the address or the page may have moved.</p>
57
- </div>
58
- <p>If you are the application owner check the logs for more information.</p>
59
- </div>
60
- </body>
61
- </html>
@@ -1,61 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The change you wanted was rejected (422)</title>
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <style>
7
- body {
8
- background-color: #EFEFEF;
9
- color: #2E2F30;
10
- text-align: center;
11
- font-family: arial, sans-serif;
12
- margin: 0;
13
- }
14
- div.dialog {
15
- width: 95%;
16
- max-width: 33em;
17
- margin: 4em auto 0;
18
- }
19
- div.dialog > div {
20
- border: 1px solid #CCC;
21
- border-right-color: #999;
22
- border-left-color: #999;
23
- border-bottom-color: #BBB;
24
- border-top: #B00100 solid 4px;
25
- border-top-left-radius: 9px;
26
- border-top-right-radius: 9px;
27
- background-color: white;
28
- padding: 7px 12% 0;
29
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
30
- }
31
- h1 {
32
- font-size: 100%;
33
- color: #730E15;
34
- line-height: 1.5em;
35
- }
36
- div.dialog > p {
37
- margin: 0 0 1em;
38
- padding: 1em;
39
- background-color: #F7F7F7;
40
- border: 1px solid #CCC;
41
- border-right-color: #999;
42
- border-left-color: #999;
43
- border-bottom-color: #999;
44
- border-bottom-left-radius: 4px;
45
- border-bottom-right-radius: 4px;
46
- border-top-color: #DADADA;
47
- color: #666;
48
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
49
- }
50
- </style>
51
- </head>
52
- <body>
53
- <div class="dialog">
54
- <div>
55
- <h1>The change you wanted was rejected.</h1>
56
- <p>Maybe you tried to change something you didn't have access to.</p>
57
- </div>
58
- <p>If you are the application owner check the logs for more information.</p>
59
- </div>
60
- </body>
61
- </html>
@@ -1,60 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>We're sorry, but something went wrong (500)</title>
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <style>
7
- body {
8
- background-color: #EFEFEF;
9
- color: #2E2F30;
10
- text-align: center;
11
- font-family: arial, sans-serif;
12
- margin: 0;
13
- }
14
- div.dialog {
15
- width: 95%;
16
- max-width: 33em;
17
- margin: 4em auto 0;
18
- }
19
- div.dialog > div {
20
- border: 1px solid #CCC;
21
- border-right-color: #999;
22
- border-left-color: #999;
23
- border-bottom-color: #BBB;
24
- border-top: #B00100 solid 4px;
25
- border-top-left-radius: 9px;
26
- border-top-right-radius: 9px;
27
- background-color: white;
28
- padding: 7px 12% 0;
29
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
30
- }
31
- h1 {
32
- font-size: 100%;
33
- color: #730E15;
34
- line-height: 1.5em;
35
- }
36
- div.dialog > p {
37
- margin: 0 0 1em;
38
- padding: 1em;
39
- background-color: #F7F7F7;
40
- border: 1px solid #CCC;
41
- border-right-color: #999;
42
- border-left-color: #999;
43
- border-bottom-color: #999;
44
- border-bottom-left-radius: 4px;
45
- border-bottom-right-radius: 4px;
46
- border-top-color: #DADADA;
47
- color: #666;
48
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
49
- }
50
- </style>
51
- </head>
52
- <body>
53
- <div class="dialog">
54
- <div>
55
- <h1>We're sorry, but something went wrong.</h1>
56
- </div>
57
- <p>If you are the application owner check the logs for more information.</p>
58
- </div>
59
- </body>
60
- </html>
File without changes
@@ -1,51 +0,0 @@
1
- require 'test_helper'
2
-
3
- class HelperTest < ActionView::TestCase
4
- include Tuning::Extensions::ActionView::Base
5
-
6
- test 'active trail' do
7
- set_path '/some-path/other-path'
8
- assert active_trail?('/')
9
- assert active_trail?('/some-path')
10
-
11
- set_path '/'
12
- assert active_trail?('/')
13
- set_path '/some-path'
14
- assert active_trail?('/some-path')
15
-
16
- set_path '/'
17
- assert_not active_trail?('/some-path')
18
- set_path '/some-path'
19
- assert_not active_trail?('/other-path')
20
- end
21
-
22
- test 'content tag if' do
23
- assert_equal(
24
- 'content',
25
- content_tag_if(false, :a) { 'content' }
26
- )
27
- assert_equal(
28
- '<a>content</a>',
29
- content_tag_if(true, :a) { 'content' }
30
- )
31
- assert_equal(
32
- '<a href="#">content</a>',
33
- content_tag_if(true, :a, href: '#') { 'content' }
34
- )
35
- end
36
-
37
- test 'extending' do
38
- assert_equal(
39
- '<!DOCTYPE html><p>content</p>',
40
- render(template: 'layouts/market').gsub(/\n\s+/, '')
41
- )
42
- end
43
-
44
- private
45
-
46
- def set_path(path)
47
- self.request = ActionDispatch::TestRequest.new
48
- self.request.path = path
49
- end
50
-
51
- end
@@ -1,13 +0,0 @@
1
- require 'test_helper'
2
-
3
- class MailerTest < ActionMailer::TestCase
4
-
5
- test 'normalization' do
6
- email = UserMailer.invite('test@mail.com')
7
- assert_equal(
8
- "Hi there,\n\nPlease come check our website!\n\n-- Signature\n",
9
- email.body.to_s
10
- )
11
- end
12
-
13
- end
@@ -1,16 +0,0 @@
1
- require 'test_helper'
2
-
3
- class RecordTest < ActiveSupport::TestCase
4
-
5
- test 'nilify blanks' do
6
- user = User.new(name: '')
7
- user.save
8
- assert_nil user.name
9
- assert_nil user.reload.name
10
- end
11
-
12
- test 'validate' do
13
- assert User.new.respond_to?(:validate)
14
- end
15
-
16
- end
@@ -1,14 +0,0 @@
1
- # Configure Rails Environment
2
- ENV['RAILS_ENV'] = 'test'
3
-
4
- require File.expand_path('../../test/dummy/config/environment.rb', __FILE__)
5
- ActiveRecord::Migrator.migrations_paths = [File.expand_path('../../test/dummy/db/migrate', __FILE__)]
6
- require 'rails/test_help'
7
- require 'mocha/mini_test'
8
-
9
- # Filter out Minitest backtrace while allowing backtrace from other libraries
10
- # to be shown.
11
- Minitest.backtrace_filter = Minitest::BacktraceFilter.new
12
-
13
- # Load support files
14
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
@@ -1,172 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ValidationTest < ActiveSupport::TestCase
4
-
5
- MODELS = [User, Session]
6
-
7
- test 'methods' do
8
- MODELS.each do |model|
9
- %i(complexity count time).each do |validator|
10
- method = "validates_#{validator}_of"
11
- assert model.respond_to?(method)
12
- end
13
- end
14
- end
15
-
16
- test 'complexity' do
17
- with_validation(
18
- :password, complexity: true
19
- ) do |model|
20
- instance = model.new(password: nil)
21
- assert_not instance.valid?
22
-
23
- instance = model.new(password: 'aaaa')
24
- assert_not instance.valid?
25
- assert instance.errors.added?(:password, :too_easy)
26
-
27
- instance = model.new(password: 'aaAA33__')
28
- assert instance.valid?
29
- end
30
- end
31
-
32
- test 'count' do
33
- with_validation(
34
- :list, count: true
35
- ) do |model|
36
- instance = model.new(list: nil)
37
- assert_not instance.valid?
38
- assert instance.errors.added?(:list, :uncountable)
39
- end
40
-
41
- with_validation(
42
- :list, count: { within: 1..2 }
43
- ) do |model|
44
- instance = model.new(list: [1, 2, 3])
45
- assert_not instance.valid?
46
- assert instance.errors.added?(:list, :too_many, count: 2)
47
-
48
- instance = model.new(list: [])
49
- assert_not instance.valid?
50
- assert instance.errors.added?(:list, :too_few, count: 1)
51
-
52
- instance = model.new(list: [1])
53
- assert instance.valid?
54
- end
55
-
56
- with_validation(
57
- :list, count: { in: 1..2 }
58
- ) do |model|
59
- instance = model.new(list: [1, 2, 3])
60
- assert_not instance.valid?
61
- assert instance.errors.added?(:list, :too_many, count: 2)
62
-
63
- instance = model.new(list: [])
64
- assert_not instance.valid?
65
- assert instance.errors.added?(:list, :too_few, count: 1)
66
-
67
- instance = model.new(list: [1])
68
- assert instance.valid?
69
- end
70
-
71
- with_validation(
72
- :list, count: { maximum: 2 }
73
- ) do |model|
74
- instance = model.new(list: [1, 2, 3])
75
- assert_not instance.valid?
76
- assert instance.errors.added?(:list, :too_many, count: 2)
77
-
78
- instance = model.new(list: [])
79
- assert instance.valid?
80
- end
81
-
82
- with_validation(
83
- :list, count: { minimum: 1 }
84
- ) do |model|
85
- instance = model.new(list: [])
86
- assert_not instance.valid?
87
- assert instance.errors.added?(:list, :too_few, count: 1)
88
-
89
- instance = model.new(list: [1])
90
- assert instance.valid?
91
- end
92
- end
93
-
94
- test 'time' do
95
- with_validation(
96
- :created_at, time: true
97
- ) do |model|
98
- instance = model.new(created_at: nil)
99
- assert_not instance.valid?
100
- assert instance.errors.added?(:created_at, :not_a_time)
101
- end
102
-
103
- with_validation(
104
- :created_at, time: { before: Proc.new { Date.today } }
105
- ) do |model|
106
- instance = model.new(created_at: Date.today)
107
- assert_not instance.valid?
108
- assert instance.errors.added?(:created_at, :before, time: I18n.l(Date.today))
109
-
110
- instance = model.new(created_at: (Time.now + 1.day))
111
- assert_not instance.valid?
112
- assert instance.errors.added?(:created_at, :before, time: I18n.l(Date.today))
113
-
114
- instance = model.new(created_at: (Date.today - 1.day))
115
- assert instance.valid?
116
- end
117
-
118
- with_validation(
119
- :created_at, time: { before_or_equal_to: Date.today }
120
- ) do |model|
121
- instance = model.new(created_at: (Time.now + 1.day))
122
- assert_not instance.valid?
123
- assert instance.errors.added?(:created_at, :before_or_equal_to, time: I18n.l(Date.today))
124
-
125
- instance = model.new(created_at: Date.today)
126
- assert instance.valid?
127
-
128
- instance = model.new(created_at: (Date.today - 1.day))
129
- assert instance.valid?
130
- end
131
-
132
- with_validation(
133
- :created_at, time: { after: ->(instance) { instance.updated_at } }
134
- ) do |model|
135
- instance = model.new(created_at: Date.today, updated_at: Date.today)
136
- assert_not instance.valid?
137
- assert instance.errors.added?(:created_at, :after, time: I18n.l(instance.updated_at))
138
-
139
- instance = model.new(created_at: (Date.today - 1.day), updated_at: Date.today)
140
- assert_not instance.valid?
141
- assert instance.errors.added?(:created_at, :after, time: I18n.l(instance.updated_at))
142
-
143
- instance = model.new(created_at: (Time.now + 1.day), updated_at: Date.today)
144
- assert instance.valid?
145
- end
146
-
147
- with_validation(
148
- :created_at, time: { after_or_equal_to: :updated_at }
149
- ) do |model|
150
- instance = model.new(created_at: (Date.today - 1.day), updated_at: Date.today)
151
- assert_not instance.valid?
152
- assert instance.errors.added?(:created_at, :after_or_equal_to, time: I18n.l(instance.updated_at))
153
-
154
- instance = model.new(created_at: Date.today, updated_at: Date.today)
155
- assert instance.valid?
156
-
157
- instance = model.new(created_at: (Date.today + 1.day), updated_at: Date.today)
158
- assert instance.valid?
159
- end
160
- end
161
-
162
- private
163
-
164
- def with_validation(*args)
165
- MODELS.each do |model|
166
- model.validates *args
167
- yield model
168
- model.clear_validators!
169
- end
170
- end
171
-
172
- end