diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index f42b2e3..d2d4ed8 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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 diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 957707b..324f0c6 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -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 %> diff --git a/app/views/users/sessions/new.html.erb b/app/views/users/sessions/new.html.erb index 4f6b051..d86dc38 100644 --- a/app/views/users/sessions/new.html.erb +++ b/app/views/users/sessions/new.html.erb @@ -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) %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 3c7535b..324e794 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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" diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml index 957a32d..7e1c0e6 100644 --- a/test/fixtures/users.yml +++ b/test/fixtures/users.yml @@ -1,3 +1,4 @@ admin: email: admin@dev27.fixin.me status: admin + encrypted_password: <%= Devise::Encryptor.digest(User, 'admin') %> diff --git a/test/system/users_test.rb b/test/system/users_test.rb index 883faad..918c2f3 100644 --- a/test/system/users_test.rb +++ b/test/system/users_test.rb @@ -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 diff --git a/test/test_helper.rb b/test/test_helper.rb index d713e37..d2472e0 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -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