Browse Source

Fix sign out link (UJS -> Turbo) (#246)

* Fix sign out link (UJS -> Turbo)

* Only works for JS...

* Specify method and turbo method so that we also get a delete request
pull/247/head
baarkerlounger 3 years ago committed by GitHub
parent
commit
169507f4e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      Gemfile.lock
  2. 2
      app/views/layouts/application.html.erb
  3. 20
      spec/features/user_spec.rb

2
Gemfile.lock

@ -8,7 +8,7 @@ GIT
GIT
remote: https://github.com/baarkerlounger/devise.git
revision: 223969286e51b02e78309b7dad908d223d6ba7f5
revision: ac956cc2a58daa57e071202967a212a1dac08053
branch: dluhc-fixes
specs:
devise (4.8.1)

2
app/views/layouts/application.html.erb

@ -46,7 +46,7 @@
component.navigation_item(text: 'Your logs', href: case_logs_path)
component.navigation_item(text: 'Your organisation', href: "/organisations/#{current_user.organisation.id}")
component.navigation_item(text: 'Your account', href: user_path(current_user))
component.navigation_item(text: 'Sign out', href: destroy_user_session_path, options: {:method => :delete})
component.navigation_item(text: 'Sign out', href: destroy_user_session_path, options: { data: {turbo_method: :delete}, method: :delete })
end
end
%>

20
spec/features/user_spec.rb

@ -30,6 +30,26 @@ RSpec.describe "User Features" do
click_button("Sign in")
expect(page).to have_current_path("/logs")
end
it " can log out again", js: true do
visit("/logs")
fill_in("user[email]", with: user.email)
fill_in("user[password]", with: "pAssword1")
click_button("Sign in")
click_link("Sign out")
expect(page).to have_current_path("/")
expect(page).to have_content("Start now")
end
it " can log out again with js disabled" do
visit("/logs")
fill_in("user[email]", with: user.email)
fill_in("user[password]", with: "pAssword1")
click_button("Sign in")
click_link("Sign out")
expect(page).to have_current_path("/")
expect(page).to have_content("Start now")
end
end
context "A user who has forgotten their password" do

Loading…
Cancel
Save