Commit a2e2ae5c authored by Alexandre Friquet's avatar Alexandre Friquet

Do not allow subscriptions creation when affiliation number not provided: refs #50.

parent 5cd3fb30
......@@ -26,11 +26,11 @@ module AuthorizationsHelper
end
def can_manage_subscriptions?(member)
admin_or_collaborating_club?(member)
admin_or_collaborating_club?(member) && member.affiliation_number.present?
end
def can_see_subscriptions?(member)
admin? || (member.collaborating_medicosocial_org? && member == current_member)
admin? || ((member.collaborating_medicosocial_org? || member.collaborating_club?)&& member == current_member)
end
private
......
......@@ -27,6 +27,11 @@
<p class="AdminCard-globalActions">
<%= custom_add_link "Nouvelle adhésion", new_member_subscription_path(@member) %>
</p>
<%- else %>
<p>
Merci de remplir votre numéro d'affiliation pour créer des adhésions.
<%= custom_edit_link edit_member_path(@member), :short, class: %w(tight) %>
</p>
<%- end %>
<h2>
Nos adhérents
......
......@@ -308,6 +308,27 @@ feature "Manage subscriptions" do
context "I can create one", :js do
scenario "only if afffiliation number provided" do
@member.update_attribute(:affiliation_number, nil)
visit member_path(@member)
within "aside#subscriptions" do
expect(page).not_to have_link "Nouvelle adhésion"
click_edit_link
end
expect(current_path).to eq edit_member_path(@member)
within "form" do
fill_in "Numéro d'affiliation", with: "123456"
click_update_button
end
expect(current_path).to eq member_path(@member)
within "aside#subscriptions" do
expect(page).to have_link "Nouvelle adhésion"
end
end
scenario "with existing medico social org" do
medico_social_orgs_group = create :member_group
msi = create :member, member_groups: [medico_social_orgs_group]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment