locomotivecms_steam 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (172) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +21 -0
  3. data/.travis.yml +4 -0
  4. data/CHANGELOG.md +19 -0
  5. data/Gemfile +8 -0
  6. data/Gemfile.lock +188 -0
  7. data/LICENSE +20 -0
  8. data/README.md +36 -0
  9. data/Rakefile +17 -0
  10. data/bin/publish +28 -0
  11. data/config/locales/de.yml +157 -0
  12. data/config/locales/en.yml +189 -0
  13. data/config/locales/es.yml +133 -0
  14. data/config/locales/et.yml +154 -0
  15. data/config/locales/fr.yml +148 -0
  16. data/config/locales/it.yml +155 -0
  17. data/config/locales/nb.yml +191 -0
  18. data/config/locales/nl.yml +160 -0
  19. data/config/locales/pl.yml +203 -0
  20. data/config/locales/pt-BR.yml +139 -0
  21. data/config/locales/ru.yml +224 -0
  22. data/lib/locomotive/steam/core_ext.rb +5 -0
  23. data/lib/locomotive/steam/core_ext/array.rb +3 -0
  24. data/lib/locomotive/steam/core_ext/boolean/false.rb +3 -0
  25. data/lib/locomotive/steam/core_ext/boolean/true.rb +3 -0
  26. data/lib/locomotive/steam/core_ext/hash.rb +27 -0
  27. data/lib/locomotive/steam/core_ext/string.rb +8 -0
  28. data/lib/locomotive/steam/exceptions.rb +62 -0
  29. data/lib/locomotive/steam/initializers.rb +5 -0
  30. data/lib/locomotive/steam/initializers/i18n.rb +3 -0
  31. data/lib/locomotive/steam/initializers/markdown.rb +27 -0
  32. data/lib/locomotive/steam/initializers/will_paginate.rb +16 -0
  33. data/lib/locomotive/steam/liquid.rb +22 -0
  34. data/lib/locomotive/steam/liquid/drops/base.rb +46 -0
  35. data/lib/locomotive/steam/liquid/drops/content_entry.rb +48 -0
  36. data/lib/locomotive/steam/liquid/drops/content_types.rb +117 -0
  37. data/lib/locomotive/steam/liquid/drops/page.rb +28 -0
  38. data/lib/locomotive/steam/liquid/drops/session_proxy.rb +18 -0
  39. data/lib/locomotive/steam/liquid/drops/site.rb +26 -0
  40. data/lib/locomotive/steam/liquid/errors.rb +17 -0
  41. data/lib/locomotive/steam/liquid/filters/date.rb +136 -0
  42. data/lib/locomotive/steam/liquid/filters/html.rb +188 -0
  43. data/lib/locomotive/steam/liquid/filters/misc.rb +49 -0
  44. data/lib/locomotive/steam/liquid/filters/resize.rb +18 -0
  45. data/lib/locomotive/steam/liquid/filters/text.rb +55 -0
  46. data/lib/locomotive/steam/liquid/filters/translate.rb +28 -0
  47. data/lib/locomotive/steam/liquid/patches.rb +47 -0
  48. data/lib/locomotive/steam/liquid/scopeable.rb +149 -0
  49. data/lib/locomotive/steam/liquid/tags/consume.rb +97 -0
  50. data/lib/locomotive/steam/liquid/tags/csrf.rb +34 -0
  51. data/lib/locomotive/steam/liquid/tags/editable.rb +6 -0
  52. data/lib/locomotive/steam/liquid/tags/editable/base.rb +50 -0
  53. data/lib/locomotive/steam/liquid/tags/editable/control.rb +19 -0
  54. data/lib/locomotive/steam/liquid/tags/editable/file.rb +15 -0
  55. data/lib/locomotive/steam/liquid/tags/editable/long_text.rb +15 -0
  56. data/lib/locomotive/steam/liquid/tags/editable/short_text.rb +20 -0
  57. data/lib/locomotive/steam/liquid/tags/editable/text.rb +15 -0
  58. data/lib/locomotive/steam/liquid/tags/extends.rb +25 -0
  59. data/lib/locomotive/steam/liquid/tags/google_analytics.rb +28 -0
  60. data/lib/locomotive/steam/liquid/tags/hybrid.rb +27 -0
  61. data/lib/locomotive/steam/liquid/tags/inline_editor.rb +16 -0
  62. data/lib/locomotive/steam/liquid/tags/link_to.rb +56 -0
  63. data/lib/locomotive/steam/liquid/tags/locale_switcher.rb +106 -0
  64. data/lib/locomotive/steam/liquid/tags/nav.rb +287 -0
  65. data/lib/locomotive/steam/liquid/tags/paginate.rb +105 -0
  66. data/lib/locomotive/steam/liquid/tags/path_helper.rb +98 -0
  67. data/lib/locomotive/steam/liquid/tags/path_to.rb +36 -0
  68. data/lib/locomotive/steam/liquid/tags/seo.rb +74 -0
  69. data/lib/locomotive/steam/liquid/tags/session_assign.rb +41 -0
  70. data/lib/locomotive/steam/liquid/tags/snippet.rb +63 -0
  71. data/lib/locomotive/steam/liquid/tags/with_scope.rb +44 -0
  72. data/lib/locomotive/steam/listen.rb +64 -0
  73. data/lib/locomotive/steam/logger.rb +54 -0
  74. data/lib/locomotive/steam/monkey_patches.rb +5 -0
  75. data/lib/locomotive/steam/monkey_patches/better_errors.rb +70 -0
  76. data/lib/locomotive/steam/monkey_patches/dragonfly.rb +79 -0
  77. data/lib/locomotive/steam/monkey_patches/haml.rb +15 -0
  78. data/lib/locomotive/steam/monkey_patches/httparty.rb +46 -0
  79. data/lib/locomotive/steam/monkey_patches/mounter.rb +32 -0
  80. data/lib/locomotive/steam/server.rb +81 -0
  81. data/lib/locomotive/steam/server/dynamic_assets.rb +33 -0
  82. data/lib/locomotive/steam/server/entry_submission.rb +120 -0
  83. data/lib/locomotive/steam/server/favicon.rb +18 -0
  84. data/lib/locomotive/steam/server/locale.rb +42 -0
  85. data/lib/locomotive/steam/server/logging.rb +32 -0
  86. data/lib/locomotive/steam/server/middleware.rb +61 -0
  87. data/lib/locomotive/steam/server/page.rb +69 -0
  88. data/lib/locomotive/steam/server/path.rb +34 -0
  89. data/lib/locomotive/steam/server/renderer.rb +118 -0
  90. data/lib/locomotive/steam/server/templatized_page.rb +32 -0
  91. data/lib/locomotive/steam/server/timezone.rb +18 -0
  92. data/lib/locomotive/steam/standalone_server.rb +33 -0
  93. data/lib/locomotive/steam/version.rb +5 -0
  94. data/lib/steam.rb +4 -0
  95. data/locomotivecms_steam.gemspec +42 -0
  96. data/spec/fixtures/default/README +0 -0
  97. data/spec/fixtures/default/app/content_types/bands.yml +19 -0
  98. data/spec/fixtures/default/app/content_types/events.yml +25 -0
  99. data/spec/fixtures/default/app/content_types/messages.yml +17 -0
  100. data/spec/fixtures/default/app/content_types/songs.yml +25 -0
  101. data/spec/fixtures/default/app/content_types/updates.yml +33 -0
  102. data/spec/fixtures/default/app/views/pages/404.liquid.haml +10 -0
  103. data/spec/fixtures/default/app/views/pages/about_us.fr.liquid.haml +7 -0
  104. data/spec/fixtures/default/app/views/pages/about_us.liquid.haml +21 -0
  105. data/spec/fixtures/default/app/views/pages/about_us.nb.liquid.haml +4 -0
  106. data/spec/fixtures/default/app/views/pages/about_us/jane_doe.liquid.haml +4 -0
  107. data/spec/fixtures/default/app/views/pages/about_us/john_doe.fr.liquid.haml +5 -0
  108. data/spec/fixtures/default/app/views/pages/about_us/john_doe.liquid.haml +6 -0
  109. data/spec/fixtures/default/app/views/pages/all.liquid.haml +13 -0
  110. data/spec/fixtures/default/app/views/pages/archives/news.liquid.haml +10 -0
  111. data/spec/fixtures/default/app/views/pages/contact.liquid.haml +54 -0
  112. data/spec/fixtures/default/app/views/pages/contest.liquid.haml +18 -0
  113. data/spec/fixtures/default/app/views/pages/events.liquid.haml +42 -0
  114. data/spec/fixtures/default/app/views/pages/filtered.liquid.haml +10 -0
  115. data/spec/fixtures/default/app/views/pages/grunge_bands.liquid.haml +8 -0
  116. data/spec/fixtures/default/app/views/pages/index.fr.liquid.haml +3 -0
  117. data/spec/fixtures/default/app/views/pages/index.liquid.haml +100 -0
  118. data/spec/fixtures/default/app/views/pages/music.fr.liquid.haml +4 -0
  119. data/spec/fixtures/default/app/views/pages/music.liquid.haml +42 -0
  120. data/spec/fixtures/default/app/views/pages/songs/template.fr.liquid.haml +16 -0
  121. data/spec/fixtures/default/app/views/pages/songs/template.liquid.haml +18 -0
  122. data/spec/fixtures/default/app/views/pages/songs/template/band.liquid.haml +16 -0
  123. data/spec/fixtures/default/app/views/pages/store.fr.liquid.haml +5 -0
  124. data/spec/fixtures/default/app/views/pages/store.liquid +5 -0
  125. data/spec/fixtures/default/app/views/pages/tags/nav.liquid.haml +6 -0
  126. data/spec/fixtures/default/app/views/pages/tags/nav_in_deep.liquid.haml +6 -0
  127. data/spec/fixtures/default/app/views/pages/unlisted_pages.liquid.haml +9 -0
  128. data/spec/fixtures/default/app/views/snippets/A_Complicated-one.liquid.haml +1 -0
  129. data/spec/fixtures/default/app/views/snippets/footer.liquid.haml +6 -0
  130. data/spec/fixtures/default/app/views/snippets/header.liquid.haml +1 -0
  131. data/spec/fixtures/default/app/views/snippets/song.fr.liquid.haml +8 -0
  132. data/spec/fixtures/default/app/views/snippets/song.liquid +12 -0
  133. data/spec/fixtures/default/config/deploy.yml +12 -0
  134. data/spec/fixtures/default/config/deploy_example.yml +12 -0
  135. data/spec/fixtures/default/config/site.yml +15 -0
  136. data/spec/fixtures/default/config/translations.yml +3 -0
  137. data/spec/fixtures/default/data/bands.yml +10 -0
  138. data/spec/fixtures/default/data/events.yml +53 -0
  139. data/spec/fixtures/default/data/songs.yml +46 -0
  140. data/spec/fixtures/default/data/updates.yml +48 -0
  141. data/spec/fixtures/default/public/fonts/chunkfive-webfont.eot +0 -0
  142. data/spec/fixtures/default/public/fonts/chunkfive-webfont.svg +213 -0
  143. data/spec/fixtures/default/public/fonts/chunkfive-webfont.ttf +0 -0
  144. data/spec/fixtures/default/public/fonts/chunkfive-webfont.woff +0 -0
  145. data/spec/fixtures/default/public/fonts/chunkfive.css +8 -0
  146. data/spec/fixtures/default/public/fonts/chunkfive.otf +0 -0
  147. data/spec/fixtures/default/public/images/nav_on.png +0 -0
  148. data/spec/fixtures/default/public/images/photo_frame.png +0 -0
  149. data/spec/fixtures/default/public/images/sep.png +0 -0
  150. data/spec/fixtures/default/public/images/top.jpg +0 -0
  151. data/spec/fixtures/default/public/javascripts/application.js.coffee +2 -0
  152. data/spec/fixtures/default/public/javascripts/common.js +1 -0
  153. data/spec/fixtures/default/public/samples/asset_collections/cover.jpg +0 -0
  154. data/spec/fixtures/default/public/samples/photo.jpg +0 -0
  155. data/spec/fixtures/default/public/samples/photo_2.jpg +0 -0
  156. data/spec/fixtures/default/public/stylesheets/application.css +64 -0
  157. data/spec/fixtures/default/public/stylesheets/other/extra.css.less +8 -0
  158. data/spec/fixtures/default/public/stylesheets/other/style.css.scss +13 -0
  159. data/spec/fixtures/default/public/stylesheets/reboot.css +82 -0
  160. data/spec/integration/integration_helper.rb +15 -0
  161. data/spec/integration/server/basic_spec.rb +170 -0
  162. data/spec/integration/server/contact_form_spec.rb +111 -0
  163. data/spec/integration/server/liquid_spec.rb +91 -0
  164. data/spec/integration/server/with_scope_spec.rb +20 -0
  165. data/spec/locales/locales_spec.rb +22 -0
  166. data/spec/spec_helper.rb +21 -0
  167. data/spec/support.rb +4 -0
  168. data/spec/support/examples/locale_file.rb +14 -0
  169. data/spec/support/examples/matching_locale.rb +8 -0
  170. data/spec/support/helpers.rb +22 -0
  171. data/spec/support/matchers/hash.rb +5 -0
  172. metadata +564 -0
@@ -0,0 +1,8 @@
1
+ @font-face {
2
+ font-family: 'ChunkFiveRoman';
3
+ src: url('chunkfive-webfont.eot');
4
+ src: local('☺'), url('chunkfive-webfont.woff') format('woff'), url('chunkfive-webfont.ttf') format('truetype'), url('chunkfive-webfont.svg#webfontwlZ5ec8v') format('svg');
5
+ font-weight: normal;
6
+ font-style: normal;
7
+ }
8
+
@@ -0,0 +1,2 @@
1
+ $(document).ready ->
2
+ alert 'hello world'
@@ -0,0 +1 @@
1
+ console.log('hello world')
@@ -0,0 +1,64 @@
1
+ body { background: #f0eee3 url("/images/top.jpg") repeat-x center 0; color: #333; font-family: Georgia, helvetica; font-size: 14px; }
2
+
3
+ h2 { font-size: 30px; font-style: italic; font-weight: normal; font-family: ChunkFiveRoman; margin-bottom: 6px; }
4
+
5
+ a { color: #2196b2; text-decoration: none; }
6
+ a:hover { text-decoration: underline; }
7
+
8
+ .sep { height: 1px; width: 950px; background: transparent url(/images/sep.png) repeat-x 0 0; }
9
+
10
+ .more a { font-style: italic; font-weight: bold; }
11
+
12
+ .container { width: 950px; padding-top: 0px; }
13
+
14
+ .error { text-align: center; font-size: 24px; text-transform: capitalize; }
15
+
16
+ /* ___ menu ___ */
17
+
18
+ #menu { height: 40px; }
19
+
20
+ #nav { list-style: none; height: 40px; }
21
+ #nav li { float: left; padding: 0px 20px 0 20px; height: 40px; }
22
+ #nav li a { position: relative; top: 7px; color: #fff; font-size: 18px; text-transform: lowercase; font-family: ChunkFiveRoman; }
23
+ #nav li.on { background: transparent url(/images/nav_on.png) repeat-x 0 0; }
24
+
25
+ /* ___ banner ___ */
26
+
27
+ #banner { padding-top: 20px; background: transparent url(/images/sep.png) repeat-x 0 bottom; margin-bottom: 30px; padding-bottom: 20px; }
28
+
29
+ #banner .photo { float: left; position: relative; left: -23px; background: transparent url(/images/photo_frame.png) no-repeat 0 0; padding: 24px 0 0px 32px; width: 636px; height: 438px; }
30
+ #banner .text { padding-top: 130px; margin-left: 686px; }
31
+ #banner .text p { font-size: 18px; }
32
+ #banner .text p a { font-weight: bold; font-size: 17px; }
33
+
34
+ /* ___ list ___ */
35
+
36
+ .list { list-style: none; font-size: 13px; margin-bottom: 10px; }
37
+ .list li { margin-bottom: 5px; }
38
+ .list li em { font-weight: bold; }
39
+
40
+ /* ___ songs ___ */
41
+
42
+ .songs { list-style: none; }
43
+ .songs li { margin: 0 20px 20px 0; padding: 0 0 20px 0px; background: transparent url(/images/sep.png) repeat-x 0 bottom; }
44
+ .songs li h3 { font-style: italic; margin-bottom: 6px; }
45
+ .songs li .cover { float: left; }
46
+ .songs li .cover img { border: 4px solid #fff; }
47
+ .songs li .info { margin-left: 165px; }
48
+ .songs li .info .listen { text-align: right; margin: 5px 0 0 0; }
49
+
50
+ /* ___ contact form ___ */
51
+
52
+ #contactform { margin-top: 30px; }
53
+ #contactform p { margin-bottom: 10px; clear: both; }
54
+ #contactform p label { float: left; width: 200px; }
55
+ #contactform p input[type=text], #contactform p textarea { font-size: 1em; padding: 3px 5px; }
56
+ #contactform p input[type=text] { width: 200px; }
57
+ #contactform p textarea { width: 400px; height: 200px; }
58
+ #contactform p.action { padding: 0 0px 15px 200px; }
59
+ #contactform p.action input { background: #2196b2; color: #fff; padding: 3px 5px; text-transform: uppercase; margin: 0 5px; border: none; }
60
+
61
+ /* ___ footer ___ */
62
+
63
+ #footer { background: transparent url(/images/sep.png) repeat-x 0 0; margin-top: 20px; padding-top: 10px; }
64
+ #footer p { text-align: center; font-size: 12px; }
@@ -0,0 +1,8 @@
1
+ @color: #4D926F;
2
+
3
+ #header {
4
+ color: @color;
5
+ }
6
+ h2 {
7
+ color: @color;
8
+ }
@@ -0,0 +1,13 @@
1
+ @import "compass/reset/utilities";
2
+
3
+ html {
4
+ @include global-reset;
5
+ }
6
+
7
+ body {
8
+ background: red;
9
+
10
+ h1 {
11
+ color: green;
12
+ }
13
+ }
@@ -0,0 +1,82 @@
1
+ html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, code, del, dfn, em, img, q, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {margin:0;padding:0;border:0;font-weight:inherit;font-style:inherit;font-size:100%;font-family:inherit;vertical-align:baseline;}
2
+
3
+ /* **************** GRIDS ***************** */
4
+ .container { margin: 0 auto; width: 900px; padding: 20px; text-align:left; }
5
+ .line, .lastUnit {overflow: hidden;_overflow:visible;_zoom:1;}
6
+ .line2 {_zoom:1; background-color:#FFF;}
7
+ .unit{float:left;_zoom:1;}
8
+ .unitExt{float:right;}
9
+ .size1of1{float:none;}
10
+ .size1of2{width:50%;}
11
+ .size1of3{width:33.33333%;}
12
+ .size2of3{width:66.66666%;}
13
+ .size1of4{width:25%;}
14
+ .size3of4{width:75%;}
15
+ .size1of5{width:20%;}
16
+ .size2of5{width:40%;}
17
+ .size3of5{width:60%;}
18
+ .size4of5{width:80%;}
19
+ .lastUnit {float:none;_position:relative; _left:-3px; _margin-right: -3px;width:auto;}
20
+ .padding10px{padding:10px;}
21
+ .padding15px{padding:15px;}
22
+ .padding20px{padding:20px;}
23
+ .clear{clear:both;height:1px;line-height:1px;}
24
+
25
+ /* **************** TYPOGRAPHY ***************** */
26
+ body {font-size:75%;line-height:1.5;}
27
+ h1, h2, h3, h4, h5, h6 {font-weight:normal;}
28
+ h1 {
29
+ font-size:3.6em;
30
+ line-height:1;
31
+ margin-bottom:0.5em;
32
+ color:#434343;
33
+ font-weight:bold;
34
+ letter-spacing:-0.05em;
35
+ }
36
+ h2 {font-size:2em;margin-bottom:0.75em; color:#434343;}
37
+ h3 {font-size:1.5em;line-height:1;margin-bottom:1em;}
38
+ h4 {font-size:1.25em;line-height:1.25;margin:0.5em 0 0.5em 0;color:#565757;font-weight:bold;}
39
+ h5 {
40
+ font-size:1.3em;
41
+ font-weight:normal;
42
+ color:#414240;
43
+ }
44
+
45
+ h6 {
46
+ font-size:1.3em;
47
+ font-weight:bold;
48
+ font-style:italic;
49
+ color:#434343;
50
+ margin:-20px 0 20px 0;
51
+ letter-spacing:-0.05em;
52
+ }
53
+ p {
54
+ margin:0 0 1.5em;
55
+ color:#414240;
56
+ }
57
+
58
+ /* **************** ALIGNMENTS ***************** */
59
+ .tcenter { text-align: center; }
60
+ .tright { text-align: right; }
61
+ .tleft { text-align: left; }
62
+ .tjustify { text-align: justify; }
63
+ .fright { float: right; }
64
+
65
+ /* **************** MARGINS ***************** */
66
+ .nomargin { margin: 0 !important; }
67
+ .mt30 { margin-top: 30px !important; }
68
+ .mt20 { margin-top: 20px !important; }
69
+ .mb20 { margin-bottom: 20px !important; }
70
+ .m20 { margin: 20px !important; }
71
+ .mt10 { margin-top: 10px !important; }
72
+ .ml10 { margin-left: 10px !important; }
73
+ .mr10 { margin-right: 10px !important; }
74
+ .mb10 { margin-bottom: 10px !important; }
75
+ .mb20 { margin-bottom: 20px !important; }
76
+ .mb30 { margin-bottom: 30px !important; }
77
+ .m10 { margin: 10px !important; }
78
+
79
+
80
+
81
+
82
+
@@ -0,0 +1,15 @@
1
+ # encoding: utf-8
2
+
3
+ require File.dirname(__FILE__) + '/../spec_helper'
4
+ # require 'vcr'
5
+ # require 'webmock/rspec'
6
+ require 'active_support/core_ext'
7
+
8
+ # VCR.configure do |c|
9
+ # c.ignore_localhost = false
10
+ # c.cassette_library_dir = File.dirname(__FILE__) + '/cassettes'
11
+ # c.hook_into :webmock
12
+ # c.default_cassette_options = { record: :new_episodes }
13
+ # c.configure_rspec_metadata!
14
+ # c.allow_http_connections_when_no_cassette = false
15
+ # end
@@ -0,0 +1,170 @@
1
+ # encoding: utf-8
2
+
3
+ require File.dirname(__FILE__) + '/../integration_helper'
4
+ require 'locomotive/steam/server'
5
+ require 'rack/test'
6
+
7
+ describe Locomotive::Steam::Server do
8
+
9
+ include Rack::Test::Methods
10
+
11
+ def app
12
+ run_server
13
+ end
14
+
15
+ it 'shows the index page' do
16
+
17
+ get '/index'
18
+
19
+ last_response.body.should =~ /Upcoming events/
20
+ end
21
+
22
+ it 'shows the 404 page' do
23
+ get '/void'
24
+ last_response.status.should eq(404)
25
+ last_response.body.should =~ /page not found/
26
+ end
27
+
28
+ it 'shows the 404 page with 200 status code when its called explicitly' do
29
+ get '/404'
30
+ last_response.status.should eq(200)
31
+ last_response.body.should =~ /page not found/
32
+ end
33
+
34
+ it 'shows content' do
35
+ get '/about-us/jane-doe'
36
+ last_response.body.should =~ /Lorem ipsum dolor sit amet/
37
+ end
38
+
39
+ it 'shows a content type template ' do
40
+ get '/songs/song-number-1'
41
+ last_response.body.should =~ /Song #1/
42
+ end
43
+
44
+ it 'renders a page under a templatized one' do
45
+ get '/songs/song-number-1/band'
46
+ last_response.body.should =~ /Song #1/
47
+ last_response.body.should =~ /Leader: Eddie/
48
+ end
49
+
50
+ it 'translates strings' do
51
+ get '/en'
52
+ last_response.body.should =~ /Powered by/
53
+ get '/fr'
54
+ last_response.body.should =~ /Propulsé par/
55
+ get '/nb'
56
+ last_response.body.should_not =~ /Powered by/
57
+ end
58
+
59
+ it 'provides translation in scopes' do
60
+ get '/'
61
+ last_response.body.should =~ /scoped_translation=.French./
62
+ end
63
+
64
+ it 'translates a page with link_to tags inside' do
65
+ get '/fr/notre-musique'
66
+ last_response.body.should =~ /<h3><a href="\/fr\/songs\/song-number-8">Song #8<\/a><\/h3>/
67
+ last_response.body.should =~ /Propulsé par/
68
+ end
69
+
70
+ it 'returns all the pages' do
71
+ get '/all'
72
+ last_response.body.should =~ /Home page/
73
+ last_response.body.should =~ /<li>Home page<\/li>/
74
+ last_response.body.should =~ /<li>John-doe<\/li>/
75
+ last_response.body.should =~ /<li>Songs<\/li>/
76
+ last_response.body.should =~ /<li>A song template<\/li>/
77
+ end
78
+
79
+ describe 'snippets' do
80
+
81
+ it 'includes a basic snippet' do
82
+ get '/'
83
+ last_response.body.should =~ /All photos are licensed under Creative Commons\./
84
+ end
85
+
86
+ it 'includes a snippet whose name is composed of dash' do
87
+ get '/'
88
+ last_response.body.should =~ /<p>A complicated one name indeed.<\/p>/
89
+ end
90
+
91
+ end
92
+
93
+ describe 'nav' do
94
+
95
+ subject { get '/all'; last_response.body }
96
+
97
+ it { should_not match(/<nav id="nav">/) }
98
+
99
+ it { should match(/<li id="about-us-link" class="link first"><a href="\/about-us">About Us<\/a><\/li>/) }
100
+
101
+ it { should match(/<li id="music-link" class="link"><a href="\/music">Music<\/a><\/li>/) }
102
+
103
+ it { should match(/<li id="store-link" class="link"><a href="\/store">Store<\/a><\/li>/) }
104
+
105
+ it { should match(/<li id="contact-link" class="link last"><a href="\/contact">Contact Us<\/a><\/li>/) }
106
+
107
+ it { should_not match(/<li id="events-link" class="link"><a href="\/events">Events<\/a><\/li>/) }
108
+
109
+ describe 'with wrapper' do
110
+
111
+ subject { get '/tags/nav'; last_response.body }
112
+
113
+ it { should match(/<nav id="nav">/) }
114
+
115
+ end
116
+
117
+ describe 'very deep' do
118
+
119
+ subject { get '/tags/nav_in_deep'; last_response.body }
120
+
121
+ it { should match(/<li id=\"john-doe-link\" class=\"link first last\">/) }
122
+
123
+ end
124
+
125
+ end
126
+
127
+ describe 'contents with_scope' do
128
+ subject { get '/grunge_bands'; last_response.body }
129
+
130
+ it { should match(/Layne/)}
131
+ it { should_not match(/Peter/) }
132
+ end
133
+
134
+ describe "pages with_scope" do
135
+ subject { get '/unlisted_pages'; last_response.body }
136
+ it { subject.should match(/Page to test the nav tag/)}
137
+ it { should_not match(/About Us/)}
138
+ end
139
+
140
+ describe 'theme assets' do
141
+
142
+ subject { get '/all'; last_response.body }
143
+
144
+ it { should match(/<link href="\/stylesheets\/application.css" media="screen" rel="stylesheet" type="text\/css" \/>/) }
145
+
146
+ it { should match(/<script src="\/javascripts\/application.js" type='text\/javascript'><\/script>/) }
147
+
148
+ it { should match(/<link rel="alternate" type="application\/atom\+xml" title="A title" href="\/foo\/bar" \/>/) }
149
+
150
+ end
151
+
152
+ describe 'session' do
153
+
154
+ subject { get '/contest'; last_response.body }
155
+
156
+ it { should match(/Your code is: HELLO WORLD/) }
157
+ it { should_not match(/You've already participated to that contest ! Come back later./) }
158
+
159
+ describe 'assign tag' do
160
+
161
+ subject { 2.times { get '/contest' }; last_response.body }
162
+
163
+ it { should_not match(/Your code is: HELLO WORLD/) }
164
+ it { should match(/You've already participated to that contest ! Come back later./) }
165
+
166
+ end
167
+
168
+ end
169
+
170
+ end
@@ -0,0 +1,111 @@
1
+ # encoding: utf-8
2
+
3
+ require File.dirname(__FILE__) + '/../integration_helper'
4
+ require 'locomotive/steam/server'
5
+ require 'rack/test'
6
+
7
+ describe 'ContactForm' do
8
+
9
+ include Rack::Test::Methods
10
+
11
+ def app
12
+ run_server
13
+ end
14
+
15
+ it 'renders the form' do
16
+ get '/contact'
17
+ last_response.body.should =~ /\/entry_submissions\/messages.json/
18
+ end
19
+
20
+ describe '#submit' do
21
+
22
+ let(:params) { {
23
+ 'entry' => { 'name' => 'John', 'email' => 'j@doe.net', 'message' => 'Bla bla' },
24
+ 'success_callback' => '/events',
25
+ 'error_callback' => '/contact' } }
26
+ let(:response) { post_contact_form(params, false) }
27
+ let(:status) { response.status }
28
+
29
+ describe 'with json request' do
30
+
31
+ let(:response) { post_contact_form(params, true) }
32
+ let(:entry) { JSON.parse(response.body)['message'] }
33
+
34
+ context 'when not valid' do
35
+
36
+ let(:params) { {} }
37
+
38
+ it 'returns an error status' do
39
+ response.status.should == 422
40
+ end
41
+
42
+ describe 'errors' do
43
+
44
+ subject { entry['errors'] }
45
+
46
+ it { should have_key_with_value('name', "can't not be blank") }
47
+
48
+ it { should have_key_with_value('email', "can't not be blank") }
49
+
50
+ it { should have_key_with_value('message', "can't not be blank") }
51
+
52
+ end
53
+
54
+ end
55
+
56
+ context 'when valid' do
57
+
58
+ it 'returns a success status' do
59
+ response.status.should == 200
60
+ end
61
+
62
+ end
63
+
64
+ end
65
+
66
+ describe 'with html request' do
67
+
68
+ context 'when not valid' do
69
+
70
+ let(:params) { { 'error_callback' => '/contact' } }
71
+
72
+ it 'returns a success status' do
73
+ response.status.should == 200
74
+ end
75
+
76
+ it 'displays errors' do
77
+ response.body.to_s.should =~ /can't not be blank/
78
+ end
79
+
80
+ end
81
+
82
+ context 'when valid' do
83
+
84
+ let(:response) { post_contact_form(params, false, true) }
85
+
86
+ it 'returns a success status' do
87
+ response.status.should == 200
88
+ end
89
+
90
+ it 'displays a success message' do
91
+ response.body.should =~ /Thank you John/
92
+ end
93
+
94
+ end
95
+
96
+ end
97
+
98
+ end
99
+
100
+ def post_contact_form(params, json = false, follow_redirect = false)
101
+ url = '/entry_submissions/messages'
102
+ url += '.json' if json
103
+ params = params.symbolize_keys if json
104
+ post url, params
105
+ if follow_redirect
106
+ follow_redirect!
107
+ end
108
+ last_response
109
+ end
110
+
111
+ end