Skip to content

Commit

Permalink
Member, membership listing period display
Browse files Browse the repository at this point in the history
To avoid confusion with membership using delivery cycles, the membership
calendar period is now displayed with the first and last delivery dates instead
of the start and end dates.
  • Loading branch information
thibaudgg committed Jan 26, 2025
1 parent 314e9ea commit 6b57a8c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
4 changes: 4 additions & 0 deletions app/models/membership.rb
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,10 @@ def first_delivery
baskets.first&.delivery
end

def last_delivery
baskets.last&.delivery
end

def period
started_on..ended_on
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/members/memberships/_membership.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ div id=membership.fiscal_year.year
li class='flex flex-row items-center'
= icon "calendar-days", class: "h-6 w-6 text-gray-300 dark:text-gray-700"
span class='ml-2'
= [ membership.started_on, membership.ended_on ].map { |d| l(d) }.join(" – ")
= [ membership.first_delivery.date, membership.last_delivery.date ].map { |d| l(d) }.join(" – ")

li class='mt-1 flex flex-row items-center'
= icon "shopping-bag", class: "h-6 w-6 text-gray-300 dark:text-gray-700"
Expand Down
6 changes: 3 additions & 3 deletions test/system/members/membership_renewals_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Members::MembershipRenewalsTest < ApplicationSystemTestCase

assert_includes menu_nav, "Membership\n⤷ Current"
within "#2025 ul" do
assert_text "1 January 2025 – 31 December 2025"
assert_text "7 April 2025 – 12 June 2025"
assert_text "Medium basket"
assert_text "2x Bread and Eggs"
assert_text "Home"
Expand Down Expand Up @@ -89,7 +89,7 @@ class Members::MembershipRenewalsTest < ApplicationSystemTestCase

assert_includes menu_nav, "Membership\n⤷ Current"
within "#2025 ul" do
assert_text "1 January 2025 – 31 December 2025"
assert_text "10 April 2025 – 12 June 2025"
end

renewed_membership = membership.reload.renewed_membership
Expand Down Expand Up @@ -117,7 +117,7 @@ class Members::MembershipRenewalsTest < ApplicationSystemTestCase
assert_selector ".flash", text: "Your membership has been renewed. Thank you!"
assert_includes menu_nav, "Membership\n⤷ Current"
within "#2025 ul" do
assert_text "1 January 2025 – 31 December 2025"
assert_text "10 April 2025 – 12 June 2025"
assert_text "Salary baskets"
end

Expand Down
6 changes: 3 additions & 3 deletions test/system/members/memberships_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Members::MembershipsTest < ApplicationSystemTestCase
click_on "Membership"

within "#2024 ul" do
assert_text "1 January 2024 – 31 December 2024"
assert_text "1 April 2024 – 3 June 202"
assert_text " Medium basket"
assert_text "Our farm"
assert_text "10 Deliveries, one absence"
Expand All @@ -32,11 +32,11 @@ class Members::MembershipsTest < ApplicationSystemTestCase
click_on "Membership"

within "#2024 ul" do
assert_text "1 January 2024 – 31 December 2024"
assert_text "4 April 2024 – 6 June 2024"
assert_text "Large basket"
assert_text "Bread"
assert_text "Bakery"
assert_text " 10 Deliveries, 2 more on trial and without commitmen"
assert_text " 10 Deliveries, 2 more on trial and without commitment"
assert_text "½ Days: 2 requested"
assert_text "CHF 380.00"
end
Expand Down

0 comments on commit 6b57a8c

Please sign in to comment.