Test "sign in"

This commit is contained in:
cryptogopher 2023-04-12 23:23:37 +02:00
parent 51985bc88e
commit 3f2a92a6e5
7 changed files with 24 additions and 8 deletions

View File

@ -33,6 +33,11 @@ module ApplicationHelper
def image_link_to(name, image = nil, options = nil, html_options = nil)
name = svg_tag("pictograms/#{image}.svg#icon") + name if image
if html_options.delete(:hide)
# NOTE: current_path? does not work for POST
visibility = (url_for(options) == request.path) ? 'hidden' : 'visible'
html_options.merge!(style: "visibility: #{visibility}") { |k, v1, v2| v1 + v2 }
end
link_to name, options, html_options
end

View File

@ -16,10 +16,9 @@
<%= image_link_to t(:sign_out), "logout", destroy_user_session_path,
data: { turbo_method: :delete } %>
<% else %>
<%= image_link_to t(:sign_in), "login", new_user_session_path,
class: class_names(active: current_page?(new_user_session_path)) %>
<%= image_link_to t(:sign_in), "login", new_user_session_path, hide: true %>
<%= image_link_to t(:register), "account-plus-outline", new_user_registration_path,
class: class_names(active: current_page?(new_user_registration_path)) %>
hide: true %>
<% end %>
</div>

View File

@ -3,7 +3,7 @@
<%= f.password_field :password, required: true, size: 32, autocomplete: "current-password" %>
<% if devise_mapping.rememberable? %>
<%= f.check_box :remember_me %>
<%= f.check_box :remember_me, label: t('.remember_me') %>
<% end %>
<%= f.submit t(:sign_in) %>

View File

@ -1,7 +1,13 @@
en:
email: "E-mail"
password: "Password"
activerecord:
attributes:
user:
email: "E-mail"
password: "Password"
users:
sessions:
new:
remember_me: "Remember me"
register: "Register"
remember_me: "Remember me"
sign_in: "Sign in"
sign_out: "Sign out"

View File

@ -1,3 +1,4 @@
admin:
email: admin@dev27.fixin.me
status: admin
encrypted_password: <%= Devise::Encryptor.digest(User, 'admin') %>

View File

@ -7,6 +7,11 @@ class UsersTest < ApplicationSystemTestCase
test "sign in" do
visit new_user_session_url
fill_in User.human_attribute_name(:email), with: @admin.email
fill_in User.human_attribute_name(:password), with: 'admin'
click_on t(:sign_in)
assert_no_current_path new_user_session_path
assert_text t('devise.sessions.signed_in')
end
#test "visiting the index" do

View File

@ -9,5 +9,5 @@ class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all
# Add more helper methods to be used by all tests here...
include AbstractController::Translation
end