* Fixed Leave organization not working * Added named route for users_leave_org
This commit is contained in:
parent
1c1a2e44fb
commit
9b5f57db0e
3 changed files with 26 additions and 2 deletions
|
|
@ -7,7 +7,7 @@
|
|||
<% end %>
|
||||
</div>
|
||||
<h3>Danger zone</h3>
|
||||
<%= form_tag "/users/leave_org", onsubmit: "return confirm('Are you sure you want to leave this organization?');" do %>
|
||||
<%= form_tag users_leave_org_path(@organization), onsubmit: "return confirm('Are you sure you want to leave this organization?');" do %>
|
||||
<div class="field">
|
||||
<%= submit_tag "Leave Organization", class: "danger-button" %>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -245,7 +245,7 @@ Rails.application.routes.draw do
|
|||
post "users/update_language_settings" => "users#update_language_settings"
|
||||
post "users/update_twitch_username" => "users#update_twitch_username"
|
||||
post "users/join_org" => "users#join_org"
|
||||
post "users/leave_org/:organization_id" => "users#leave_org"
|
||||
post "users/leave_org/:organization_id" => "users#leave_org", as: :users_leave_org
|
||||
post "users/add_org_admin" => "users#add_org_admin"
|
||||
post "users/remove_org_admin" => "users#remove_org_admin"
|
||||
post "users/remove_from_org" => "users#remove_from_org"
|
||||
|
|
|
|||
24
spec/system/organization/user_leaves_an_organization_spec.rb
Normal file
24
spec/system/organization/user_leaves_an_organization_spec.rb
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe "User leaves an organization", type: :system do
|
||||
let!(:org_user) { create(:user, :org_member) }
|
||||
let(:organization) { org_user.organizations.first }
|
||||
|
||||
before do
|
||||
sign_in org_user
|
||||
visit "/settings/organization/#{organization.id}"
|
||||
end
|
||||
|
||||
context "when user visits member organization settings" do
|
||||
it "shows the leave oranization button" do
|
||||
expect(page).to have_button("Leave Organization")
|
||||
end
|
||||
end
|
||||
|
||||
context "when user leaves member organization" do
|
||||
it "leaves organization and shows confirmation" do
|
||||
click_button("Leave Organization")
|
||||
expect(page).to have_content("You have left your organization.")
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Reference in a new issue