Skip to content

Commit

Permalink
Minitest, start migration from RSpec
Browse files Browse the repository at this point in the history
  • Loading branch information
thibaudgg committed Dec 30, 2024
1 parent 39a4fde commit 4ea943f
Show file tree
Hide file tree
Showing 106 changed files with 3,231 additions and 2,261 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/specs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Specs

on: push

jobs:
specs:
runs-on: ubuntu-24.04

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install libvips and pdftoppm
run: |
sudo apt-get update -qq -o Acquire::Retries=3
sudo apt-get install -y --fix-missing -qq -o Acquire::Retries=3 libvips poppler-utils
- name: Install Ruby and run Bundler install with cache
uses: ruby/setup-ruby@v1
with:
bundler-cache: true

- name: Set timezone
uses: szenius/[email protected]
with:
timezoneLinux: Europe/Zurich

- name: Run specs
env:
RAILS_ENV: test
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
run: |
bin/rails db:setup
bin/rails test:prepare
bin/rspec
8 changes: 3 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Tests
on: push

jobs:
test:
tests:
runs-on: ubuntu-24.04

steps:
Expand All @@ -25,11 +25,9 @@ jobs:
with:
timezoneLinux: Europe/Zurich

- name: Rails tests
- name: Run tests
env:
RAILS_ENV: test
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
run: |
bin/rails db:setup
bin/rails test:prepare
bin/rspec
bin/rails test:all
2 changes: 0 additions & 2 deletions Aptfile

This file was deleted.

9 changes: 5 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ gem "hexapdf"
gem "public_suffix"
gem "rubyXL"
gem "rexml"
gem "rubyzip", require: "zip"
gem "rubyzip", "~> 2.4.rc1", require: "zip"
gem "parallel"

gem "postmark-rails"
Expand Down Expand Up @@ -94,7 +94,6 @@ group :development, :test do
gem "rspec-rails"
gem "faker"
gem "factory_bot_rails"
gem "brakeman"
end

group :development do
Expand All @@ -114,8 +113,10 @@ group :development do
gem "rubocop-rails-omakase", require: false
gem "rubocop-slim", require: false

gem "cloudflare"
gem "resolv"
gem "brakeman", require: false

gem "cloudflare", require: false
gem "resolv", require: false

gem "prosopite"
gem "pg_query"
Expand Down
16 changes: 8 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -376,12 +376,12 @@ GEM
net-smtp (0.5.0)
net-ssh (7.3.0)
nio4r (2.7.4)
nokogiri (1.18.0)
nokogiri (1.18.1)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
nokogiri (1.18.0-arm64-darwin)
nokogiri (1.18.1-arm64-darwin)
racc (~> 1.4)
nokogiri (1.18.0-x86_64-linux-gnu)
nokogiri (1.18.1-x86_64-linux-gnu)
racc (~> 1.4)
openssl (3.3.0)
optimist (3.2.0)
Expand Down Expand Up @@ -506,7 +506,7 @@ GEM
rb-fsevent (0.11.2)
rb-inotify (0.11.1)
ffi (~> 1.0)
rbs (3.8.0)
rbs (3.8.1)
logger
rchardet19 (1.3.7)
rdoc (6.10.0)
Expand Down Expand Up @@ -590,7 +590,7 @@ GEM
rubyXL (3.4.33)
nokogiri (>= 1.10.8)
rubyzip (>= 1.3.0)
rubyzip (2.3.2)
rubyzip (2.4.rc1)
securerandom (0.4.1)
simple_form (5.3.1)
actionpack (>= 5.2)
Expand All @@ -603,7 +603,7 @@ GEM
temple
thor
tilt
solid_queue (1.1.0)
solid_queue (1.1.2)
activejob (>= 7.1)
activerecord (>= 7.1)
concurrent-ruby (>= 1.3.1)
Expand All @@ -629,7 +629,7 @@ GEM
attr_extras (>= 6.2.4)
diff-lcs
patience_diff
tailwindcss-rails (3.0.0)
tailwindcss-rails (3.1.0)
railties (>= 7.0.0)
tailwindcss-ruby
tailwindcss-ruby (3.4.17)
Expand Down Expand Up @@ -746,7 +746,7 @@ DEPENDENCIES
ruby-lsp-rails
ruby-lsp-rspec
rubyXL
rubyzip
rubyzip (~> 2.4.rc1)
simple_form
slim
solid_queue
Expand Down
11 changes: 5 additions & 6 deletions app/models/invoice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,11 @@ def send!
# Leave some time for the invoice PDF to be uploaded
MailTemplate.deliver_later(:invoice_created, invoice: self)
update!(sent_at: Time.current)
close_or_open!
rescue => e
Error.report(e,
invoice_id: id,
emails: member.emails,
member_id: member_id)
rescue => e
Error.report(e,
invoice_id: id,
emails: member.emails,
member_id: member_id)
end

def mark_as_sent!
Expand Down
15 changes: 8 additions & 7 deletions app/models/organization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,18 @@ class Organization < ApplicationRecord
INPUT_FORM_MODES = %w[hidden visible required]
DELIVERY_PDF_MEMBER_INFOS = %w[none phones food_note]
MEMBERS_SUBDOMAINS = %w[membres mitglieder soci members]
ACTIVITY_PARTICIPATIONS_DEMANDED_LOGIC_DEFAULT = <<-LIQUID
{% if member.salary_basket %}
0
{% else %}
{{ membership.baskets | divided_by: membership.full_year_deliveries | times: membership.full_year_activity_participations | round }}
{% endif %}
LIQUID

attribute :shop_delivery_open_last_day_end_time, :time_only
attribute :icalendar_auth_token, :string, default: -> { SecureRandom.hex(16) }
attribute :activity_participations_demanded_logic, :string, default: -> {
<<~LIQUID
{% if member.salary_basket %}
0
{% else %}
{{ membership.baskets | divided_by: membership.full_year_deliveries | times: membership.full_year_activity_participations | round }}
{% endif %}
LIQUID
ACTIVITY_PARTICIPATIONS_DEMANDED_LOGIC_DEFAULT
}

translated_attributes :invoice_info, :invoice_footer
Expand Down
1 change: 0 additions & 1 deletion app/models/permission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ class Permission < ApplicationRecord

RIGHTS = %i[read write].freeze
SUPERADMIN_ID = 1
SUPERADMIN_FEATURES =

translated_attributes :name, required: true

Expand Down
4 changes: 2 additions & 2 deletions app/views/active_admin/_site_footer.html.slim
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
footer class="pt-40"

ul class="flex justify-center" role="group"
li = link_to updates_path, class: "inline-flex items-center px-2 py-1 no-underline text-sm font-medium text-gray-400 dark:text-gray-600 bg-white border border-gray-200 rounded-s-lg hover:bg-gray-100 hover:text-green-600 focus:z-10 focus:ring-2 focus:ring-green-700 focus:text-green-700 dark:bg-transparent dark:border-gray-800 dark:hover:text-green-500 dark:hover:bg-gray-700 dark:focus:ring-green-500 dark:focus:text-white" do
li = link_to updates_path, class: "action-item-button px-2 py-1 rounded-e-none text-gray-400 dark:text-gray-500" do
= icon "gift", class: "w-5 h-5 me-2"
= t(".updates")

li = link_to handbook_path, class: "inline-flex items-center px-2 py-1 no-underline text-sm font-medium text-gray-400 dark:text-gray-600 bg-white border border-l-0 border-gray-200 rounded-e-lg hover:bg-gray-100 hover:text-green-600 focus:z-10 focus:ring-2 focus:ring-green-700 focus:text-green-700 dark:bg-transparent dark:border-gray-800 dark:hover:text-green-500 dark:hover:bg-gray-700 dark:focus:ring-green-500 dark:focus:text-white" do
li = link_to handbook_path, class: "action-item-button px-2 py-1 border-s-0 rounded-s-none text-gray-400 dark:text-gray-500" do
= icon "book-open", class: "w-5 h-5 me-2"
= t(".handbook")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{% highlight_list %}
<strong>Date:</strong> {{ activity.date_long }}
<strong>Time:</strong> {{ activity.period }}
<strong>Schedule:</strong> {{ activity.period }}
<strong>Activity:</strong> {{ activity.title }}
{% if activity.description %}
<strong>Description:</strong> {{ activity.description }}
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin_mailer/new_registration_email.en.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
{% endif %}

{% button member.admin_url %}
Access the member's page
Access member page
{% endbutton %}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{% highlight_list %}
<strong>Date:</strong> {{ activity.date_long }}
<strong>Time:</strong> {{ activity.period }}
<strong>Schedule:</strong> {{ activity.period }}
<strong>Activity:</strong> {{ activity.title }}
{% if activity.description %}
<strong>Description:</strong> {{ activity.description }}
Expand Down
2 changes: 1 addition & 1 deletion app/views/mail_templates/invoice_overdue_notice.en.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
<p>You can view your invoices and payments at any time from your member page.</p>

{% button member.billing_url %}
Access My Member Page
Access my member page
{% endbutton %}
{% endunless %}
31 changes: 0 additions & 31 deletions bin/update

This file was deleted.

2 changes: 1 addition & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Application < Rails::Application
config.time_zone = "Europe/Zurich"

config.i18n.available_locales = %w[en fr de it]
config.i18n.default_locale = :fr
config.i18n.default_locale = :en
config.i18n.fallbacks = true

# :time must not be included here because of the tod gem
Expand Down
28 changes: 14 additions & 14 deletions config/locales/mail_template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,32 @@ _:
default_subjects:
activity_participation_rejected:
_de: "Abgelehnte Aktivität \U0001F62C"
_en: "Activity Rejected \U0001F62C"
_en: "Activity rejected \U0001F62C"
_fr: "Activité refusée \U0001F62C"
_it: "Attività rifiutata \U0001F62C"
activity_participation_reminder:
_de: Bevorstehende Aktivität ({{ activity.date }})
_en: Upcoming Activity ({{ activity.date }})
_en: Upcoming activity ({{ activity.date }})
_fr: Activité à venir ({{ activity.date }})
_it: Attività futura ({{ activity.date }})
activity_participation_validated:
_de: "Bestätigte Aktivität \U0001F389"
_en: "Activity Confirmed \U0001F389"
_en: "Activity confirmed \U0001F389"
_fr: "Activité validée \U0001F389"
_it: "Attività confermata \U0001F389"
invoice_cancelled:
_de: 'Stornierte Rechnung #{{ invoice.number }}'
_en: 'Cancelled Invoice #{{ invoice.number }}'
_en: 'Cancelled invoice #{{ invoice.number }}'
_fr: 'Facture annulée #{{ invoice.number }}'
_it: 'Fattura annullata #{{ invoice.number }}'
invoice_created:
_de: 'Neue Rechnung #{{ invoice.number }}'
_en: 'New Invoice #{{ invoice.number }}'
_en: 'New invoice #{{ invoice.number }}'
_fr: 'Nouvelle facture #{{ invoice.number }}'
_it: 'Nuova fattura #{{ invoice.number }}'
invoice_overdue_notice:
_de: "Mahnung #{{ invoice.overdue_notices_count }} der Rechnung #{{ invoice.number }} \U0001F62C"
_en: "Overdue Notice #{{ invoice.overdue_notices_count }} for Invoice #{{ invoice.number }} \U0001F62C"
_en: "Overdue notice #{{ invoice.overdue_notices_count }} for invoice #{{ invoice.number }} \U0001F62C"
_fr: "Rappel #{{ invoice.overdue_notices_count }} de la facture #{{ invoice.number }} \U0001F62C"
_it: "Promemoria #{{ invoice.overdue_notices_count }} della fattura #{{ invoice.number }} \U0001F62C"
member_activated:
Expand All @@ -38,42 +38,42 @@ _:
_it: Benvenuto/a!
member_validated:
_de: Registrierung validiert!
_en: Registration Validated!
_en: Registration validated!
_fr: Inscription validée!
_it: Iscrizione confermata!
membership_final_basket:
_de: Letzte Tasche!
_en: Last Basket!
_en: Last basket!
_fr: Dernier panier!
_it: Ultimo cestino!
membership_first_basket:
_de: Erste Tasche des Jahres!
_en: First Basket of the Year!
_en: First basket of the year!
_fr: Premier panier de l'année!
_it: Primo cestino dell'anno!
membership_initial_basket:
_de: Erste Tasche!
_en: First Basket!
_en: First basket!
_fr: Premier panier!
_it: Primo cestino!
membership_last_basket:
_de: Letzte Tasche des Jahres!
_en: Last Basket of the Year!
_en: Last basket of the year!
_fr: Dernier panier de l'année!
_it: Ultimo cestino dell'anno!
membership_last_trial_basket:
_de: Letzte Probe Tasche!
_en: Last Trial Basket!
_en: Last trial basket!
_fr: Dernier panier à l'essai!
_it: Ultimo cestino da provare!
membership_renewal:
_de: Ihr Abonnement verlängern
_en: Renew Your Membership
_en: Renew your membership
_fr: Renouvellement de votre abonnement
_it: Rinnovo del vostro abbonamento
membership_renewal_reminder:
_de: Ihr Abonnement verlängern (Mahnung)
_en: Renew Your Membership (Reminder)
_en: Renew your membership (reminder)
_fr: Renouvellement de votre abonnement (Rappel)
_it: Rinnovo del vostro abbonamento (promemoria)
description:
Expand Down
1 change: 1 addition & 0 deletions lib/tasks/hostname.rake
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# frozen_string_literal: true

require "cloudflare"
require "cloudflare-rails"

namespace :hostname do
Expand Down
Loading

0 comments on commit 4ea943f

Please sign in to comment.