- <%= f.label :email, t("devise_views.sessions.new.email_label") %>
<%= f.email_field :email, autofocus: true, placeholder: t("devise_views.sessions.new.email_label") %>
- <%= f.label :password, t("devise_views.sessions.new.password_label") %>
<%= f.password_field :password, autocomplete: "off", placeholder: t("devise_views.sessions.new.password_label") %>
- <%= f.label :remember_me do %>
- <%= f.check_box :remember_me %>
- <%= t("devise_views.sessions.new.remember_me") %>
- <% end %>
+ <%= f.check_box :remember_me, label: t("devise_views.sessions.new.remember_me") %>
<% end -%>
diff --git a/app/views/devise/unlocks/new.html.erb b/app/views/devise/unlocks/new.html.erb
index a92662664..d21209438 100644
--- a/app/views/devise/unlocks/new.html.erb
+++ b/app/views/devise/unlocks/new.html.erb
@@ -1,16 +1,23 @@
-
+
+
+
<%= t("devise_views.unlocks.new.title") %>
-<%= form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %>
- <%= devise_error_messages! %>
+ <%= form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %>
+ <%= render 'shared/errors', resource: resource %>
-
- <%= f.label :email, t("devise_views.unlocks.new.email_label") %>
- <%= f.email_field :email, autofocus: true %>
+
+ <%= f.email_field :email, autofocus: true,
+ label: t("devise_views.unlocks.new.email_label") %>
+
+
+
+ <%= f.submit t("devise_views.unlocks.new.submit") %>
+
+ <% end %>
+
+ <%= render "devise/shared/links" %>
+
+
-
-
- <%= f.submit t("devise_views.unlocks.new.submit") %>
-
-<% end %>
-
-<%= render "devise/shared/links" %>
+
\ No newline at end of file
diff --git a/app/views/shared/_errors.html.erb b/app/views/shared/_errors.html.erb
new file mode 100644
index 000000000..4e22c3038
--- /dev/null
+++ b/app/views/shared/_errors.html.erb
@@ -0,0 +1,10 @@
+<% if resource.errors.any? %>
+
+
+
+ <%= pluralize resource.errors.count, t("form.error"), t("form.errors") %>
+ <%= t("form.not_saved", resource: t("form.#{resource.class.to_s.downcase}")) %>
+
+
+
+<% end %>
\ No newline at end of file
diff --git a/config/i18n-tasks.yml b/config/i18n-tasks.yml
index 12c1c8022..5e6eb2899 100644
--- a/config/i18n-tasks.yml
+++ b/config/i18n-tasks.yml
@@ -89,6 +89,7 @@ search:
# - '{devise,simple_form}.*'
ignore_missing:
- 'unauthorized.*'
+ - 'errors.messages.blank'
## Consider these keys used:
ignore_unused:
diff --git a/config/locales/devise_views.en.yml b/config/locales/devise_views.en.yml
index cb9a20665..5eb4eccce 100644
--- a/config/locales/devise_views.en.yml
+++ b/config/locales/devise_views.en.yml
@@ -29,7 +29,6 @@ en:
edit:
title: "Change your password"
password_label: "New password"
- min_length: "%{min} characters minimum"
password_confirmation_label: "Confirm new password"
change_submit: "Change my password"
new:
@@ -56,7 +55,6 @@ en:
use_nickname_label: "Use nickname"
email_label: "Email"
password_label: "Password"
- min_length: "(%{min} characters minimum)"
password_confirmation_label: "Confirm password"
submit: "Sign up"
sessions:
diff --git a/config/locales/devise_views.es.yml b/config/locales/devise_views.es.yml
index 23ee16648..6c1997745 100644
--- a/config/locales/devise_views.es.yml
+++ b/config/locales/devise_views.es.yml
@@ -29,7 +29,6 @@ es:
edit:
title: "Cambia tu contraseña"
password_label: "Contraseña nueva"
- min_length: "Mínimo %{min} caracteres"
password_confirmation_label: "Confirmar contraseña nueva"
change_submit: "Cambiar mi contraseña"
new:
@@ -56,7 +55,6 @@ es:
use_nickname_label: "Usar pseudónimo"
email_label: "Email"
password_label: "Contraseña"
- min_length: "(mínimo %{min} caracteres)"
password_confirmation_label: "Confirmar contraseña"
submit: "Registrarse"
sessions:
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 3ff25f774..f1d7ba646 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -17,6 +17,13 @@ en:
moderation: Moderation
footer:
copyright: "Ayuntamiento de Madrid, 2015. All rights reserved"
+ form:
+ error: error
+ errors: errors
+ not_saved: "prohibited this %{resource} from being saved:"
+ accept_terms: I accept the privacy policy and the legal terms
+ user: account
+ debate: debate
debates:
index:
create_debate: Create a debate
@@ -41,9 +48,6 @@ en:
other: "%{count} votes"
votes_weighted_score: "Total: %{score}"
form:
- error: error
- errors: errors
- not_saved: "prohibited this debate from being saved:"
debate_title: Debate title
title_instructions: "SBe clear and precise with the title, but make it informative"
debate_text: Ellaborate your opinion
@@ -53,7 +57,6 @@ en:
Tag this idea. You can choose among our proposals on the list or add any other topic you want by
writing them separated by "," and then pressing "enter".
Some suggestions:
- accept_terms: I accept the privacy policy and the legal terms
show:
back_link: Back
comments_title: Comments
@@ -105,6 +108,7 @@ en:
simple_captcha:
placeholder: "Enter the image value"
label: "Enter the code in the box"
+ refresh_button_text: "Refresh"
message:
user: "secret code did not match with the image"
debate: "secret code did not match with the image"
diff --git a/config/locales/es.yml b/config/locales/es.yml
index d8970f035..45cfac0d5 100644
--- a/config/locales/es.yml
+++ b/config/locales/es.yml
@@ -17,6 +17,13 @@ es:
moderation: Moderar
footer:
copyright: "Ayuntamiento de Madrid, %{year}. Todos los derechos reservados"
+ form:
+ error: error
+ errors: errores
+ not_saved: "impidieron guardar %{resource}:"
+ accept_terms: Acepto la política de privacidad y el aviso legal
+ user: la cuenta
+ debate: el debate
debates:
index:
create_debate: Crea un debate
@@ -41,9 +48,6 @@ es:
other: "%{count} votos"
votes_weighted_score: "Total: %{score}"
form:
- error: error
- errors: errores
- not_saved: "impidieron guardar el debate:"
debate_title: Título del debate
title_instructions: "Sé claro y conciso a la hora de poner un título, pero recuerda que debe explicar bien tu idea, ¡es tu carta de entrada!"
debate_text: Describe tu opinión
@@ -53,7 +57,6 @@ es:
Etiqueta esta idea. Puedes elegir entre nuestras propuestas o introducir las que desees.
Para ello solo tienes que escribir las etiquetas que desees separadas por "," y pulsar "intro".
Algunas recomendaciones:
- accept_terms: Acepto la política de privacidad y el aviso legal
show:
back_link: Volver
comments_title: Comentarios
@@ -105,6 +108,7 @@ es:
simple_captcha:
placeholder: "Introduce el texto de la imagen"
label: "Introduce el texto en la caja"
+ refresh_button_text: "Refrescar"
message:
user: "el código secreto no coincide con la imagen"
debate: "el código secreto no coincide con la imagen"
diff --git a/spec/features/account_spec.rb b/spec/features/account_spec.rb
index 14a5310ba..f44114bf8 100644
--- a/spec/features/account_spec.rb
+++ b/spec/features/account_spec.rb
@@ -19,19 +19,6 @@ feature 'Account' do
expect(page).to have_selector(avatar('Manuela Colau'), count: 1)
end
- scenario "Failed Edit" do
- visit account_path
-
- fill_in 'account_first_name', with: ''
- fill_in 'account_last_name', with: ''
- fill_in 'account_nickname', with: ''
- click_button 'Save changes'
-
- expect(page).to have_content "2 errors prohibited this debate from being saved"
- expect(page).to have_content "First name can't be blank"
- expect(page).to have_content "First name can't be blank"
- end
-
scenario 'Edit' do
visit account_path
@@ -50,4 +37,22 @@ feature 'Account' do
expect(page).to have_selector("input[id='account_email_on_debate_comment'][value='1']")
expect(page).to have_selector("input[id='account_email_on_comment_reply'][value='1']")
end
+
+ scenario "Errors on edit" do
+ visit account_path
+
+ fill_in 'account_first_name', with: ''
+ click_button 'Save changes'
+
+ expect(page).to have_content error_message
+ end
+
+ scenario 'Errors editing credentials' do
+ visit account_path
+
+ click_link 'Change my credentials'
+ click_button 'Update'
+
+ expect(page).to have_content error_message
+ end
end
diff --git a/spec/features/comments_spec.rb b/spec/features/comments_spec.rb
index 93547ffd2..1d63fdb5e 100644
--- a/spec/features/comments_spec.rb
+++ b/spec/features/comments_spec.rb
@@ -10,14 +10,12 @@ feature 'Comments' do
visit debate_path(debate)
expect(page).to have_css('.comment', count: 3)
- expect(page).to have_content '3 Comments'
comment = Comment.first
within first('.comment') do
expect(page).to have_content comment.user.name
expect(page).to have_content time_ago_in_words(comment.created_at)
expect(page).to have_content comment.body
- expect(page).to have_selector(avatar(comment.user.name), count: 1)
end
end
@@ -51,6 +49,18 @@ feature 'Comments' do
end
end
+ scenario 'Errors on create', :js do
+ user = create(:user)
+ debate = create(:debate)
+
+ login_as(user)
+ visit debate_path(debate)
+
+ click_button 'Publish comment'
+
+ expect(page).to have_content "Can't be blank"
+ end
+
scenario 'Reply', :js do
citizen = create(:user, first_name: 'Ana')
manuela = create(:user, first_name: 'Manuela')
@@ -74,6 +84,23 @@ feature 'Comments' do
expect(page).to_not have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
end
+ scenario 'Errors on reply', :js do
+ user = create(:user)
+ debate = create(:debate)
+ comment = create(:comment, commentable: debate, user: user)
+
+ login_as(user)
+ visit debate_path(debate)
+
+ click_link "Reply"
+
+ within "#js-comment-form-comment_#{comment.id}" do
+ click_button 'Publish reply'
+ expect(page).to have_content "Can't be blank"
+ end
+
+ end
+
scenario "N replies", :js do
debate = create(:debate)
parent = create(:comment, commentable: debate)
@@ -86,11 +113,6 @@ feature 'Comments' do
visit debate_path(debate)
expect(page).to have_css(".comment.comment.comment.comment.comment.comment.comment.comment")
- expect(page).to have_content '8 Comments'
-
- within first('.comment') do
- expect(page).to have_content '1 Response'
- end
end
end
diff --git a/spec/features/debates_spec.rb b/spec/features/debates_spec.rb
index cb89e1c6b..94e902f03 100644
--- a/spec/features/debates_spec.rb
+++ b/spec/features/debates_spec.rb
@@ -25,7 +25,7 @@ feature 'Debates' do
expect(page).to have_content "Debate description"
expect(page).to have_content debate.author.name
expect(page).to have_content I18n.l(debate.created_at.to_date)
- expect(page).to have_selector(avatar(debate.author.name), count: 1)
+ expect(page).to have_selector(avatar(debate.author.name))
within('.social-share-button') do
expect(page.all('a').count).to be(3) # Twitter, Facebook, Google+
@@ -92,6 +92,15 @@ feature 'Debates' do
end
end
+ scenario 'Errors on create' do
+ author = create(:user)
+ login_as(author)
+
+ visit new_debate_path
+ click_button 'Create Debate'
+ expect(page).to have_content /error/
+ end
+
scenario 'JS injection is prevented but safe html is respected' do
author = create(:user)
login_as(author)
@@ -202,6 +211,17 @@ feature 'Debates' do
expect(page).to have_content "Let's..."
end
+ scenario 'Errors on update' do
+ debate = create(:debate)
+ login_as(debate.author)
+
+ visit edit_debate_path(debate)
+ fill_in 'debate_title', with: ""
+ click_button 'Update Debate'
+
+ expect(page).to have_content error_message
+ end
+
scenario 'Captcha is required to update a debate' do
debate = create(:debate)
login_as(debate.author)
@@ -278,15 +298,6 @@ feature 'Debates' do
expect(page).not_to have_content '+'
end
end
-
- scenario 'Debate#show shows the full tag list' do
- visit debate_path(debate)
-
- within("#debate-#{debate.id}") do
- all_tags.each do |tag|
- expect(page).to have_content tag
- end
- end
- end
end
+
end
diff --git a/spec/features/users_spec.rb b/spec/features/users_spec.rb
index be67c3e27..74a050578 100644
--- a/spec/features/users_spec.rb
+++ b/spec/features/users_spec.rb
@@ -23,6 +23,14 @@ feature 'Users' do
expect(page).to have_content "Your email address has been successfully confirmed"
end
+ scenario 'Errors on sign up' do
+ visit '/'
+ click_link 'Sign up'
+ click_button 'Sign up'
+
+ expect(page).to have_content error_message
+ end
+
scenario 'Sign in' do
user = create(:user, email: 'manuela@madrid.es', password: 'judgementday')
diff --git a/spec/support/common_actions.rb b/spec/support/common_actions.rb
index 7647c9a64..32252aa1a 100644
--- a/spec/support/common_actions.rb
+++ b/spec/support/common_actions.rb
@@ -74,4 +74,8 @@ module CommonActions
SCRIPT
end
+ def error_message
+ /\d errors? prohibited this (.*) from being saved:/
+ end
+
end