Skip to content

Commit

Permalink
Minitest migration
Browse files Browse the repository at this point in the history
  • Loading branch information
thibaudgg committed Jan 21, 2025
1 parent 77cf7eb commit 3a10ac0
Show file tree
Hide file tree
Showing 12 changed files with 108 additions and 157 deletions.
2 changes: 1 addition & 1 deletion app/views/members/baskets/_basket.html.slim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ul class="relative p-2 rounded hover:bg-gray-100 dark:hover:bg-gray-900 #{"text-gray-300 dark:text-gray-700" if basket.absent?} #{"bg-gray-200 dark:bg-gray-800" if basket == @next_basket}"
ul id=dom_id(basket) class="relative p-2 rounded hover:bg-gray-100 dark:hover:bg-gray-900 #{"text-gray-300 dark:text-gray-700" if basket.absent?} #{"bg-gray-200 dark:bg-gray-800" if basket == @next_basket}"
- if basket.can_member_update?
= link_to edit_members_basket_path(basket), title: t(".edit"), class: "absolute top-0 right-0 p-2 " do
= icon "pencil-square", class: "h-5 w-5 text-gray-400 dark:text-gray-600 hover:text-green-500 dark:hover:text-green-500"
Expand Down
2 changes: 1 addition & 1 deletion config/locales/attributes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ _:
_it: Ceste
billing_year_division:
_de: Einzahlungsintervall
_en: Billing year division
_en: Payment interval
_fr: Intervalle de paiement
_it: Intervallo di pagamento
bulk_dates_ends_on:
Expand Down
2 changes: 1 addition & 1 deletion config/storage.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
test:
service: TenantDisk
service: Disk
root: <%= Rails.root.join("tmp/storage") %>

tenant_disk:
Expand Down
93 changes: 0 additions & 93 deletions spec/system/members/baskets_spec.rb

This file was deleted.

60 changes: 0 additions & 60 deletions spec/system/members/billing_spec.rb

This file was deleted.

4 changes: 4 additions & 0 deletions test/application_system_test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase

driven_by :rack_test

Capybara.configure do |config|
config.save_path = Rails.root.join("tmp", "capybara")
end

setup do |test|
subdomain = test.class.name.include?("Members::") ? "members" : "admin"
Capybara.app_host = "http://#{subdomain}.acme.test"
Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/active_storage/attachments.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
annual_fee_pdf:
name: pdf_file
record: annual_fee (Invoice)
blob: invoice_pdf

other_closed_pdf:
name: pdf_file
record: other_closed (Invoice)
blob: invoice_pdf
1 change: 1 addition & 0 deletions test/fixtures/active_storage/blobs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invoice_pdf: <%= ActiveStorage::FixtureSet.blob filename: "invoice.pdf" %>
Binary file added test/fixtures/files/invoice.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion test/fixtures/payments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ other_closed:
invoice: other_closed
member: john
amount: 10
date: <%= Date.today %>
date: 2024-04-02
54 changes: 54 additions & 0 deletions test/system/members/baskets_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# frozen_string_literal: true

require "application_system_test_case"

class Members::BasketsTest < ApplicationSystemTestCase
test "update depot and basket complements" do
travel_to "2024-01-01"
org(
membership_depot_update_allowed: true,
membership_complements_update_allowed: true)
membership = memberships(:jane)
basket = membership.baskets.first

login(members(:jane))
assert_includes menu_nav, "Deliveries\n" + "⤷ 4 April 2024"
click_on "Deliveries"

assert_equal "/deliveries", current_path
assert_text "Bakery"
assert_text "Bread"
assert_no_text "Eggs"

within "#basket_#{basket.id}" do
click_on "Edit"
end
choose "Home"
fill_in "Bread", with: "2"
fill_in "Eggs", with: "1"
assert_no_text "Cheese"

assert_changes -> { basket.reload.depot_id }, to: home_id do
assert_changes -> { basket.reload.complement_ids }, to: [ eggs_id, bread_id ] do
click_on "Confirm"
end
end

assert_equal "/deliveries", current_path
assert_text "Home"
assert_text "2x Bread and Eggs"
end

test "update not allowed" do
travel_to "2024-01-01"
basket = memberships(:john).baskets.first

login(members(:john))
assert_includes menu_nav, "Deliveries\n" + "⤷ 1 April 2024"
click_on "Deliveries"

within "#basket_#{basket.id}" do
assert_no_link "Edit"
end
end
end
36 changes: 36 additions & 0 deletions test/system/members/billing_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# frozen_string_literal: true

require "application_system_test_case"

class Members::BillingTest < ApplicationSystemTestCase
test "list open invoices" do
login(members(:martha))
invoice = invoices(:annual_fee)

visit "/billing"

assert_text "Billing\n⤷ 1 open invoice"
assert_text "1 open invoice"
assert_text "01.04.24Open invoice ##{invoice.id} (Annual fee) CHF 30.00"
assert_text "Amount remaining to be paidCHF 30.00"
assert_text "Payment intervalAnnual"
end

test "list invoices and payments history" do
travel_to "2024-05-01"
member = members(:john)
memberships(:john).update!(billing_year_division: 4)
login(member)
invoice = invoices(:other_closed)
create_payment(amount: 42)

visit "/billing"

assert_text "History"
assert_text "CreditCHF 42.00"
assert_text "Payment intervalQuarterly"
assert_text "01.05.24Payment without reference-CHF 42.00"
assert_text "02.04.24Payment of invoice #901871612-CHF 10.00"
assert_text "01.04.24Invoice ##{invoice.id} (Other) CHF 10.00"
end
end

0 comments on commit 3a10ac0

Please sign in to comment.