Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix user login #542

Merged
merged 2 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 5 additions & 13 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,17 @@
<head>
<title>Giving Connection</title>
<meta name="viewport" content="width=device-width,initial-scale=1">

<% if request.fullpath.include? "/search" %>
<meta name="turbo-cache-control" content="no-preview">
<% end %>

<%= yield(:head) %>

<%= csrf_meta_tags %>
<%= csp_meta_tag %>

<%= favicon_link_tag %>

<link href="https://fonts.googleapis.com" rel="preconnect" />
<link crossorigin="" href="https://fonts.gstatic.com" rel="preconnect" />
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@100;200;300;400;500;600;700;800;900&amp;display=swap" rel="stylesheet" />
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&amp;display=swap" rel="stylesheet" />

<%= stylesheet_link_tag 'application', media: 'all', 'data-turbo-track': 'reload' %>
<%= stylesheet_pack_tag 'application', media: 'all', 'data-turbo-track': 'reload' %>
<%= javascript_pack_tag 'application', 'data-turbo-track': 'reload' %>
Expand All @@ -29,11 +23,9 @@
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','<%= Rails.application.credentials.dig(Rails.env.to_sym)[:google_tag_key] %>');
</script>

<!-- Google tag (gtag.js) -->
<script src="https://www.googletagmanager.com/gtag/js?id=AW-11382454124" data-turbo-track="reload" async></script>
</head>

<body
class="bg-gray-9"
data-controller="disable-turbo"
Expand All @@ -43,16 +35,16 @@
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<%= render Navbar::Component.new(signed_in: user_signed_in?) %>
<main class="main">
<div id="flash-messages">
<div id="flash-messages" data-test-id="flash_messages">
<%= render "shared/flash_messages" %>
</div>

<%= yield %>
</main>
<%= render Footer::Component.new() %>
<div id="main-modal-container"></div>

<script src="https://cdn.jsdelivr.net/gh/stevenschobert/[email protected]/src/instafeed.min.js"></script>
<script> (function(){ var s = document.createElement('script'); var h = document.querySelector('head') || document.body; s.src = 'https://acsbapp.com/apps/app/dist/js/app.js'; s.async = true; s.onload = function(){ acsbJS.init({ statementLink : '', footerHtml : '', hideMobile : false, hideTrigger : false, disableBgProcess : false, language : 'en', position : 'right', leadColor : '#146FF8', triggerColor : '#146FF8', triggerRadius : '50%', triggerPositionX : 'right', triggerPositionY : 'bottom', triggerIcon : 'people', triggerSize : 'bottom', triggerOffsetX : 20, triggerOffsetY : 20, mobile : { triggerSize : 'small', triggerPositionX : 'right', triggerPositionY : 'bottom', triggerOffsetX : 20, triggerOffsetY : 20, triggerRadius : '20' } }); }; h.appendChild(s); })();</script>
<script src="https://cdn.jsdelivr.net/gh/stevenschobert/[email protected]/src/instafeed.min.js"></script>
<script>
(function(){ var s = document.createElement('script'); var h = document.querySelector('head') || document.body; s.src = 'https://acsbapp.com/apps/app/dist/js/app.js'; s.async = true; s.onload = function(){ acsbJS.init({ statementLink : '', footerHtml : '', hideMobile : false, hideTrigger : false, disableBgProcess : false, language : 'en', position : 'right', leadColor : '#146FF8', triggerColor : '#146FF8', triggerRadius : '50%', triggerPositionX : 'right', triggerPositionY : 'bottom', triggerIcon : 'people', triggerSize : 'bottom', triggerOffsetX : 20, triggerOffsetY : 20, mobile : { triggerSize : 'small', triggerPositionX : 'right', triggerPositionY : 'bottom', triggerOffsetX : 20, triggerOffsetY : 20, triggerRadius : '20' } }); }; h.appendChild(s); })();
</script>
</body>
</html>
2 changes: 1 addition & 1 deletion app/views/my_accounts/show.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ div class="w-full h-full bg-white"
div class="flex flex-row justify-center col-span-12"
= form.submit "Update", class: "mx-auto py-2.5 px-5 text-sm font-bold text-white bg-blue-medium uppercase rounded-6px"
div class="col-span-12 py-4 border-t border-gray-8"
= link_to "Log out", destroy_user_session_path, method: :delete, class:'text-xl font-bold text-blue-dark'
= link_to "Log out", destroy_user_session_path, method: :delete, class:'text-xl font-bold text-blue-dark', data: { turbo: false , test_id: "user_logout_link"}
div class="hidden" data-tabs-target="panel"
h4 class="px-6 text-xl text-grey-2 my-7"
| My Saved Nonprofit Pages
Expand Down
8 changes: 4 additions & 4 deletions app/views/users/sessions/new.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@

= render "users/shared/links"

= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f|
= form_for(resource, as: resource_name, url: session_path(resource_name), data: { turbo: false }) do |f|
.c-form
.c-form--group
= f.label :email, "Email Address"
= f.email_field :email, autofocus: true, autocomplete: "email", class:"c-input"
= f.email_field :email, autofocus: true, autocomplete: "email", class:"c-input", data: { test_id: "user_login_email_input"}
.c-form--group class="mb-3"
= f.label :password
= f.password_field :password, autocomplete: "current-password", class:"c-input"
= f.password_field :password, autocomplete: "current-password", class:"c-input", data: { test_id: "user_login_password_input"}
- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations'
= link_to "Forgot your password?", new_password_path(resource_name), class:'font-bold'
- if devise_mapping.confirmable?
= link_to "Didn't receive confirmation instructions?", new_user_confirmation_path, class: "font-bold"
.c-form--action class="mt-12"
= f.submit "Sign in", class:"c-button"
= f.submit "Sign in", class:"c-button", data: { test_id: "user_login_submit_btn"}

32 changes: 32 additions & 0 deletions spec/system/user_login_system_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require "system_helper"

RSpec.describe "User Login", type: :system do
before do
@user = create(:user)
end

it "can log in" do
visit signin_path

find(:test_id, "user_login_email_input").fill_in with: @user.email
find(:test_id, "user_login_password_input").fill_in with: "wrong password"
click_button "user_login_submit_btn"
expect(page).to have_content("Invalid Email or password.")

find(:test_id, "user_login_password_input").fill_in with: @user.password
click_button "user_login_submit_btn"

expect(page).to have_content("Signed in successfully.")
end

it "can log out" do
sign_in(@user)
visit my_account_path

click_link "user_logout_link"

within(:test_id, "flash_messages") do
expect(page).to have_text("Signed out successfully.")
end
end
end
Loading