flowmor_router 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +175 -0
  4. data/Rakefile +34 -0
  5. data/app/controllers/application_controller.rb +2 -0
  6. data/app/controllers/static_controller.rb +2 -0
  7. data/app/models/routable_record.rb +121 -0
  8. data/bin/rails +12 -0
  9. data/config/routes.rb +21 -0
  10. data/lib/flowmor_router/engine.rb +4 -0
  11. data/lib/flowmor_router/exceptions.rb +3 -0
  12. data/lib/flowmor_router/version.rb +3 -0
  13. data/lib/flowmor_router.rb +24 -0
  14. data/lib/tasks/flowmor_router_tasks.rake +4 -0
  15. data/test/dummy/README.rdoc +28 -0
  16. data/test/dummy/Rakefile +6 -0
  17. data/test/dummy/app/assets/javascripts/application.js +13 -0
  18. data/test/dummy/app/assets/javascripts/blog.js +2 -0
  19. data/test/dummy/app/assets/javascripts/static.js +2 -0
  20. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  21. data/test/dummy/app/assets/stylesheets/blog.css +4 -0
  22. data/test/dummy/app/assets/stylesheets/static.css +4 -0
  23. data/test/dummy/app/controllers/application_controller.rb +5 -0
  24. data/test/dummy/app/controllers/blog_controller.rb +9 -0
  25. data/test/dummy/app/controllers/static_controller.rb +2 -0
  26. data/test/dummy/app/helpers/application_helper.rb +2 -0
  27. data/test/dummy/app/helpers/blog_helper.rb +2 -0
  28. data/test/dummy/app/helpers/static_helper.rb +2 -0
  29. data/test/dummy/app/models/article.rb +3 -0
  30. data/test/dummy/app/models/news_article.rb +4 -0
  31. data/test/dummy/app/models/post.rb +18 -0
  32. data/test/dummy/app/models/post_category.rb +9 -0
  33. data/test/dummy/app/views/blog/show.html.erb +1 -0
  34. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  35. data/test/dummy/app/views/static/index.html.erb +3 -0
  36. data/test/dummy/bin/bundle +3 -0
  37. data/test/dummy/bin/rails +4 -0
  38. data/test/dummy/bin/rake +4 -0
  39. data/test/dummy/config/application.rb +23 -0
  40. data/test/dummy/config/boot.rb +5 -0
  41. data/test/dummy/config/database.yml +25 -0
  42. data/test/dummy/config/environment.rb +5 -0
  43. data/test/dummy/config/environments/development.rb +37 -0
  44. data/test/dummy/config/environments/production.rb +82 -0
  45. data/test/dummy/config/environments/test.rb +39 -0
  46. data/test/dummy/config/initializers/assets.rb +8 -0
  47. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  48. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  49. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  50. data/test/dummy/config/initializers/inflections.rb +16 -0
  51. data/test/dummy/config/initializers/mime_types.rb +4 -0
  52. data/test/dummy/config/initializers/session_store.rb +3 -0
  53. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  54. data/test/dummy/config/locales/en.yml +23 -0
  55. data/test/dummy/config/routes.rb +56 -0
  56. data/test/dummy/config/secrets.yml +22 -0
  57. data/test/dummy/config.ru +4 -0
  58. data/test/dummy/db/development.sqlite3 +0 -0
  59. data/test/dummy/db/migrate/20140811154447_create_posts.rb +11 -0
  60. data/test/dummy/db/migrate/20140811155356_create_post_categories.rb +10 -0
  61. data/test/dummy/db/migrate/20140811182855_create_articles.rb +10 -0
  62. data/test/dummy/db/migrate/20140811184010_create_news_articles.rb +10 -0
  63. data/test/dummy/db/schema.rb +45 -0
  64. data/test/dummy/db/test.sqlite3 +0 -0
  65. data/test/dummy/log/development.log +6 -0
  66. data/test/dummy/log/test.log +12740 -0
  67. data/test/dummy/public/404.html +67 -0
  68. data/test/dummy/public/422.html +67 -0
  69. data/test/dummy/public/500.html +66 -0
  70. data/test/dummy/public/favicon.ico +0 -0
  71. data/test/dummy/test/controllers/static_controller_test.rb +10 -0
  72. data/test/dummy/test/fixtures/articles.yml +9 -0
  73. data/test/dummy/test/fixtures/news_articles.yml +9 -0
  74. data/test/dummy/test/fixtures/post_categories.yml +9 -0
  75. data/test/dummy/test/fixtures/posts.yml +11 -0
  76. data/test/dummy/test/helpers/blog_helper_test.rb +4 -0
  77. data/test/dummy/test/helpers/static_helper_test.rb +4 -0
  78. data/test/dummy/test/integration/routable_records_test.rb +12 -0
  79. data/test/dummy/test/models/article_test.rb +29 -0
  80. data/test/dummy/test/models/news_article_test.rb +50 -0
  81. data/test/dummy/test/models/post_category_test.rb +46 -0
  82. data/test/dummy/test/models/post_test.rb +50 -0
  83. data/test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  84. data/test/dummy/tmp/cache/assets/test/sprockets/2cdcb1089fe8a96b07fa1beb4356a3f2 +0 -0
  85. data/test/dummy/tmp/cache/assets/test/sprockets/2ef169e1ab9b9980404c3f7bd7b16cd1 +0 -0
  86. data/test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  87. data/test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  88. data/test/dummy/tmp/cache/assets/test/sprockets/66a7ff918272131011428741d7073461 +0 -0
  89. data/test/dummy/tmp/cache/assets/test/sprockets/66e7b4d1264df0176332685032844ce5 +0 -0
  90. data/test/dummy/tmp/cache/assets/test/sprockets/9bd4a825d7cf65dfa37efb43fe6b5aa7 +0 -0
  91. data/test/dummy/tmp/cache/assets/test/sprockets/a3ecd3c2fe5e4b3c4dd1365b4c108d06 +0 -0
  92. data/test/dummy/tmp/cache/assets/test/sprockets/c1a3b329f54c41592a0854a40f8425e0 +0 -0
  93. data/test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  94. data/test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  95. data/test/dummy/tmp/cache/assets/test/sprockets/efbfd84424b5a4f22bd23b73db9591a2 +0 -0
  96. data/test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  97. data/test/flowmor_router_test.rb +7 -0
  98. data/test/integration/navigation_test.rb +10 -0
  99. data/test/test_helper.rb +15 -0
  100. metadata +257 -0
@@ -0,0 +1,67 @@
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
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/404.html -->
59
+ <div class="dialog">
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>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,67 @@
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
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/422.html -->
59
+ <div class="dialog">
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>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,66 @@
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
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/500.html -->
59
+ <div class="dialog">
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>
64
+ </div>
65
+ </body>
66
+ </html>
File without changes
@@ -0,0 +1,10 @@
1
+ require 'test_helper'
2
+
3
+ class StaticControllerTest < ActionController::TestCase
4
+ test "should get index" do
5
+ get :index
6
+ assert_response :success
7
+ assert_select "h1", "Static Page Example"
8
+ assert_select "p", "It Works!"
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2
+
3
+ one:
4
+ title: MyString
5
+ name: MyString
6
+
7
+ two:
8
+ title: MyString
9
+ name: MyString
@@ -0,0 +1,9 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2
+
3
+ one:
4
+ title: MyString
5
+ name: MyString
6
+
7
+ two:
8
+ title: MyString
9
+ name: MyString
@@ -0,0 +1,9 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2
+
3
+ one:
4
+ title: MyString
5
+ name: MyString
6
+
7
+ two:
8
+ title: MyString
9
+ name: MyString
@@ -0,0 +1,11 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2
+
3
+ one:
4
+ title: MyString
5
+ category_id: 1
6
+ name: MyString
7
+
8
+ two:
9
+ title: MyString
10
+ category_id: 1
11
+ name: MyString
@@ -0,0 +1,4 @@
1
+ require 'test_helper'
2
+
3
+ class BlogHelperTest < ActionView::TestCase
4
+ end
@@ -0,0 +1,4 @@
1
+ require 'test_helper'
2
+
3
+ class StaticHelperTest < ActionView::TestCase
4
+ end
@@ -0,0 +1,12 @@
1
+ require 'test_helper'
2
+
3
+ class RoutableRecordsTest < ActionDispatch::IntegrationTest
4
+ test "/general/lets-test-this" do
5
+ post = Post.create(title: "Let's Test This")
6
+ assert_equal post.name, 'lets-test-this'
7
+ assert_equal "/general/lets-test-this", post.path
8
+ get post.path
9
+ assert_response :success
10
+ assert_select "h1", "Let&#39;s Test This"
11
+ end
12
+ end
@@ -0,0 +1,29 @@
1
+ require 'test_helper'
2
+
3
+ class ArticleTest < ActiveSupport::TestCase
4
+ test "article#controller_action" do
5
+ assert Article.new.controller_action, "article#show"
6
+ end
7
+
8
+ test "article#route_name" do
9
+ assert Article.new(title: "Dummy Article").route_name, 'articles_dummy_article'
10
+ end
11
+
12
+ test "article#route_name_prefix" do
13
+ assert Article.new(title: "Dummy Article").route_name_prefix, 'article'
14
+ end
15
+
16
+ test "article#derived_name_field_value" do
17
+ assert Article.new(title: "Dummy Article").derived_name_field_value, 'dummy-article'
18
+ end
19
+
20
+ test "article#path" do
21
+ assert_raise FlowmorRouter::UnroutableRecord do
22
+ Article.new(title: nil).path
23
+ end
24
+ assert_raise FlowmorRouter::UnroutableRecord do
25
+ Article.create(title: nil).path
26
+ end
27
+ assert Article.create(title: "Dummy Article").path, '/articles/dummy-article'
28
+ end
29
+ end
@@ -0,0 +1,50 @@
1
+ require 'test_helper'
2
+
3
+ class NewsArticleTest < ActiveSupport::TestCase
4
+ test "news_article#controller_action" do
5
+ assert_equal "news_article#show", NewsArticle.new.controller_action
6
+ end
7
+
8
+ test "news_article#route_name" do
9
+ assert_equal 'news_articles_dummy_news_article', NewsArticle.new(caption: "Dummy News Article").route_name
10
+ end
11
+
12
+ test "news_article#route_name_prefix" do
13
+ assert_equal 'news_articles', NewsArticle.new(caption: "Dummy News Article").route_name_prefix
14
+ end
15
+
16
+ test "news_article#derived_name_field_value" do
17
+ assert_equal 'Dummy News Article', NewsArticle.new(caption: "Dummy News Article").derived_name_field_value
18
+ end
19
+
20
+ test "news_article#new_name_value" do
21
+ assert_equal 'dummy-news-article', NewsArticle.new(caption: "Dummy News Article").new_name_value
22
+ end
23
+
24
+ test "news_article#slug" do
25
+ assert_equal 'dummy-news-article', NewsArticle.create(caption: "Dummy News Article").slug
26
+ end
27
+
28
+ test "NewsArticle#route_model" do
29
+ assert_equal 'news_article', NewsArticle.route_model
30
+ end
31
+
32
+ test "news_article#path" do
33
+ assert_raise FlowmorRouter::UnroutableRecord do
34
+ NewsArticle.new(caption: nil).path
35
+ end
36
+ assert_raise FlowmorRouter::UnroutableRecord do
37
+ NewsArticle.create(caption: nil).path
38
+ end
39
+ assert_equal '/news-articles/dummy-news-article', NewsArticle.create(caption: "Dummy News Article").path
40
+ end
41
+
42
+ test "news_article#url" do
43
+ assert_raise FlowmorRouter::UnroutableRecord do
44
+ NewsArticle.new(caption: nil).url
45
+ end
46
+ assert_raise FlowmorRouter::UnroutableRecord do
47
+ NewsArticle.create(caption: nil).url
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,46 @@
1
+ require 'test_helper'
2
+
3
+ class PostCategoryCategoryTest < ActiveSupport::TestCase
4
+ test "post_category#controller_action" do
5
+ assert_equal "blog#category", PostCategory.new.controller_action
6
+ end
7
+
8
+ test "post_category#route_name" do
9
+ assert_equal 'categories_general', PostCategory.new(title: "General").route_name
10
+ end
11
+
12
+ test "post_category#route_name_prefix" do
13
+ assert_equal 'categories', PostCategory.new(title: "General").route_name_prefix
14
+ end
15
+
16
+ test "post_category#derived_name_field_value" do
17
+ assert_equal 'General', PostCategory.new(title: "General").derived_name_field_value
18
+ end
19
+
20
+ test "post_category#new_name_value" do
21
+ assert_equal 'general', PostCategory.new(title: "General").new_name_value
22
+ end
23
+
24
+ test "PostCategory#route_model" do
25
+ assert_equal 'post_category', PostCategory.route_model
26
+ end
27
+
28
+ test "post_category#path" do
29
+ assert_raise FlowmorRouter::UnroutableRecord do
30
+ PostCategory.new(title: nil).path
31
+ end
32
+ assert_raise FlowmorRouter::UnroutableRecord do
33
+ PostCategory.create(title: nil).path
34
+ end
35
+ assert_equal '/categories/general', PostCategory.create(title: "General").path
36
+ end
37
+
38
+ test "post_category#url" do
39
+ assert_raise FlowmorRouter::UnroutableRecord do
40
+ PostCategory.new(title: nil).url
41
+ end
42
+ assert_raise FlowmorRouter::UnroutableRecord do
43
+ PostCategory.create(title: nil).url
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,50 @@
1
+ require 'test_helper'
2
+
3
+ class PostTest < ActiveSupport::TestCase
4
+ test "post#controller_action" do
5
+ assert_equal "blog#show", Post.new.controller_action
6
+ end
7
+
8
+ test "default category is 'general'" do
9
+ assert_equal 'general', Post.new.category_name
10
+ end
11
+
12
+ test "post#route_name" do
13
+ assert_equal 'posts_general_dummy_post', Post.new(title: "Dummy Post").route_name
14
+ end
15
+
16
+ test "post#route_name_prefix" do
17
+ assert_equal 'posts_general', Post.new(title: "Dummy Post").route_name_prefix
18
+ end
19
+
20
+ test "post#derived_name_field_value" do
21
+ assert_equal 'Dummy Post', Post.new(title: "Dummy Post").derived_name_field_value
22
+ end
23
+
24
+ test "post#new_name_value" do
25
+ assert_equal 'dummy-post', Post.new(title: "Dummy Post").new_name_value
26
+ end
27
+
28
+ test "Post#route_model" do
29
+ assert_equal 'post', Post.route_model
30
+ end
31
+
32
+ test "post#path" do
33
+ assert_raise FlowmorRouter::UnroutableRecord do
34
+ Post.new(title: nil).path
35
+ end
36
+ assert_raise FlowmorRouter::UnroutableRecord do
37
+ Post.create(title: nil).path
38
+ end
39
+ assert_equal '/general/dummy-post', Post.create(title: "Dummy Post").path
40
+ end
41
+
42
+ test "post#url" do
43
+ assert_raise FlowmorRouter::UnroutableRecord do
44
+ Post.new(title: nil).url
45
+ end
46
+ assert_raise FlowmorRouter::UnroutableRecord do
47
+ Post.create(title: nil).url
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class FlowmorRouterTest < ActiveSupport::TestCase
4
+ test "truth" do
5
+ assert_kind_of Module, FlowmorRouter
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ require 'test_helper'
2
+
3
+ class NavigationTest < ActionDispatch::IntegrationTest
4
+ fixtures :all
5
+
6
+ # test "the truth" do
7
+ # assert true
8
+ # end
9
+ end
10
+
@@ -0,0 +1,15 @@
1
+ # Configure Rails Environment
2
+ ENV["RAILS_ENV"] = "test"
3
+
4
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
5
+ require "rails/test_help"
6
+
7
+ Rails.backtrace_cleaner.remove_silencers!
8
+
9
+ # Load support files
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