Skip to content

Commit

Permalink
Feature/1335 Kein self service austritt für Magazin Abonnenten (#1375)
Browse files Browse the repository at this point in the history
* Add ability spec for described case

* Adjust ability

* Add translation key for tooltip

* Fix spec feature specs and add one spec to check for tooltip

* Adjust translation

* Adjust spec

* Use correct character in spec

* Update config/locales/wagon.de.yml

---------

Co-authored-by: Raphael Nestler <[email protected]>
  • Loading branch information
njaeggi and rnestler authored Dec 12, 2024
1 parent 615714d commit 5571894
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
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

0 comments on commit 5571894

Please sign in to comment.