locomotivecms_steam 1.2.1 → 1.3.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/Gemfile +3 -2
  4. data/Gemfile.lock +57 -50
  5. data/LICENSE +1 -1
  6. data/README.md +1 -1
  7. data/config/locales/nl.yml +2 -2
  8. data/lib/locomotive/steam/adapters/filesystem/yaml_loaders/content_entry.rb +8 -0
  9. data/lib/locomotive/steam/adapters/memory/condition.rb +1 -1
  10. data/lib/locomotive/steam/configuration.rb +1 -1
  11. data/lib/locomotive/steam/decorators/template_decorator.rb +1 -1
  12. data/lib/locomotive/steam/entities/content_entry.rb +17 -0
  13. data/lib/locomotive/steam/entities/content_type.rb +1 -0
  14. data/lib/locomotive/steam/entities/content_type_field.rb +1 -0
  15. data/lib/locomotive/steam/entities/editable_element.rb +4 -0
  16. data/lib/locomotive/steam/errors.rb +35 -5
  17. data/lib/locomotive/steam/initializers/sprockets.rb +6 -80
  18. data/lib/locomotive/steam/liquid/drops/page.rb +9 -2
  19. data/lib/locomotive/steam/liquid/filters/date.rb +109 -0
  20. data/lib/locomotive/steam/liquid/tags/action.rb +6 -1
  21. data/lib/locomotive/steam/liquid/tags/authorize.rb +65 -0
  22. data/lib/locomotive/steam/liquid/tags/snippet.rb +10 -2
  23. data/lib/locomotive/steam/liquid/template.rb +3 -1
  24. data/lib/locomotive/steam/middlewares/auth.rb +187 -0
  25. data/lib/locomotive/steam/middlewares/redirection.rb +24 -0
  26. data/lib/locomotive/steam/middlewares/renderer.rb +20 -3
  27. data/lib/locomotive/steam/middlewares/sitemap.rb +3 -1
  28. data/lib/locomotive/steam/middlewares/templatized_page.rb +1 -6
  29. data/lib/locomotive/steam/middlewares/thread_safe.rb +19 -0
  30. data/lib/locomotive/steam/middlewares/url_redirection.rb +14 -1
  31. data/lib/locomotive/steam/repositories.rb +5 -1
  32. data/lib/locomotive/steam/repositories/content_entry_repository.rb +1 -1
  33. data/lib/locomotive/steam/repositories/content_type_field_repository.rb +4 -0
  34. data/lib/locomotive/steam/server.rb +2 -0
  35. data/lib/locomotive/steam/services.rb +9 -1
  36. data/lib/locomotive/steam/services/action_service.rb +26 -7
  37. data/lib/locomotive/steam/services/asset_host_service.rb +6 -1
  38. data/lib/locomotive/steam/services/auth_service.rb +105 -0
  39. data/lib/locomotive/steam/services/content_entry_service.rb +14 -0
  40. data/lib/locomotive/steam/services/external_api_service.rb +59 -25
  41. data/lib/locomotive/steam/services/liquid_parser_service.rb +5 -1
  42. data/lib/locomotive/steam/services/page_redirection_service.rb +29 -0
  43. data/lib/locomotive/steam/version.rb +1 -1
  44. data/locomotivecms_steam.gemspec +18 -16
  45. data/spec/fixtures/default/app/content_types/accounts.yml +59 -0
  46. data/spec/fixtures/default/app/content_types/songs.yml +2 -1
  47. data/spec/fixtures/default/app/views/pages/about_us/john_doe.fr.liquid.haml +5 -1
  48. data/spec/fixtures/default/app/views/pages/about_us/john_doe.liquid.haml +1 -1
  49. data/spec/fixtures/default/app/views/pages/account/forgot_password.liquid +39 -0
  50. data/spec/fixtures/default/app/views/pages/account/me.liquid +15 -0
  51. data/spec/fixtures/default/app/views/pages/account/reset_password.liquid +42 -0
  52. data/spec/fixtures/default/app/views/pages/account/sign_in.liquid +49 -0
  53. data/spec/fixtures/default/app/views/pages/all.liquid.haml +1 -1
  54. data/spec/fixtures/default/app/views/pages/emails/reset_password.liquid +15 -0
  55. data/spec/fixtures/default/app/views/pages/songs/template.liquid.haml +1 -1
  56. data/spec/fixtures/default/config/metafields_schema.yml +10 -0
  57. data/spec/fixtures/default/config/site.yml +5 -0
  58. data/spec/fixtures/default/config/translations.yml +25 -1
  59. data/spec/fixtures/default/data/accounts.yml +15 -0
  60. data/spec/fixtures/mongodb/locomotive_accounts.bson +0 -0
  61. data/spec/fixtures/mongodb/locomotive_accounts.metadata.json +1 -1
  62. data/spec/fixtures/mongodb/locomotive_activities.bson +0 -0
  63. data/spec/fixtures/mongodb/locomotive_activities.metadata.json +1 -1
  64. data/spec/fixtures/mongodb/locomotive_content_assets.bson +0 -0
  65. data/spec/fixtures/mongodb/locomotive_content_assets.metadata.json +1 -1
  66. data/spec/fixtures/mongodb/locomotive_content_entries.bson +0 -0
  67. data/spec/fixtures/mongodb/locomotive_content_entries.metadata.json +1 -1
  68. data/spec/fixtures/mongodb/locomotive_content_types.bson +0 -0
  69. data/spec/fixtures/mongodb/locomotive_content_types.metadata.json +1 -1
  70. data/spec/fixtures/mongodb/locomotive_pages.bson +0 -0
  71. data/spec/fixtures/mongodb/locomotive_pages.metadata.json +1 -1
  72. data/spec/fixtures/mongodb/locomotive_sites.bson +0 -0
  73. data/spec/fixtures/mongodb/locomotive_sites.metadata.json +1 -1
  74. data/spec/fixtures/mongodb/locomotive_snippets.bson +0 -0
  75. data/spec/fixtures/mongodb/locomotive_snippets.metadata.json +1 -1
  76. data/spec/fixtures/mongodb/locomotive_theme_assets.bson +0 -0
  77. data/spec/fixtures/mongodb/locomotive_theme_assets.metadata.json +1 -1
  78. data/spec/fixtures/mongodb/locomotive_translations.bson +0 -0
  79. data/spec/fixtures/mongodb/locomotive_translations.metadata.json +1 -1
  80. data/spec/integration/repositories/content_entry_repository_spec.rb +1 -1
  81. data/spec/integration/repositories/content_type_repository_spec.rb +1 -1
  82. data/spec/integration/repositories/page_repository_spec.rb +3 -3
  83. data/spec/integration/repositories/theme_asset_repository_spec.rb +1 -1
  84. data/spec/integration/repositories/translation_repository_spec.rb +1 -1
  85. data/spec/integration/server/auth_spec.rb +196 -0
  86. data/spec/integration/server/basic_spec.rb +18 -0
  87. data/spec/integration/server/nav_spec.rb +1 -1
  88. data/spec/integration/server/sitemap_spec.rb +1 -1
  89. data/spec/integration/services/content_entry_service_spec.rb +1 -1
  90. data/spec/integration/services/external_api_service_spec.rb +9 -0
  91. data/spec/support/helpers.rb +1 -1
  92. data/spec/unit/adapters/filesystem/yaml_loaders/content_entry_spec.rb +17 -5
  93. data/spec/unit/adapters/filesystem/yaml_loaders/content_type_spec.rb +4 -4
  94. data/spec/unit/adapters/filesystem/yaml_loaders/page_spec.rb +7 -7
  95. data/spec/unit/adapters/filesystem/yaml_loaders/site_spec.rb +1 -1
  96. data/spec/unit/adapters/filesystem/yaml_loaders/translation_spec.rb +1 -1
  97. data/spec/unit/entities/content_entry_spec.rb +10 -0
  98. data/spec/unit/errors_spec.rb +2 -2
  99. data/spec/unit/initializers/sprockets_spec.rb +0 -14
  100. data/spec/unit/liquid/drops/page_spec.rb +3 -2
  101. data/spec/unit/liquid/filters/date_spec.rb +219 -0
  102. data/spec/unit/liquid/tags/action_spec.rb +9 -0
  103. data/spec/unit/liquid/tags/authorize_spec.rb +51 -0
  104. data/spec/unit/liquid/tags/link_to_spec.rb +1 -1
  105. data/spec/unit/liquid/tags/paginate_spec.rb +1 -1
  106. data/spec/unit/liquid/tags/snippet_spec.rb +10 -0
  107. data/spec/unit/middlewares/auth_spec.rb +31 -0
  108. data/spec/unit/middlewares/redirection_spec.rb +37 -0
  109. data/spec/unit/middlewares/url_redirection_spec.rb +20 -1
  110. data/spec/unit/services/action_service_spec.rb +57 -1
  111. data/spec/unit/services/asset_host_service_spec.rb +15 -0
  112. data/spec/unit/services/auth_service_spec.rb +156 -0
  113. data/spec/unit/services/external_api_service_spec.rb +22 -0
  114. data/spec/unit/services/page_redirection_service_spec.rb +49 -0
  115. metadata +96 -40
  116. data/CHANGELOG.md +0 -29
  117. data/spec/fixtures/mongodb/system.indexes.bson +0 -0
@@ -11,6 +11,6 @@ published: true
11
11
  {% endfor %}
12
12
  </ul>
13
13
 
14
- <!-- TEST -->{{ site.index.children | map: 'title' | join: " - " }}<!-- TEST -->
14
+ <!-- TEST -->{{ site.index.children | map: 'title' | sort | join: " - " }}<!-- TEST -->
15
15
 
16
16
  {% endblock %}
@@ -0,0 +1,15 @@
1
+ ---
2
+ title: Reset password instructions
3
+ listed: false
4
+ published: true
5
+ handle: reset_password_instructions
6
+ ---
7
+ Hello {{ account.name }},
8
+
9
+ To reset your password please follow the link below:
10
+
11
+ {{ reset_password_url }}
12
+
13
+ If you need help or have any questions, please visit https://www.locomotivecms.com
14
+ Thanks!
15
+ Locomotive
@@ -15,4 +15,4 @@ handle: a-song-template
15
15
  #content_type_size{content_type_size: "{{ page.content_type.size }}"}
16
16
  #content_type_count{content_type_count: "{{ page.content_type.count }}"}
17
17
 
18
- {% endblock %}
18
+ {% endblock %}
@@ -31,3 +31,13 @@ github:
31
31
  min: 0
32
32
  max: 3600
33
33
 
34
+ smtp:
35
+ fields:
36
+ address:
37
+ type: string
38
+ localhost:
39
+ type: string
40
+ user_name:
41
+ type: string
42
+ password:
43
+ type: string
@@ -32,3 +32,8 @@ metafields:
32
32
  github:
33
33
  api_url: https://api.github.com/repos/vmg/redcarpet/issues?state=closed
34
34
  expires_in: 42
35
+ smtp:
36
+ address: localhost
37
+ port: 25
38
+ user_name: user
39
+ password: password
@@ -1,3 +1,27 @@
1
1
  powered_by:
2
2
  en: Powered by
3
- fr: Propulsé par
3
+ fr: Propulsé par
4
+
5
+ auth_wrong_credentials:
6
+ en: Your email and/or password are incorrect
7
+ fr: Votre email et/ou mot de passe sont incorrects
8
+
9
+ auth_signed_out:
10
+ en: You've been signed out
11
+ fr: Vous avez été déconnecté(e)
12
+
13
+ auth_wrong_email:
14
+ en: Your email is unknown
15
+ fr: Votre email est inconnu
16
+
17
+ auth_reset_password_instructions_sent:
18
+ en: "The instructions for changing your password have been emailed to you"
19
+ fr: "Les instructions pour modifier votre mot de passe viennent de vous être envoyées"
20
+
21
+ auth_invalid_token:
22
+ en: "The reset token is not valid anymore"
23
+ fr: "Le token de re-initialisation du mot de passe n'est plus valide"
24
+
25
+ auth_password_too_short:
26
+ en: "Your password is too short"
27
+ fr: "Votre mot de passe est trop court"
@@ -0,0 +1,15 @@
1
+ - "John":
2
+ email: 'john@doe.net'
3
+ password: 'easyone'
4
+
5
+ - "Jane":
6
+ email: 'john@doe.net'
7
+ password: 'anotherone'
8
+ _auth_reset_token: '420000000000000'
9
+ _auth_reset_sent_at: '2020-01-01T15:00:00.000Z'
10
+
11
+ - "Mickey":
12
+ email: 'mickey@doe.net'
13
+ password: 'anotherone'
14
+ _auth_reset_token: '420000000000001'
15
+ _auth_reset_sent_at: '2016-01-01T15:00:00.000Z'
@@ -1 +1 @@
1
- { "indexes" : [ { "v" : 1, "key" : { "_id" : 1 }, "name" : "_id_", "ns" : "locomotive_engine_wagon_dev.locomotive_accounts" } ] }
1
+ {"options":{},"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"locomotive_engine_dev.locomotive_accounts"}]}
@@ -1 +1 @@
1
- { "indexes" : [ { "v" : 1, "key" : { "_id" : 1 }, "name" : "_id_", "ns" : "locomotive_engine_wagon_dev.locomotive_activities" } ] }
1
+ {"options":{},"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"locomotive_engine_dev.locomotive_activities"}]}
@@ -1 +1 @@
1
- { "indexes" : [ { "v" : 1, "key" : { "_id" : 1 }, "name" : "_id_", "ns" : "locomotive_engine_wagon_dev.locomotive_content_assets" } ] }
1
+ {"options":{},"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"locomotive_engine_dev.locomotive_content_assets"}]}
@@ -1 +1 @@
1
- { "indexes" : [ { "v" : 1, "key" : { "_id" : 1 }, "name" : "_id_", "ns" : "locomotive_engine_wagon_dev.locomotive_content_entries" } ] }
1
+ {"options":{},"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"locomotive_engine_dev.locomotive_content_entries"}]}
@@ -1 +1 @@
1
- { "indexes" : [ { "v" : 1, "key" : { "_id" : 1 }, "name" : "_id_", "ns" : "locomotive_engine_wagon_dev.locomotive_content_types" } ] }
1
+ {"options":{},"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"locomotive_engine_dev.locomotive_content_types"}]}
@@ -1 +1 @@
1
- { "indexes" : [ { "v" : 1, "key" : { "_id" : 1 }, "name" : "_id_", "ns" : "locomotive_engine_wagon_dev.locomotive_pages" } ] }
1
+ {"options":{},"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"locomotive_engine_dev.locomotive_pages"}]}
@@ -1 +1 @@
1
- { "indexes" : [ { "v" : 1, "key" : { "_id" : 1 }, "name" : "_id_", "ns" : "locomotive_engine_wagon_dev.locomotive_sites" } ] }
1
+ {"options":{},"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"locomotive_engine_dev.locomotive_sites"}]}
@@ -1 +1 @@
1
- { "indexes" : [ { "v" : 1, "key" : { "_id" : 1 }, "name" : "_id_", "ns" : "locomotive_engine_wagon_dev.locomotive_snippets" } ] }
1
+ {"options":{},"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"locomotive_engine_dev.locomotive_snippets"}]}
@@ -1 +1 @@
1
- { "indexes" : [ { "v" : 1, "key" : { "_id" : 1 }, "name" : "_id_", "ns" : "locomotive_engine_wagon_dev.locomotive_theme_assets" } ] }
1
+ {"options":{},"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"locomotive_engine_dev.locomotive_theme_assets"}]}
@@ -1 +1 @@
1
- { "indexes" : [ { "v" : 1, "key" : { "_id" : 1 }, "name" : "_id_", "ns" : "locomotive_engine_wagon_dev.locomotive_translations" } ] }
1
+ {"options":{},"indexes":[{"v":1,"key":{"_id":1},"name":"_id_","ns":"locomotive_engine_dev.locomotive_translations"}]}
@@ -116,7 +116,7 @@ describe Locomotive::Steam::ContentEntryRepository do
116
116
 
117
117
  let(:site_id) { mongodb_site_id }
118
118
  let(:adapter) { Locomotive::Steam::MongoDBAdapter.new(database: 'steam_test', hosts: ['127.0.0.1:27017']) }
119
- let(:entry_id) { BSON::ObjectId.from_string('5610310b87f6431588000029') }
119
+ let(:entry_id) { BSON::ObjectId.from_string('5829ffa087f6435971756881') }
120
120
 
121
121
  end
122
122
 
@@ -13,7 +13,7 @@ describe Locomotive::Steam::ContentTypeRepository do
13
13
 
14
14
  describe '#all' do
15
15
  subject { repository.all }
16
- it { expect(subject.size).to eq 5 }
16
+ it { expect(subject.size).to eq 6 }
17
17
  end
18
18
 
19
19
  describe '#by_slug' do
@@ -14,7 +14,7 @@ describe Locomotive::Steam::PageRepository do
14
14
  describe '#all' do
15
15
  let(:conditions) { {} }
16
16
  subject { repository.all(conditions) }
17
- it { expect(subject.size).to eq 26 }
17
+ it { expect(subject.size).to eq 33 }
18
18
 
19
19
  context 'with conditions' do
20
20
  let(:conditions) { { fullpath: 'index', 'slug.ne' => '404' } }
@@ -34,7 +34,7 @@ describe Locomotive::Steam::PageRepository do
34
34
 
35
35
  describe '#only_handle_and_fullpath' do
36
36
  subject { repository.only_handle_and_fullpath }
37
- it { expect(subject.size).to eq 3 }
37
+ it { expect(subject.size).to eq 8 }
38
38
  end
39
39
 
40
40
  describe '#by_fullpath' do
@@ -78,7 +78,7 @@ describe Locomotive::Steam::PageRepository do
78
78
  describe '#children_of' do
79
79
  let(:page) { repository.root }
80
80
  subject { repository.children_of(page) }
81
- it { expect(subject.size).to eq 15 }
81
+ it { expect(subject.size).to eq 17 }
82
82
  end
83
83
 
84
84
  describe '#editable_element_for' do
@@ -26,7 +26,7 @@ describe Locomotive::Steam::ThemeAssetRepository do
26
26
  describe '#checksums' do
27
27
  subject { repository.checksums }
28
28
  it { expect(subject.size).to eq 16 }
29
- it { expect(subject['stylesheets/application.css']).to eq '3bacf4c2b7877e230e6990d72dae7724' }
29
+ it { expect(subject['stylesheets/application.css']).to eq 'f431407c21db339b7759c2d7ded2553f' }
30
30
  end
31
31
 
32
32
  end
@@ -13,7 +13,7 @@ describe Locomotive::Steam::TranslationRepository do
13
13
 
14
14
  describe '#all' do
15
15
  subject { repository.all }
16
- it { expect(subject.size).to eq 1 }
16
+ it { expect(subject.size).to eq 7 }
17
17
  end
18
18
 
19
19
  describe '#by_key' do
@@ -0,0 +1,196 @@
1
+ require File.dirname(__FILE__) + '/../integration_helper'
2
+
3
+ describe 'Authentication' do
4
+
5
+ include Rack::Test::Methods
6
+
7
+ def app
8
+ run_server
9
+ end
10
+
11
+ describe 'sign in action' do
12
+
13
+ it 'renders the form' do
14
+ get '/account/sign-in'
15
+ expect(last_response.body).to include '/account/sign-in'
16
+ expect(last_response.body).not_to include "You've been signed out"
17
+ end
18
+
19
+ describe 'press the sign in button' do
20
+
21
+ let(:params) { {
22
+ auth_action: 'sign_in',
23
+ auth_content_type: 'accounts',
24
+ auth_id_field: 'email',
25
+ auth_password_field: 'password',
26
+ auth_id: 'john@doe.net',
27
+ auth_password: 'easyone',
28
+ auth_callback: '/account/me'
29
+ } }
30
+
31
+ it 'redirects to the callback' do
32
+ sign_in(params)
33
+ expect(last_response.status).to eq 301
34
+ expect(last_response.location).to eq '/account/me'
35
+ end
36
+
37
+ it 'displays the profile page as described in the params' do
38
+ sign_in(params, true)
39
+ expect(last_response.body).to include "My name is John and I'm logged in!"
40
+ end
41
+
42
+ context 'wrong credentials' do
43
+
44
+ let(:params) { {
45
+ auth_action: 'sign_in',
46
+ auth_content_type: 'accounts',
47
+ auth_id_field: 'email',
48
+ auth_password_field: 'password',
49
+ auth_id: 'john@doe.net',
50
+ auth_password: 'dontrememberit',
51
+ auth_callback: '/account/me'
52
+ } }
53
+
54
+ it 'renders the sign in page with an error message' do
55
+ sign_in(params)
56
+ expect(last_response.status).to eq 200
57
+ expect(last_response.body).to include '/account/sign-in'
58
+ expect(last_response.body).to include 'Your email and/or password are incorrect'
59
+ end
60
+
61
+ end
62
+
63
+ def sign_in(params, follow_redirect = false)
64
+ post '/account/sign-in', params
65
+ follow_redirect! if follow_redirect
66
+ last_response
67
+ end
68
+
69
+ end
70
+
71
+ end
72
+
73
+ describe 'sign out action' do
74
+
75
+ let(:params) { {
76
+ auth_action: 'sign_out',
77
+ auth_content_type: 'accounts'
78
+ } }
79
+
80
+ let(:rack_session) { {
81
+ 'authenticated_entry_type' => 'accounts',
82
+ 'authenticated_entry_id' => 'john'
83
+ } }
84
+
85
+ it 'displays the profile page as described in the params' do
86
+ post '/account/sign-in', params, { 'rack.session' => rack_session }
87
+ expect(last_response.body).to include "You've been signed out"
88
+ expect(last_response.body).not_to include "You're already authenticated!"
89
+ end
90
+
91
+ end
92
+
93
+ describe 'forgot password action' do
94
+
95
+ let(:email) { '' }
96
+
97
+ let(:params) { {
98
+ auth_action: 'forgot_password',
99
+ auth_content_type: 'accounts',
100
+ auth_id_field: 'email',
101
+ auth_id: email,
102
+ auth_reset_password_url: 'http://acme.com/account/reset-password',
103
+ auth_callback: '/account/sign-in',
104
+ auth_email_from: 'support@acme.com',
105
+ auth_email_handle: 'reset_password_instructions',
106
+ auth_email_smtp_address: 'smtp.nowhere.net',
107
+ auth_email_smtp_user_name: 'jane',
108
+ auth_email_smtp_password: 'easyone'
109
+ } }
110
+
111
+ it 'renders the forgot password page with an error message' do
112
+ post '/account/forgot-password', params
113
+ expect(last_response.status).to eq 200
114
+ expect(last_response.body).to include 'Forgot your password'
115
+ expect(last_response.body).to include 'Your email is unknown'
116
+ end
117
+
118
+ context 'with an known email' do
119
+
120
+ let(:email) { 'john@doe.net' }
121
+
122
+ it 'sends an email to the account' do
123
+ post '/account/forgot-password', params
124
+ expect(last_response.status).to eq 200
125
+ expect(last_response.body).to include "The instructions for changing your password have been emailed to you"
126
+ end
127
+
128
+ end
129
+
130
+ end
131
+
132
+ describe 'reset password action' do
133
+
134
+ let(:token) { '' }
135
+ let(:new_password) { 'newone!' }
136
+
137
+ let(:params) { {
138
+ auth_action: 'reset_password',
139
+ auth_content_type: 'accounts',
140
+ auth_password_field: 'password',
141
+ auth_password: new_password,
142
+ auth_reset_token: token,
143
+ auth_callback: '/account/me'
144
+ } }
145
+
146
+ it 'renders the reset password page with an error message' do
147
+ post '/account/reset-password', params
148
+ expect(last_response.status).to eq 200
149
+ expect(last_response.body).to include 'Change your password'
150
+ expect(last_response.body).to include 'The reset token is not valid anymore'
151
+ end
152
+
153
+ context 'with an expired token' do
154
+
155
+ let(:token) { '420000000000001' }
156
+
157
+ it 'renders the reset password page with an error message' do
158
+ post '/account/reset-password', params
159
+ expect(last_response.status).to eq 200
160
+ expect(last_response.body).to include 'Change your password'
161
+ expect(last_response.body).to include 'The reset token is not valid anymore'
162
+ end
163
+
164
+ end
165
+
166
+ context 'with a valid token' do
167
+
168
+ let(:token) { '420000000000000' }
169
+
170
+ it 'sends an email to the account' do
171
+ post '/account/reset-password', params
172
+ expect(last_response.status).to eq 301
173
+ follow_redirect!
174
+ expect(last_response.body).to include "My name is Jane and I'm logged in!"
175
+ end
176
+
177
+ context 'with a too short password' do
178
+
179
+ let(:new_password) { 'short' }
180
+
181
+ it 'renders the reset password page with an error message' do
182
+ post '/account/reset-password', params
183
+ expect(last_response.status).to eq 200
184
+ expect(last_response.body).to include 'Change your password'
185
+ expect(last_response.body).to include 'Your password is too short'
186
+ end
187
+
188
+ end
189
+
190
+ end
191
+
192
+ end
193
+
194
+ end
195
+
196
+
@@ -173,4 +173,22 @@ describe Locomotive::Steam::Server do
173
173
 
174
174
  end
175
175
 
176
+ describe 'page with parse or render errors' do
177
+
178
+ context 'liquid parsing error' do
179
+
180
+ subject { get '/about-us/john-doe'; last_response.body }
181
+ it { expect { subject }.to raise_error(Locomotive::Steam::RenderError, "Liquid syntax error (line 1): Syntax Error in 'for loop' - Valid syntax: for [item] in [collection]") }
182
+
183
+ end
184
+
185
+ context 'rendering error' do
186
+
187
+ subject { get '/fr/a-notre-sujet/jean-personne'; last_response.body }
188
+ it { expect { subject }.to raise_error(Locomotive::Steam::ActionError, "identifier 'foo' undefined") }
189
+
190
+ end
191
+
192
+ end
193
+
176
194
  end