Skip to content

Commit 4f42045

Browse files
authored
Add "Log out" button (#56)
1 parent 24b68d8 commit 4f42045

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

app/views/layouts/_sidebar.html.erb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<div class="sidebar-header position-relative">
55
<div class="d-flex justify-content-between align-items-center">
66
<div class="logo">
7-
<a href="index.html">Logo</a>
7+
<%= link_to("SkillRx", root_path) %>
88
</div>
99
<div class="theme-toggle d-flex gap-2 align-items-center mt-2">
1010
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true"
@@ -38,6 +38,9 @@
3838
<a href="#" class="sidebar-hide d-xl-none d-block"><i class="bi bi-x bi-middle"></i></a>
3939
</div>
4040
</div>
41+
<%= button_to session_path, method: :delete, class: "btn btn-danger mt-2" do %>
42+
<i class="bi bi-box-arrow-right"></i> Log out
43+
<% end %>
4144
</div>
4245

4346
<div class="sidebar-menu">

spec/system/login_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,15 @@
3434
expect(page).to have_link("Login", href: new_session_path)
3535
end
3636
end
37+
38+
context "after logging in" do
39+
it "allows users to log out" do
40+
visit new_session_path
41+
fill_in "email", with: user.email
42+
fill_in "password", with: user.password
43+
click_button("Sign in")
44+
click_button("Log out")
45+
expect(page).to have_button("Sign in")
46+
end
47+
end
3748
end

0 commit comments

Comments
 (0)