forked from fixin.me/fixin.me
Fix translations and enable i18n testing
This commit is contained in:
parent
3509cd409c
commit
e4f595a329
@ -73,7 +73,7 @@ module ApplicationHelper
|
|||||||
|
|
||||||
content_tag :div, class: "right" do
|
content_tag :div, class: "right" do
|
||||||
if current_user.at_least(:admin)
|
if current_user.at_least(:admin)
|
||||||
image_link_to t('.users'), "account-multiple-outline", users_path, class: "tab",
|
image_link_to t(".users"), "account-multiple-outline", users_path, class: "tab",
|
||||||
current: :active
|
current: :active
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -13,9 +13,10 @@
|
|||||||
<div class="app-menu">
|
<div class="app-menu">
|
||||||
<% if user_signed_in? %>
|
<% if user_signed_in? %>
|
||||||
<% if current_user_disguised? %>
|
<% if current_user_disguised? %>
|
||||||
<%= image_button_to t(:revert), "incognito-off", revert_users_path %>
|
<%= image_button_to t(".revert"), "incognito-off", revert_users_path %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= image_button_to t(:sign_out), "logout", destroy_user_session_path, method: :delete %>
|
<%= image_button_to t(".sign_out"), "logout", destroy_user_session_path,
|
||||||
|
method: :delete %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= image_link_to current_user.email, "account-wrench-outline",
|
<%= image_link_to current_user.email, "account-wrench-outline",
|
||||||
edit_user_registration_path, current: :hide %>
|
edit_user_registration_path, current: :hide %>
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
<%= tabular_form_for resource, url: user_password_path, html: { method: :put } do |f| %>
|
<%= tabular_form_for resource, url: user_password_path, html: { method: :put } do |f| %>
|
||||||
<%= f.hidden_field :reset_password_token, label: false %>
|
<%= f.hidden_field :reset_password_token, label: false %>
|
||||||
|
|
||||||
<%= f.password_field :password, label: t('.new_password'),
|
<%= f.password_field :password, label: t(".new_password"),
|
||||||
required: true, size: 30, autofocus: true, autocomplete: "new-password",
|
required: true, size: 30, autofocus: true, autocomplete: "new-password",
|
||||||
hint: ("(#{@minimum_password_length} characters minimum)" if @minimum_password_length) %>
|
hint: ("(#{@minimum_password_length} characters minimum)" if @minimum_password_length) %>
|
||||||
<%= f.password_field :password_confirmation, label: t('.password_confirmation'),
|
<%= f.password_field :password_confirmation, label: t(".password_confirmation"),
|
||||||
required: true, size: 30, autocomplete: "new-password" %>
|
required: true, size: 30, autocomplete: "new-password" %>
|
||||||
|
|
||||||
<%= f.submit t('.update_password') %>
|
<%= f.submit t(".update_password") %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -21,9 +21,9 @@
|
|||||||
<%= f.select :status, User.statuses, readonly: true %>
|
<%= f.select :status, User.statuses, readonly: true %>
|
||||||
|
|
||||||
<%= f.password_field :password, size: 30, autocomplete: "off",
|
<%= f.password_field :password, size: 30, autocomplete: "off",
|
||||||
hint: t('.blank_password_hint_html',
|
hint: t(".blank_password_hint_html",
|
||||||
subhint: t('.minimum_length_hint_html', count: @minimum_password_length)) %>
|
subhint: t(".minimum_length_hint_html", count: @minimum_password_length)) %>
|
||||||
<%= f.password_field :password_confirmation, size: 30, autocomplete: "off" %>
|
<%= f.password_field :password_confirmation, size: 30, autocomplete: "off" %>
|
||||||
|
|
||||||
<%= f.submit t('.update') %>
|
<%= f.submit t(".update") %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<%= f.password_field :password, required: true, size: 30, minlength: @minimum_password_length,
|
<%= f.password_field :password, required: true, size: 30, minlength: @minimum_password_length,
|
||||||
autocomplete: "new-password",
|
autocomplete: "new-password",
|
||||||
hint: ("(#{@minimum_password_length} characters minimum)" if @minimum_password_length) %>
|
hint: ("(#{@minimum_password_length} characters minimum)" if @minimum_password_length) %>
|
||||||
<%= f.password_field :password_confirmation, label: t('.password_confirmation'),
|
<%= f.password_field :password_confirmation, label: t(".password_confirmation"),
|
||||||
required: true, size: 30, autocomplete: "new-password" %>
|
required: true, size: 30, autocomplete: "new-password" %>
|
||||||
|
|
||||||
<%= f.submit t(:register) %>
|
<%= f.submit t(:register) %>
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<%= f.password_field :password, required: true, size: 30, autocomplete: "current-password" %>
|
<%= f.password_field :password, required: true, size: 30, autocomplete: "current-password" %>
|
||||||
|
|
||||||
<% if devise_mapping.rememberable? %>
|
<% if devise_mapping.rememberable? %>
|
||||||
<%= f.check_box :remember_me, label: t('.remember_me') %>
|
<%= f.check_box :remember_me, label: t(".remember_me") %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= f.submit t(:sign_in) %>
|
<%= f.submit t(:sign_in) %>
|
||||||
|
@ -52,7 +52,7 @@ Rails.application.configure do
|
|||||||
config.active_support.disallowed_deprecation_warnings = []
|
config.active_support.disallowed_deprecation_warnings = []
|
||||||
|
|
||||||
# Raises error for missing translations.
|
# Raises error for missing translations.
|
||||||
# config.i18n.raise_on_missing_translations = true
|
config.i18n.raise_on_missing_translations = true
|
||||||
|
|
||||||
# Annotate rendered view with file names.
|
# Annotate rendered view with file names.
|
||||||
# config.action_view.annotate_rendered_view_with_filenames = true
|
# config.action_view.annotate_rendered_view_with_filenames = true
|
||||||
|
@ -35,13 +35,12 @@ en:
|
|||||||
layouts:
|
layouts:
|
||||||
application:
|
application:
|
||||||
revert: Revert
|
revert: Revert
|
||||||
|
sign_out: Sign out
|
||||||
users: Users
|
users: Users
|
||||||
actions: Actions
|
actions: Actions
|
||||||
back: Back
|
back: Back
|
||||||
or: or
|
or: or
|
||||||
profile: Profile
|
|
||||||
register: Register
|
register: Register
|
||||||
sign_in: Sign in
|
sign_in: Sign in
|
||||||
sign_out: Sign out
|
|
||||||
recover_password: Recover password
|
recover_password: Recover password
|
||||||
resend_confirmation: Resend confirmation
|
resend_confirmation: Resend confirmation
|
||||||
|
@ -8,21 +8,21 @@ class UsersTest < ApplicationSystemTestCase
|
|||||||
test "sign in" do
|
test "sign in" do
|
||||||
sign_in
|
sign_in
|
||||||
assert_no_current_path new_user_session_path
|
assert_no_current_path new_user_session_path
|
||||||
assert_text t('devise.sessions.signed_in')
|
assert_text t("devise.sessions.signed_in")
|
||||||
end
|
end
|
||||||
|
|
||||||
test "sign in fails with invalid password" do
|
test "sign in fails with invalid password" do
|
||||||
sign_in password: random_password
|
sign_in password: random_password
|
||||||
assert_current_path new_user_session_path
|
assert_current_path new_user_session_path
|
||||||
assert_text t('devise.failure.invalid', authentication_keys: User.human_attribute_name(:email))
|
assert_text t("devise.failure.invalid", authentication_keys: User.human_attribute_name(:email))
|
||||||
end
|
end
|
||||||
|
|
||||||
test "sign out" do
|
test "sign out" do
|
||||||
sign_in
|
sign_in
|
||||||
visit root_url
|
visit root_url
|
||||||
click_on t(:sign_out)
|
click_on t("layouts.application.sign_out")
|
||||||
assert_current_path new_user_session_path
|
assert_current_path new_user_session_path
|
||||||
assert_text t('devise.sessions.signed_out')
|
assert_text t("devise.sessions.signed_out")
|
||||||
end
|
end
|
||||||
|
|
||||||
test "recover password" do
|
test "recover password" do
|
||||||
@ -35,19 +35,19 @@ class UsersTest < ApplicationSystemTestCase
|
|||||||
click_on t(:recover_password)
|
click_on t(:recover_password)
|
||||||
end
|
end
|
||||||
assert_current_path new_user_session_path
|
assert_current_path new_user_session_path
|
||||||
assert_text t('devise.passwords.send_instructions')
|
assert_text t("devise.passwords.send_instructions")
|
||||||
|
|
||||||
with_last_email do |mail|
|
with_last_email do |mail|
|
||||||
visit Capybara.string(mail.body.to_s).find_link("Change my password")[:href]
|
visit Capybara.string(mail.body.to_s).find_link("Change my password")[:href]
|
||||||
end
|
end
|
||||||
new_password = random_password
|
new_password = random_password
|
||||||
fill_in t('users.passwords.edit.new_password'), with: new_password
|
fill_in t("users.passwords.edit.new_password"), with: new_password
|
||||||
fill_in t('users.passwords.edit.password_confirmation'), with: new_password
|
fill_in t("users.passwords.edit.password_confirmation"), with: new_password
|
||||||
assert_emails 1 do
|
assert_emails 1 do
|
||||||
click_on t('users.passwords.edit.update_password')
|
click_on t("users.passwords.edit.update_password")
|
||||||
end
|
end
|
||||||
assert_no_current_path user_password_path
|
assert_no_current_path user_password_path
|
||||||
assert_text t('devise.passwords.updated')
|
assert_text t("devise.passwords.updated")
|
||||||
end
|
end
|
||||||
|
|
||||||
test "register" do
|
test "register" do
|
||||||
@ -57,7 +57,7 @@ class UsersTest < ApplicationSystemTestCase
|
|||||||
fill_in User.human_attribute_name(:email).capitalize, with: random_email
|
fill_in User.human_attribute_name(:email).capitalize, with: random_email
|
||||||
password = random_password
|
password = random_password
|
||||||
fill_in User.human_attribute_name(:password).capitalize, with: password
|
fill_in User.human_attribute_name(:password).capitalize, with: password
|
||||||
fill_in t('users.registrations.new.password_confirmation'), with: password
|
fill_in t("users.registrations.new.password_confirmation"), with: password
|
||||||
assert_difference ->{User.count}, 1 do
|
assert_difference ->{User.count}, 1 do
|
||||||
assert_emails 1 do
|
assert_emails 1 do
|
||||||
click_on t(:register)
|
click_on t(:register)
|
||||||
@ -65,13 +65,13 @@ class UsersTest < ApplicationSystemTestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
assert_no_current_path new_user_registration_path
|
assert_no_current_path new_user_registration_path
|
||||||
assert_text t('devise.registrations.signed_up_but_unconfirmed')
|
assert_text t("devise.registrations.signed_up_but_unconfirmed")
|
||||||
|
|
||||||
with_last_email do |mail|
|
with_last_email do |mail|
|
||||||
visit Capybara.string(mail.body.to_s).find_link("Confirm my account")[:href]
|
visit Capybara.string(mail.body.to_s).find_link("Confirm my account")[:href]
|
||||||
end
|
end
|
||||||
assert_current_path new_user_session_path
|
assert_current_path new_user_session_path
|
||||||
assert_text t('devise.confirmations.confirmed')
|
assert_text t("devise.confirmations.confirmed")
|
||||||
assert User.last.confirmed?
|
assert User.last.confirmed?
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ class UsersTest < ApplicationSystemTestCase
|
|||||||
click_on t(:resend_confirmation)
|
click_on t(:resend_confirmation)
|
||||||
end
|
end
|
||||||
assert_current_path new_user_session_path
|
assert_current_path new_user_session_path
|
||||||
assert_text t('devise.confirmations.send_instructions')
|
assert_text t("devise.confirmations.send_instructions")
|
||||||
|
|
||||||
with_last_email do |mail|
|
with_last_email do |mail|
|
||||||
visit Capybara.string(mail.body.to_s).find_link("Confirm my account")[:href]
|
visit Capybara.string(mail.body.to_s).find_link("Confirm my account")[:href]
|
||||||
@ -95,7 +95,7 @@ class UsersTest < ApplicationSystemTestCase
|
|||||||
|
|
||||||
test "show profile" do
|
test "show profile" do
|
||||||
sign_in user: users.select(&:admin?).select(&:confirmed?).sample
|
sign_in user: users.select(&:admin?).select(&:confirmed?).sample
|
||||||
click_on t('layouts.application.users')
|
click_on t("layouts.application.users")
|
||||||
within all('tr').drop(1).sample do |tr|
|
within all('tr').drop(1).sample do |tr|
|
||||||
email = first(:link).text
|
email = first(:link).text
|
||||||
click_on email
|
click_on email
|
||||||
@ -107,7 +107,7 @@ class UsersTest < ApplicationSystemTestCase
|
|||||||
user = users.select(&:admin?).select(&:confirmed?).sample
|
user = users.select(&:admin?).select(&:confirmed?).sample
|
||||||
sign_in user: user
|
sign_in user: user
|
||||||
|
|
||||||
click_on t('layouts.application.users')
|
click_on t("layouts.application.users")
|
||||||
all(:link_or_button, text: t("users.index.disguise")).sample.click
|
all(:link_or_button, text: t("users.index.disguise")).sample.click
|
||||||
assert_current_path edit_user_registration_path
|
assert_current_path edit_user_registration_path
|
||||||
# TODO: test for profile app-menu link after root changed to different path
|
# TODO: test for profile app-menu link after root changed to different path
|
||||||
@ -122,8 +122,8 @@ class UsersTest < ApplicationSystemTestCase
|
|||||||
user = users.select(&:admin?).select(&:confirmed?).sample
|
user = users.select(&:admin?).select(&:confirmed?).sample
|
||||||
sign_in user: user
|
sign_in user: user
|
||||||
|
|
||||||
click_on t('layouts.application.users')
|
click_on t("layouts.application.users")
|
||||||
text = t('users.index.disguise')
|
text = t("users.index.disguise")
|
||||||
undisguisable = all(:xpath, "//tbody//tr[not(descendant::*[contains(text(),\"#{text}\")])]")
|
undisguisable = all(:xpath, "//tbody//tr[not(descendant::*[contains(text(),\"#{text}\")])]")
|
||||||
within undisguisable.sample do |tr|
|
within undisguisable.sample do |tr|
|
||||||
email = first(:link).text
|
email = first(:link).text
|
||||||
@ -144,8 +144,8 @@ class UsersTest < ApplicationSystemTestCase
|
|||||||
end
|
end
|
||||||
assert_difference ->{ User.count }, -1 do
|
assert_difference ->{ User.count }, -1 do
|
||||||
# TODO: accept_confirm when modal dialog is working
|
# TODO: accept_confirm when modal dialog is working
|
||||||
#accept_confirm { click_on t('users.registrations.edit.delete') }
|
#accept_confirm { click_on t("users.registrations.edit.delete") }
|
||||||
click_on t('users.registrations.edit.delete')
|
click_on t("users.registrations.edit.delete")
|
||||||
end
|
end
|
||||||
assert_current_path new_user_session_path
|
assert_current_path new_user_session_path
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user