valid_route 0.0.1

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 (149) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/Rakefile +19 -0
  4. data/lib/tasks/valid_route_tasks.rake +4 -0
  5. data/lib/valid_route/all.rb +2 -0
  6. data/lib/valid_route/route_formatter.rb +36 -0
  7. data/lib/valid_route/route_validator.rb +154 -0
  8. data/lib/valid_route/version.rb +3 -0
  9. data/lib/valid_route.rb +1 -0
  10. data/test/dummy/README.rdoc +28 -0
  11. data/test/dummy/Rakefile +6 -0
  12. data/test/dummy/app/assets/javascripts/application.js +15 -0
  13. data/test/dummy/app/assets/javascripts/others.js +2 -0
  14. data/test/dummy/app/assets/javascripts/pages.js +2 -0
  15. data/test/dummy/app/assets/javascripts/users.js +2 -0
  16. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  17. data/test/dummy/app/assets/stylesheets/others.css +4 -0
  18. data/test/dummy/app/assets/stylesheets/pages.css +4 -0
  19. data/test/dummy/app/assets/stylesheets/scaffold.css +56 -0
  20. data/test/dummy/app/assets/stylesheets/users.css +4 -0
  21. data/test/dummy/app/constraints/page_constraint.rb +9 -0
  22. data/test/dummy/app/constraints/user_constraint.rb +9 -0
  23. data/test/dummy/app/controllers/application_controller.rb +5 -0
  24. data/test/dummy/app/controllers/others_controller.rb +58 -0
  25. data/test/dummy/app/controllers/pages_controller.rb +58 -0
  26. data/test/dummy/app/controllers/users_controller.rb +58 -0
  27. data/test/dummy/app/helpers/application_helper.rb +2 -0
  28. data/test/dummy/app/helpers/others_helper.rb +2 -0
  29. data/test/dummy/app/helpers/pages_helper.rb +2 -0
  30. data/test/dummy/app/helpers/users_helper.rb +2 -0
  31. data/test/dummy/app/models/other.rb +19 -0
  32. data/test/dummy/app/models/page.rb +22 -0
  33. data/test/dummy/app/models/user.rb +22 -0
  34. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  35. data/test/dummy/app/views/others/_form.html.erb +29 -0
  36. data/test/dummy/app/views/others/edit.html.erb +6 -0
  37. data/test/dummy/app/views/others/index.html.erb +31 -0
  38. data/test/dummy/app/views/others/new.html.erb +5 -0
  39. data/test/dummy/app/views/others/show.html.erb +19 -0
  40. data/test/dummy/app/views/pages/_form.html.erb +29 -0
  41. data/test/dummy/app/views/pages/edit.html.erb +6 -0
  42. data/test/dummy/app/views/pages/index.html.erb +31 -0
  43. data/test/dummy/app/views/pages/new.html.erb +5 -0
  44. data/test/dummy/app/views/pages/show.html.erb +19 -0
  45. data/test/dummy/app/views/users/_form.html.erb +29 -0
  46. data/test/dummy/app/views/users/edit.html.erb +6 -0
  47. data/test/dummy/app/views/users/index.html.erb +31 -0
  48. data/test/dummy/app/views/users/new.html.erb +5 -0
  49. data/test/dummy/app/views/users/show.html.erb +19 -0
  50. data/test/dummy/bin/bundle +3 -0
  51. data/test/dummy/bin/rails +4 -0
  52. data/test/dummy/bin/rake +4 -0
  53. data/test/dummy/config/application.rb +24 -0
  54. data/test/dummy/config/boot.rb +5 -0
  55. data/test/dummy/config/database.yml +25 -0
  56. data/test/dummy/config/environment.rb +5 -0
  57. data/test/dummy/config/environments/development.rb +29 -0
  58. data/test/dummy/config/environments/production.rb +80 -0
  59. data/test/dummy/config/environments/test.rb +36 -0
  60. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  61. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  62. data/test/dummy/config/initializers/inflections.rb +16 -0
  63. data/test/dummy/config/initializers/mime_types.rb +5 -0
  64. data/test/dummy/config/initializers/secret_token.rb +12 -0
  65. data/test/dummy/config/initializers/session_store.rb +3 -0
  66. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  67. data/test/dummy/config/locales/en.yml +23 -0
  68. data/test/dummy/config/routes.rb +22 -0
  69. data/test/dummy/config.ru +4 -0
  70. data/test/dummy/db/development.sqlite3 +0 -0
  71. data/test/dummy/db/migrate/20130504204336_create_pages.rb +13 -0
  72. data/test/dummy/db/migrate/20130505171048_create_users.rb +13 -0
  73. data/test/dummy/db/migrate/20130513145529_create_others.rb +11 -0
  74. data/test/dummy/db/schema.rb +40 -0
  75. data/test/dummy/db/seeds.rb +4 -0
  76. data/test/dummy/db/test.sqlite3 +0 -0
  77. data/test/dummy/log/development.log +8038 -0
  78. data/test/dummy/log/test.log +26031 -0
  79. data/test/dummy/public/404.html +58 -0
  80. data/test/dummy/public/422.html +58 -0
  81. data/test/dummy/public/500.html +57 -0
  82. data/test/dummy/public/favicon.ico +0 -0
  83. data/test/dummy/test/controllers/others_controller_test.rb +53 -0
  84. data/test/dummy/test/controllers/pages_controller_test.rb +54 -0
  85. data/test/dummy/test/controllers/users_controller_test.rb +52 -0
  86. data/test/dummy/test/helpers/others_helper_test.rb +4 -0
  87. data/test/dummy/test/helpers/pages_helper_test.rb +4 -0
  88. data/test/dummy/test/helpers/users_helper_test.rb +4 -0
  89. data/test/dummy/test/models/other_test.rb +7 -0
  90. data/test/dummy/test/models/page_test.rb +7 -0
  91. data/test/dummy/test/models/user_test.rb +7 -0
  92. data/test/dummy/test/valid_route/route_formatter_test.rb +48 -0
  93. data/test/dummy/test/valid_route/route_validator_test.rb +104 -0
  94. data/test/dummy/tmp/cache/assets/development/sprockets/0204daa608dcc3d6010d17d5a3325dae +0 -0
  95. data/test/dummy/tmp/cache/assets/development/sprockets/0800f54ee19cf3cee10b956fa9786799 +0 -0
  96. data/test/dummy/tmp/cache/assets/development/sprockets/0f1e224003d74d132651ab92f55c07cd +0 -0
  97. data/test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  98. data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  99. data/test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  100. data/test/dummy/tmp/cache/assets/development/sprockets/36a0c7121af098cc05c1eb1e9b05c6fc +0 -0
  101. data/test/dummy/tmp/cache/assets/development/sprockets/371bf96e99717688ed7313a0c53f4212 +0 -0
  102. data/test/dummy/tmp/cache/assets/development/sprockets/4050a4e5062ab95c9f32e9b6940821ea +0 -0
  103. data/test/dummy/tmp/cache/assets/development/sprockets/510da110ae528e2d22533be39ff696c5 +0 -0
  104. data/test/dummy/tmp/cache/assets/development/sprockets/58e369b37e5157ea746a485eea17e9f7 +0 -0
  105. data/test/dummy/tmp/cache/assets/development/sprockets/5f1a0d05e77ca8b9a1fc2a47e17a8174 +0 -0
  106. data/test/dummy/tmp/cache/assets/development/sprockets/6fc757c2c8329244ca95d6909865bbc2 +0 -0
  107. data/test/dummy/tmp/cache/assets/development/sprockets/7162e1034189ecdac520608cf2d65859 +0 -0
  108. data/test/dummy/tmp/cache/assets/development/sprockets/7ae10239eda2588a95fdcc7d871bef52 +0 -0
  109. data/test/dummy/tmp/cache/assets/development/sprockets/87b209c0c9da28094a8d5581a21262c6 +0 -0
  110. data/test/dummy/tmp/cache/assets/development/sprockets/8d5d60255600aa010a32e1d1a9bc6db6 +0 -0
  111. data/test/dummy/tmp/cache/assets/development/sprockets/b3d9b0e88cdded276ebdce333e338a85 +0 -0
  112. data/test/dummy/tmp/cache/assets/development/sprockets/cebc6db0bbb8120f430da3970b173d2f +0 -0
  113. data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  114. data/test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  115. data/test/dummy/tmp/cache/assets/development/sprockets/dd4918aca468e2fe7bf61814631a1758 +0 -0
  116. data/test/dummy/tmp/cache/assets/development/sprockets/ebb095504f281d4e6bc39c4e574e25b2 +0 -0
  117. data/test/dummy/tmp/cache/assets/development/sprockets/f56253b5f374fff1a33fbbc9881c9124 +0 -0
  118. data/test/dummy/tmp/cache/assets/development/sprockets/f576841f662770908b35e6951e6900dd +0 -0
  119. data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  120. data/test/dummy/tmp/cache/assets/development/sprockets/ff05efaf31ab618d1eae2cd81fe67315 +0 -0
  121. data/test/dummy/tmp/cache/assets/test/sprockets/0204daa608dcc3d6010d17d5a3325dae +0 -0
  122. data/test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  123. data/test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  124. data/test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  125. data/test/dummy/tmp/cache/assets/test/sprockets/36a0c7121af098cc05c1eb1e9b05c6fc +0 -0
  126. data/test/dummy/tmp/cache/assets/test/sprockets/371bf96e99717688ed7313a0c53f4212 +0 -0
  127. data/test/dummy/tmp/cache/assets/test/sprockets/3d6a697f5610f9f9e1d5af4ce5c9d618 +0 -0
  128. data/test/dummy/tmp/cache/assets/test/sprockets/4050a4e5062ab95c9f32e9b6940821ea +0 -0
  129. data/test/dummy/tmp/cache/assets/test/sprockets/58e369b37e5157ea746a485eea17e9f7 +0 -0
  130. data/test/dummy/tmp/cache/assets/test/sprockets/5f1a0d05e77ca8b9a1fc2a47e17a8174 +0 -0
  131. data/test/dummy/tmp/cache/assets/test/sprockets/6fc757c2c8329244ca95d6909865bbc2 +0 -0
  132. data/test/dummy/tmp/cache/assets/test/sprockets/717ea0077fd0f73e5d956e4902250d3a +0 -0
  133. data/test/dummy/tmp/cache/assets/test/sprockets/7ae10239eda2588a95fdcc7d871bef52 +0 -0
  134. data/test/dummy/tmp/cache/assets/test/sprockets/8733c94f79979ec907253d4bff6714a6 +0 -0
  135. data/test/dummy/tmp/cache/assets/test/sprockets/87b209c0c9da28094a8d5581a21262c6 +0 -0
  136. data/test/dummy/tmp/cache/assets/test/sprockets/8d5d60255600aa010a32e1d1a9bc6db6 +0 -0
  137. data/test/dummy/tmp/cache/assets/test/sprockets/b3d9b0e88cdded276ebdce333e338a85 +0 -0
  138. data/test/dummy/tmp/cache/assets/test/sprockets/c9f51f5d854353b135800b3f119d5a2f +0 -0
  139. data/test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  140. data/test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  141. data/test/dummy/tmp/cache/assets/test/sprockets/f56253b5f374fff1a33fbbc9881c9124 +0 -0
  142. data/test/dummy/tmp/cache/assets/test/sprockets/f576841f662770908b35e6951e6900dd +0 -0
  143. data/test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  144. data/test/dummy/tmp/cache/assets/test/sprockets/ff05efaf31ab618d1eae2cd81fe67315 +0 -0
  145. data/test/factories/others.rb +11 -0
  146. data/test/factories/pages.rb +23 -0
  147. data/test/factories/users.rb +34 -0
  148. data/test/test_helper.rb +17 -0
  149. metadata +401 -0
@@ -0,0 +1,58 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/404.html -->
52
+ <div class="dialog">
53
+ <h1>The page you were looking for doesn't exist.</h1>
54
+ <p>You may have mistyped the address or the page may have moved.</p>
55
+ </div>
56
+ <p>If you are the application owner check the logs for more information.</p>
57
+ </body>
58
+ </html>
@@ -0,0 +1,58 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/422.html -->
52
+ <div class="dialog">
53
+ <h1>The change you wanted was rejected.</h1>
54
+ <p>Maybe you tried to change something you didn't have access to.</p>
55
+ </div>
56
+ <p>If you are the application owner check the logs for more information.</p>
57
+ </body>
58
+ </html>
@@ -0,0 +1,57 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/500.html -->
52
+ <div class="dialog">
53
+ <h1>We're sorry, but something went wrong.</h1>
54
+ </div>
55
+ <p>If you are the application owner check the logs for more information.</p>
56
+ </body>
57
+ </html>
File without changes
@@ -0,0 +1,53 @@
1
+ require 'test_helper'
2
+
3
+ class OthersControllerTest < ActionController::TestCase
4
+
5
+ test "should get index" do
6
+ @other = FactoryGirl.create(:other)
7
+ get :index
8
+ assert_response :success
9
+ assert_not_nil assigns(:others)
10
+ end
11
+
12
+ test "should get new" do
13
+ @other = Other.new
14
+ get :new
15
+ assert_response :success
16
+ end
17
+
18
+ test "should create other" do
19
+ @other = FactoryGirl.build(:other)
20
+ assert_difference('Other.count') do
21
+ post :create, other: { content: @other.content, name: @other.name, permalink: @other.permalink }
22
+ end
23
+
24
+ assert_redirected_to other_path(assigns(:other))
25
+ end
26
+
27
+ test "should show other" do
28
+ @other = FactoryGirl.create(:other)
29
+ get :show, id: @other
30
+ assert_response :success
31
+ end
32
+
33
+ test "should get edit" do
34
+ @other = FactoryGirl.create(:other)
35
+ get :edit, id: @other
36
+ assert_response :success
37
+ end
38
+
39
+ test "should update other" do
40
+ @other = FactoryGirl.create(:other)
41
+ patch :update, id: @other, other: { content: @other.content, name: @other.name, permalink: @other.permalink }
42
+ assert_redirected_to other_path(assigns(:other))
43
+ end
44
+
45
+ test "should destroy other" do
46
+ @other = FactoryGirl.create(:other)
47
+ assert_difference('Other.count', -1) do
48
+ delete :destroy, id: @other
49
+ end
50
+
51
+ assert_redirected_to others_path
52
+ end
53
+ end
@@ -0,0 +1,54 @@
1
+ require 'test_helper'
2
+
3
+ class PagesControllerTest < ActionController::TestCase
4
+ test "should get index" do
5
+ get :index
6
+ assert_response :success
7
+ assert_not_nil assigns(:pages)
8
+ end
9
+
10
+ test "should get new" do
11
+ @page = Page.new
12
+ get :new
13
+ assert_response :success
14
+ end
15
+
16
+ test "should create page" do
17
+ @built_page = FactoryGirl.build(:page)
18
+ assert @built_page.valid?, @built_page.inspect
19
+ assert_difference('Page.count') do
20
+ post :create, page: { content: @built_page.content, name: @built_page.name, permalink: @built_page.permalink }
21
+ end
22
+
23
+ assert_redirected_to page_path(assigns(:page))
24
+ end
25
+
26
+ test "should show page" do
27
+ @page = FactoryGirl.create(:page)
28
+
29
+ get :show, id: @page
30
+ assert_response :success
31
+ end
32
+
33
+ test "should get edit" do
34
+ @page = FactoryGirl.create(:page)
35
+ get :edit, id: @page
36
+ assert_response :success
37
+ end
38
+
39
+ test "should update page" do
40
+ @page = FactoryGirl.create(:page)
41
+
42
+ patch :update, id: @page, page: { content: @page.content, name: @page.name, permalink: @page.permalink }
43
+ assert_redirected_to page_path(assigns(:page))
44
+ end
45
+
46
+ test "should destroy page" do
47
+ @page = FactoryGirl.create(:page)
48
+ assert_difference('Page.count', -1) do
49
+ delete :destroy, id: @page
50
+ end
51
+
52
+ assert_redirected_to pages_path
53
+ end
54
+ end
@@ -0,0 +1,52 @@
1
+ require 'test_helper'
2
+
3
+ class UsersControllerTest < ActionController::TestCase
4
+
5
+ test "should get index" do
6
+ get :index
7
+ assert_response :success
8
+ assert_not_nil assigns(:users)
9
+ end
10
+
11
+ test "should get new" do
12
+ @user = User.new
13
+ get :new
14
+ assert_response :success
15
+ end
16
+
17
+ test "should create user" do
18
+ @user = FactoryGirl.build(:user)
19
+ assert_difference('User.count') do
20
+ post :create, user: { first_name: @user.first_name, password: @user.password, username: @user.username }
21
+ end
22
+
23
+ assert_redirected_to user_path(assigns(:user))
24
+ end
25
+
26
+ test "should show user" do
27
+ @user = FactoryGirl.create(:user)
28
+ get :show, id: @user
29
+ assert_response :success
30
+ end
31
+
32
+ test "should get edit" do
33
+ @user = FactoryGirl.create(:user)
34
+ get :edit, id: @user
35
+ assert_response :success
36
+ end
37
+
38
+ test "should update user" do
39
+ @user = FactoryGirl.create(:user)
40
+ patch :update, id: @user, user: { first_name: @user.first_name, password: @user.password, username: @user.username }
41
+ assert_redirected_to user_path(assigns(:user))
42
+ end
43
+
44
+ test "should destroy user" do
45
+ @user = FactoryGirl.create(:user)
46
+ assert_difference('User.count', -1) do
47
+ delete :destroy, id: @user
48
+ end
49
+
50
+ assert_redirected_to users_path
51
+ end
52
+ end
@@ -0,0 +1,4 @@
1
+ require 'test_helper'
2
+
3
+ class OthersHelperTest < ActionView::TestCase
4
+ end
@@ -0,0 +1,4 @@
1
+ require 'test_helper'
2
+
3
+ class PagesHelperTest < ActionView::TestCase
4
+ end
@@ -0,0 +1,4 @@
1
+ require 'test_helper'
2
+
3
+ class UsersHelperTest < ActionView::TestCase
4
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class OtherTest < ActiveSupport::TestCase
4
+ # test "the truth" do
5
+ # assert true
6
+ # end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class PageTest < ActiveSupport::TestCase
4
+ # test "the truth" do
5
+ # assert true
6
+ # end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class UserTest < ActiveSupport::TestCase
4
+ # test "the truth" do
5
+ # assert true
6
+ # end
7
+ end
@@ -0,0 +1,48 @@
1
+ require 'test_helper'
2
+
3
+ class RouteFormatterTest < ActionController::TestCase
4
+
5
+ test "routes returned as an array" do
6
+ expected_results = []
7
+ expected_results.push({path: '/pages', verb: 'GET', reqs: 'pages#index'})
8
+ expected_results.push({path: '/pages/new', verb: 'GET', reqs: 'pages#new'})
9
+ expected_results.push({path: '/pages/:id/edit', verb: 'GET', reqs: 'pages#edit'})
10
+ expected_results.push({path: '/pages/:id', verb: 'GET', reqs: 'pages#show'})
11
+ expected_results.push({path: '/:id', verb: 'GET', reqs: 'pages#show'})
12
+ expected_results.push({path: '/', verb: 'GET', reqs: 'pages#show {:id=>"home"}'})
13
+ expected_results.push({path: '/home', verb: 'GET', reqs: 'redirect(301, /)'})
14
+ expected_results.push({path: '/contact_us', verb: 'GET', reqs: 'pages#show {:id=>"contact"}'})
15
+
16
+ expected_results.push({:path=>"/users", :verb=>"GET", :reqs=>"users#index"})
17
+ expected_results.push({:path=>"/users/new", :verb=>"GET", :reqs=>"users#new"})
18
+ expected_results.push({:path=>"/users/:id/edit", :verb=>"GET", :reqs=>"users#edit"})
19
+ expected_results.push({:path=>"/users/:id", :verb=>"GET", :reqs=>"users#show"})
20
+ expected_results.push({:path=>"/:id", :verb=>"GET", :reqs=>"users#show"})
21
+ expected_results.push({:path=>"/all_users", :verb=>"GET", :reqs=>"users#index"})
22
+
23
+ expected_results.push({:path=>"/others", :verb=>"GET", :reqs=>"others#index"})
24
+ expected_results.push({:path=>"/others/new", :verb=>"GET", :reqs=>"others#new"})
25
+ expected_results.push({:path=>"/others/:id/edit", :verb=>"GET", :reqs=>"others#edit"})
26
+ expected_results.push({:path=>"/others/:id", :verb=>"GET", :reqs=>"others#show"})
27
+ expected_results.push({:path=>"/:id", :verb=>"GET", :reqs=>"others#show"})
28
+
29
+
30
+ inspector = ActionDispatch::Routing::RoutesInspector.new(Rails.application.routes.routes)
31
+ actual_results = inspector.format(ValidRoute::RouteFormatter.new)
32
+
33
+ actual_results.delete_if { |route|
34
+ route[:verb] != "GET"
35
+
36
+ }
37
+
38
+ unexpected_routes = actual_results - expected_results
39
+ expected_routes_missing = expected_results - actual_results
40
+
41
+
42
+ assert unexpected_routes.empty?, "\n" + "unexpected_routes:" + "\n" + "#{unexpected_routes}"
43
+ assert expected_routes_missing.empty?, "\n" + "expected_routes_missing:" + "\n" + "#{expected_routes_missing}"
44
+
45
+
46
+ end
47
+
48
+ end
@@ -0,0 +1,104 @@
1
+ require 'test_helper'
2
+
3
+ class RouteValidatorTest < ActionController::TestCase
4
+
5
+ test "existing routes should not be allowed to conflict" do
6
+
7
+ FactoryGirl.create(:page, permalink: "home")
8
+ assert Page.exists?("home")
9
+ FactoryGirl.create(:page, permalink: "contact")
10
+ assert Page.exists?("contact")
11
+
12
+ FactoryGirl.create(:user, username: "vjm")
13
+ assert User.exists?("vjm")
14
+
15
+ assert_routing '/contact_us', { :controller => "pages", :action => "show", :id => "contact" }
16
+ assert_routing '/pages/home/edit', { :controller => "pages", :action => "edit", :id => "home" }
17
+ assert_routing '/pages/new', { :controller => "pages", :action => "new" }
18
+ assert_routing '/pages', { :controller => "pages", :action => "index" }
19
+ assert_routing "/", { :controller => "pages", :action => "show", :id => "home" }
20
+
21
+ # assert_recognizes({:controller => 'pages', :action => 'show', :id => 'random_page'}, '/random_page')
22
+
23
+ assert_routing '/users/vjm', { :controller => "users", :action => "show", :id => "vjm" }
24
+ assert_routing '/users/vjm/edit', { :controller => "users", :action => "edit", :id => "vjm" }
25
+ assert_routing '/users/new', { :controller => "users", :action => "new" }
26
+ assert_routing '/users', { :controller => "users", :action => "index" }
27
+
28
+ assert_recognizes({:controller => 'users', :action => 'index'}, '/all_users')
29
+ # assert_recognizes page_permalink_path, '/'
30
+ # assert_routing '/all_users', { :controller => "users", :action => "index" }
31
+
32
+ # assert_recognizes {:controller => 'users', :action => 'show', :id => 'vjm'}, '/vjm'
33
+
34
+
35
+ users_page = FactoryGirl.build(:page, permalink: "users")
36
+ assert !users_page.valid?
37
+ assert users_page.errors.full_messages.include?("Permalink route is taken"), users_page.errors.full_messages.inspect
38
+
39
+ pages_page = FactoryGirl.build(:page, permalink: "pages")
40
+ assert !pages_page.valid?, pages_page.errors.inspect
41
+ assert pages_page.errors.full_messages.include?("Permalink route is taken"), pages_page.errors.full_messages.inspect
42
+
43
+ vjm_page = FactoryGirl.build(:page, permalink: "vjm")
44
+ assert !vjm_page.valid?, vjm_page.errors.inspect
45
+ assert vjm_page.errors.full_messages.include?("Permalink route is taken"), vjm_page.errors.full_messages.inspect
46
+
47
+
48
+ home_user = FactoryGirl.build(:user, username: "home")
49
+ assert !home_user.valid?, home_user.errors.inspect
50
+ assert home_user.errors.full_messages.include?("Username route is taken"), home_user.errors.full_messages.inspect
51
+
52
+ contact_user = FactoryGirl.build(:user, username: "contact")
53
+ assert !contact_user.valid?, contact_user.errors.inspect
54
+ assert contact_user.errors.full_messages.include?("Username route is taken"), contact_user.errors.full_messages.inspect
55
+
56
+ pages_user = FactoryGirl.build(:user, username: "pages")
57
+ assert !pages_user.valid?, pages_user.errors.inspect
58
+ assert pages_user.errors.full_messages.include?("Username route is taken"), pages_user.errors.full_messages.inspect
59
+
60
+
61
+
62
+
63
+ end
64
+
65
+ test "additional reserved routes option" do
66
+
67
+ inspector = ActionDispatch::Routing::RoutesInspector.new(Rails.application.routes.routes)
68
+ actual_results = inspector.format(ValidRoute::RouteFormatter.new)
69
+
70
+ tommy_page = FactoryGirl.build(:page, permalink: "tommy")
71
+ assert !tommy_page.valid?, actual_results
72
+ assert tommy_page.errors.full_messages.include?("Permalink route is taken"), tommy_page.errors.full_messages.inspect
73
+
74
+ reserved_page = FactoryGirl.build(:page, permalink: "reserved")
75
+ assert !reserved_page.valid?, reserved_page.errors.inspect
76
+ assert reserved_page.errors.full_messages.include?("Permalink route is taken"), reserved_page.errors.full_messages.inspect
77
+
78
+ about_user = FactoryGirl.build(:user, username: "about")
79
+ assert !about_user.valid?, about_user.errors.inspect
80
+ assert about_user.errors.full_messages.include?("Username route is taken"), about_user.errors.full_messages.inspect
81
+
82
+ admin_user = FactoryGirl.build(:user, username: "admin")
83
+ assert !admin_user.valid?, admin_user.errors.inspect
84
+ assert admin_user.errors.full_messages.include?("Username route is taken"), admin_user.errors.full_messages.inspect
85
+
86
+
87
+ end
88
+
89
+ test "unreserved routes option" do
90
+
91
+ pages_user = FactoryGirl.build(:user, username: "pages")
92
+ assert !pages_user.valid?, pages_user.errors.inspect
93
+ assert pages_user.errors.full_messages.include?("Username route is taken"), pages_user.errors.full_messages.inspect
94
+
95
+ pages_other = FactoryGirl.build(:other, permalink: "pages")
96
+ assert pages_other.valid?
97
+ # assert pages_other.errors.full_messages.include?("Permalink route is taken"), pages_other.errors.full_messages.inspect
98
+
99
+
100
+
101
+
102
+ end
103
+
104
+ end