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/test/dummy/config/routes.rb
CHANGED
@@ -1,10 +1,5 @@
|
|
1
|
-
|
1
|
+
Rails.application.routes.draw do
|
2
2
|
|
3
|
-
|
4
|
-
get 'error' => 'status#error_action'
|
5
|
-
get 'not_found' => 'status#not_found_action'
|
6
|
-
get 'unauthorized' => 'status#unauthorized_action'
|
7
|
-
get 'forbidden' => 'status#forbidden_action'
|
8
|
-
get 'unprocessable_entity' => 'status#unprocessable_entity_action'
|
3
|
+
resources :shops
|
9
4
|
|
10
5
|
end
|
@@ -0,0 +1,22 @@
|
|
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 the secrets in this file are kept private
|
11
|
+
# if you're sharing your code publicly.
|
12
|
+
|
13
|
+
development:
|
14
|
+
secret_key_base: 921ea9f25943669d3a4b0a6c8762cb6a97a00c42732c84b3a4c80900d4f2be79081cad03e0ec8d5d0f2f293874b2bbd04c1444e7a6d6b9147de8f4ffb3acff11
|
15
|
+
|
16
|
+
test:
|
17
|
+
secret_key_base: 0e085a62fbfd58069441e0eb7dd8c3d0a7035017443181a5fba2c04041a03f8d0d427216ac56a51da79125898d125bb9fb8badb48404919fe3188eb309231570
|
18
|
+
|
19
|
+
# Do not keep production secrets in the repository,
|
20
|
+
# instead read values from the environment.
|
21
|
+
production:
|
22
|
+
secret_key_base: <%= ENV['SECRET_KEY_BASE'] %>
|
data/test/dummy/db/schema.rb
CHANGED
@@ -11,6 +11,20 @@
|
|
11
11
|
#
|
12
12
|
# It's strongly recommended that you check this file into your version control system.
|
13
13
|
|
14
|
-
ActiveRecord::Schema.define(version:
|
14
|
+
ActiveRecord::Schema.define(version: 20161022144717) do
|
15
|
+
|
16
|
+
# These are extensions that must be enabled in order to support this database
|
17
|
+
enable_extension "plpgsql"
|
18
|
+
|
19
|
+
create_table "records", force: :cascade do |t|
|
20
|
+
end
|
21
|
+
|
22
|
+
create_table "shops", force: :cascade do |t|
|
23
|
+
t.boolean "enabled"
|
24
|
+
t.boolean "visible"
|
25
|
+
t.string "name"
|
26
|
+
t.datetime "created_at", null: false
|
27
|
+
t.datetime "updated_at", null: false
|
28
|
+
end
|
15
29
|
|
16
30
|
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.5ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
2
|
+
[1m[35m (0.3ms)[0m BEGIN
|
3
|
+
------------------------------
|
4
|
+
HelpersTest: test_active_trail
|
5
|
+
------------------------------
|
6
|
+
[1m[36m (0.2ms)[0m [1mROLLBACK[0m
|
7
|
+
[1m[35m (0.1ms)[0m BEGIN
|
8
|
+
--------------------------------
|
9
|
+
HelpersTest: test_content_tag_if
|
10
|
+
--------------------------------
|
11
|
+
[1m[36m (0.2ms)[0m [1mROLLBACK[0m
|
12
|
+
[1m[35m (0.1ms)[0m BEGIN
|
13
|
+
---------------------------
|
14
|
+
HelpersTest: test_extending
|
15
|
+
---------------------------
|
16
|
+
Rendered layouts/application.html.erb (0.3ms)
|
17
|
+
Rendered layouts/market.html.erb (7.7ms)
|
18
|
+
[1m[36m (0.2ms)[0m [1mROLLBACK[0m
|
19
|
+
[1m[35m (0.1ms)[0m BEGIN
|
20
|
+
-----------------------------
|
21
|
+
ValidationsTest: test_methods
|
22
|
+
-----------------------------
|
23
|
+
[1m[36m (0.2ms)[0m [1mROLLBACK[0m
|
24
|
+
[1m[35m (0.1ms)[0m BEGIN
|
25
|
+
--------------------------
|
26
|
+
ValidationsTest: test_time
|
27
|
+
--------------------------
|
28
|
+
[1m[36m (0.2ms)[0m [1mROLLBACK[0m
|
29
|
+
[1m[35m (0.2ms)[0m BEGIN
|
30
|
+
--------------------------------
|
31
|
+
ValidationsTest: test_complexity
|
32
|
+
--------------------------------
|
33
|
+
[1m[36m (0.2ms)[0m [1mROLLBACK[0m
|
34
|
+
[1m[35m (0.2ms)[0m BEGIN
|
35
|
+
---------------------------
|
36
|
+
ValidationsTest: test_count
|
37
|
+
---------------------------
|
38
|
+
[1m[36m (0.3ms)[0m [1mROLLBACK[0m
|
39
|
+
[1m[35m (0.1ms)[0m BEGIN
|
40
|
+
-------------------------------
|
41
|
+
ControllersTest: test_callbacks
|
42
|
+
-------------------------------
|
43
|
+
[1m[36m (0.1ms)[0m [1mROLLBACK[0m
|
44
|
+
[1m[35m (0.2ms)[0m BEGIN
|
45
|
+
----------------------------
|
46
|
+
ControllersTest: test_render
|
47
|
+
----------------------------
|
48
|
+
[1m[36m (0.2ms)[0m [1mROLLBACK[0m
|
49
|
+
[1m[35m (0.1ms)[0m BEGIN
|
50
|
+
-------------------------------
|
51
|
+
MailersTest: test_normalization
|
52
|
+
-------------------------------
|
53
|
+
Rendered user_mailer/invite.text.erb (0.3ms)
|
54
|
+
|
55
|
+
UserMailer#invite: processed outbound mail in 11.4ms
|
56
|
+
[1m[36m (0.2ms)[0m [1mROLLBACK[0m
|
57
|
+
[1m[35m (0.2ms)[0m BEGIN
|
58
|
+
-------------------------------
|
59
|
+
RecordsTest: test_nilify_blanks
|
60
|
+
-------------------------------
|
61
|
+
[1m[36m (0.1ms)[0m [1mSAVEPOINT active_record_1[0m
|
62
|
+
[1m[35mSQL (0.4ms)[0m INSERT INTO "shops" ("created_at", "updated_at") VALUES ($1, $2) RETURNING "id" [["created_at", "2016-10-22 15:50:31.994321"], ["updated_at", "2016-10-22 15:50:31.994321"]]
|
63
|
+
[1m[36m (0.1ms)[0m [1mRELEASE SAVEPOINT active_record_1[0m
|
64
|
+
[1m[35mShop Load (0.3ms)[0m SELECT "shops".* FROM "shops" WHERE "shops"."id" = $1 LIMIT 1 [["id", 11]]
|
65
|
+
[1m[36m (0.2ms)[0m [1mROLLBACK[0m
|
66
|
+
[1m[35m (0.2ms)[0m BEGIN
|
67
|
+
--------------------------
|
68
|
+
RecordsTest: test_validate
|
69
|
+
--------------------------
|
70
|
+
[1m[36m (0.1ms)[0m [1mROLLBACK[0m
|
data/test/dummy/public/404.html
CHANGED
@@ -2,17 +2,23 @@
|
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
5
6
|
<style>
|
6
7
|
body {
|
7
8
|
background-color: #EFEFEF;
|
8
9
|
color: #2E2F30;
|
9
10
|
text-align: center;
|
10
11
|
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
11
13
|
}
|
12
14
|
|
13
15
|
div.dialog {
|
14
|
-
width:
|
15
|
-
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
16
22
|
border: 1px solid #CCC;
|
17
23
|
border-right-color: #999;
|
18
24
|
border-left-color: #999;
|
@@ -21,7 +27,8 @@
|
|
21
27
|
border-top-left-radius: 9px;
|
22
28
|
border-top-right-radius: 9px;
|
23
29
|
background-color: white;
|
24
|
-
padding: 7px
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
25
32
|
}
|
26
33
|
|
27
34
|
h1 {
|
@@ -30,19 +37,19 @@
|
|
30
37
|
line-height: 1.5em;
|
31
38
|
}
|
32
39
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
padding: 1em 0;
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
37
43
|
background-color: #F7F7F7;
|
38
44
|
border: 1px solid #CCC;
|
39
45
|
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
40
47
|
border-bottom-color: #999;
|
41
48
|
border-bottom-left-radius: 4px;
|
42
49
|
border-bottom-right-radius: 4px;
|
43
50
|
border-top-color: #DADADA;
|
44
51
|
color: #666;
|
45
|
-
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
46
53
|
}
|
47
54
|
</style>
|
48
55
|
</head>
|
@@ -50,9 +57,11 @@
|
|
50
57
|
<body>
|
51
58
|
<!-- This file lives in public/404.html -->
|
52
59
|
<div class="dialog">
|
53
|
-
<
|
54
|
-
|
60
|
+
<div>
|
61
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
62
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
55
65
|
</div>
|
56
|
-
<p>If you are the application owner check the logs for more information.</p>
|
57
66
|
</body>
|
58
67
|
</html>
|
data/test/dummy/public/422.html
CHANGED
@@ -2,17 +2,23 @@
|
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
5
6
|
<style>
|
6
7
|
body {
|
7
8
|
background-color: #EFEFEF;
|
8
9
|
color: #2E2F30;
|
9
10
|
text-align: center;
|
10
11
|
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
11
13
|
}
|
12
14
|
|
13
15
|
div.dialog {
|
14
|
-
width:
|
15
|
-
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
16
22
|
border: 1px solid #CCC;
|
17
23
|
border-right-color: #999;
|
18
24
|
border-left-color: #999;
|
@@ -21,7 +27,8 @@
|
|
21
27
|
border-top-left-radius: 9px;
|
22
28
|
border-top-right-radius: 9px;
|
23
29
|
background-color: white;
|
24
|
-
padding: 7px
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
25
32
|
}
|
26
33
|
|
27
34
|
h1 {
|
@@ -30,19 +37,19 @@
|
|
30
37
|
line-height: 1.5em;
|
31
38
|
}
|
32
39
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
padding: 1em 0;
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
37
43
|
background-color: #F7F7F7;
|
38
44
|
border: 1px solid #CCC;
|
39
45
|
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
40
47
|
border-bottom-color: #999;
|
41
48
|
border-bottom-left-radius: 4px;
|
42
49
|
border-bottom-right-radius: 4px;
|
43
50
|
border-top-color: #DADADA;
|
44
51
|
color: #666;
|
45
|
-
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
46
53
|
}
|
47
54
|
</style>
|
48
55
|
</head>
|
@@ -50,9 +57,11 @@
|
|
50
57
|
<body>
|
51
58
|
<!-- This file lives in public/422.html -->
|
52
59
|
<div class="dialog">
|
53
|
-
<
|
54
|
-
|
60
|
+
<div>
|
61
|
+
<h1>The change you wanted was rejected.</h1>
|
62
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
55
65
|
</div>
|
56
|
-
<p>If you are the application owner check the logs for more information.</p>
|
57
66
|
</body>
|
58
67
|
</html>
|
data/test/dummy/public/500.html
CHANGED
@@ -2,17 +2,23 @@
|
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
5
6
|
<style>
|
6
7
|
body {
|
7
8
|
background-color: #EFEFEF;
|
8
9
|
color: #2E2F30;
|
9
10
|
text-align: center;
|
10
11
|
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
11
13
|
}
|
12
14
|
|
13
15
|
div.dialog {
|
14
|
-
width:
|
15
|
-
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
16
22
|
border: 1px solid #CCC;
|
17
23
|
border-right-color: #999;
|
18
24
|
border-left-color: #999;
|
@@ -21,7 +27,8 @@
|
|
21
27
|
border-top-left-radius: 9px;
|
22
28
|
border-top-right-radius: 9px;
|
23
29
|
background-color: white;
|
24
|
-
padding: 7px
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
25
32
|
}
|
26
33
|
|
27
34
|
h1 {
|
@@ -30,19 +37,19 @@
|
|
30
37
|
line-height: 1.5em;
|
31
38
|
}
|
32
39
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
padding: 1em 0;
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
37
43
|
background-color: #F7F7F7;
|
38
44
|
border: 1px solid #CCC;
|
39
45
|
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
40
47
|
border-bottom-color: #999;
|
41
48
|
border-bottom-left-radius: 4px;
|
42
49
|
border-bottom-right-radius: 4px;
|
43
50
|
border-top-color: #DADADA;
|
44
51
|
color: #666;
|
45
|
-
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
46
53
|
}
|
47
54
|
</style>
|
48
55
|
</head>
|
@@ -50,8 +57,10 @@
|
|
50
57
|
<body>
|
51
58
|
<!-- This file lives in public/500.html -->
|
52
59
|
<div class="dialog">
|
53
|
-
<
|
60
|
+
<div>
|
61
|
+
<h1>We're sorry, but something went wrong.</h1>
|
62
|
+
</div>
|
63
|
+
<p>If you are the application owner check the logs for more information.</p>
|
54
64
|
</div>
|
55
|
-
<p>If you are the application owner check the logs for more information.</p>
|
56
65
|
</body>
|
57
66
|
</html>
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class HelpersTest < 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 'content', content_tag_if(false, :a) { 'content' }
|
24
|
+
assert_equal '<a>content</a>', content_tag_if(true, :a) { 'content' }
|
25
|
+
assert_equal '<a href="#">content</a>', content_tag_if(true, :a, href: '#') { 'content' }
|
26
|
+
end
|
27
|
+
|
28
|
+
test 'extending' do
|
29
|
+
assert_equal '<!DOCTYPE html><p>content</p>', render(template: 'layouts/market').gsub(/\n\s+/, '')
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def set_path(path)
|
35
|
+
self.request = ActionDispatch::TestRequest.new
|
36
|
+
self.request.path = path
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class RecordsTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
test 'nilify blanks' do
|
6
|
+
shop = Shop.new(name: '')
|
7
|
+
shop.save
|
8
|
+
assert_nil shop.name
|
9
|
+
assert_nil shop.reload.name
|
10
|
+
end
|
11
|
+
|
12
|
+
test 'validate' do
|
13
|
+
assert Shop.new.respond_to?(:validate)
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -2,23 +2,10 @@
|
|
2
2
|
ENV['RAILS_ENV'] = 'test'
|
3
3
|
|
4
4
|
require File.expand_path('../dummy/config/environment.rb', __FILE__)
|
5
|
+
ActiveRecord::Migrator.migrations_paths = [File.expand_path('../dummy/db/migrate', __FILE__)]
|
5
6
|
require 'rails/test_help'
|
7
|
+
require 'mocha/mini_test'
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
11
|
-
|
12
|
-
# Load fixtures from the engine
|
13
|
-
if ActiveSupport::TestCase.method_defined?(:fixture_path=)
|
14
|
-
ActiveSupport::TestCase.fixture_path = File.expand_path('../fixtures', __FILE__)
|
15
|
-
end
|
16
|
-
|
17
|
-
# Load database
|
18
|
-
config = YAML::load(File.read(File.expand_path('../dummy/config/database.yml', __FILE__)))
|
19
|
-
config['test']['adapter'] = 'jdbcsqlite3' if RUBY_PLATFORM == 'java'
|
20
|
-
ActiveRecord::Base.establish_connection(config['test'])
|
21
|
-
load(File.expand_path('../dummy/db/schema.rb', __FILE__))
|
22
|
-
|
23
|
-
# Include helpers
|
24
|
-
ActionView::TestCase.send :include, Tuning::ActionView::Base
|
9
|
+
# Filter out Minitest backtrace while allowing backtrace from other libraries
|
10
|
+
# to be shown.
|
11
|
+
Minitest.backtrace_filter = Minitest::BacktraceFilter.new
|