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

Featue/1335/kein self service austritt #1375

Merged
merged 8 commits into from
Dec 12, 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
3 changes: 3 additions & 0 deletions app/abilities/sac_cas/role_ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module SacCas::RoleAbility

def self_terminatable_own_role
return false unless her_own
return false if abonnent?
return true unless mitglied_role?

!has_termination_by_section_only_role
Expand Down Expand Up @@ -58,4 +59,6 @@ def mitglied_termination_by_section_only?(role = subject)
def wizard_managed_role?(role = subject)
SacCas::WIZARD_MANAGED_ROLES.include?(role.class)
end

def abonnent? = subject.is_a?(Group::AboMagazin::Abonnent)
end
2 changes: 2 additions & 0 deletions config/locales/wagon.de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1678,6 +1678,8 @@ de:
global:
sac_cas/role/mitglied_common:
no_permission: Für einen Austritt musst du dich an den Mitgliederdienst der Sektion wenden
group/abo_magazin/abonnent:
no_permission: "Eine Kündigung kann nur über den Mitgliederdienst des SAC erfolgen. Bitte schreibe eine E-Mail mit dem gewünschten Kündigungstermin sowie deinem Vor- und Nachnamen an [email protected]."

sac_membership_configs:
form:
Expand Down
9 changes: 9 additions & 0 deletions spec/abilities/sac_cas/role_ability_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,14 @@ def set_termination_by_section_only(role, value)
expect(ability).to be_able_to(:terminate, role_zusatzsektion)
end
end

context "Abo" do
let(:person) { people(:abonnent) }
let(:role_abonnent) { roles(:abonnent_alpen) }

it "is denied when Sektion#mitglied_termination_by_section_only" do
expect(ability).not_to be_able_to(:terminate, role_abonnent)
end
end
end
end
16 changes: 13 additions & 3 deletions spec/features/roles/terminations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
require "spec_helper"

describe :roles_terminations, js: true do
def visit_dialog(role)
sign_in(role.person)
let(:role) { roles(:abonnent_alpen) }

def visit_dialog
sign_in(people(:admin))
visit history_group_person_path(group_id: role.group_id, id: role.person_id)
click_link(href: /#{new_group_role_termination_path(group_id: role.group_id, role_id: role.id)}/)

Expand All @@ -20,11 +22,19 @@ def visit_dialog(role)
it "lists affected role and mentions person" do
# when terminating the stammsektion role, the affected roles include
# all zusatzektion roles as well
visit_dialog(roles(:abonnent_alpen))
visit_dialog

within(".modal-dialog") do
expect(page).to have_content "SAC/CAS / Die Alpen DE / Abonnent" # roles(:mitglied)
expect(page).to have_content(/Austritt.*#{roles(:abonnent_alpen).person.full_name}/)
end
end

it "displays disabled button with tooltip when current_user is abonnent" do
sign_in(role.person)
visit history_group_person_path(group_id: role.group_id, id: role.person_id)

expect(page).to have_css 'button[disabled="disabled"]', text: "Austritt"
expect(page).to have_css('div[rel="tooltip"][title="Eine Kündigung kann nur über den Mitgliederdienst des SAC erfolgen. Bitte schreibe eine E-Mail mit dem gewünschten Kündigungstermin sowie deinem Vor- und Nachnamen an [email protected]."]')
end
end
Loading