Skip to content

Commit

Permalink
Add specs
Browse files Browse the repository at this point in the history
  • Loading branch information
hunchr committed Sep 26, 2024
1 parent 964985c commit 5000dde
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
25 changes: 25 additions & 0 deletions spec/mailers/event/participation_canceled_mailer_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

# Copyright (c) 2024, Schweizer Alpen-Club. This file is part of
# hitobito_sac_cas and licensed under the Affero General Public License version 3
# or later. See the COPYING file at the top-level directory or at
# https://github.com/hitobito/hitobito_sac_cas.

require "spec_helper"

describe Event::ParticipationCanceledMailer do
let(:event) { Fabricate(:sac_open_course) }
let(:participation) { event.participations.create!(person: people(:mitglied)) }
let(:mail) { described_class.confirmation(participation) }

before { event.groups.first.update!(course_admin_email: "admin@example.com") }

it "sends to email addresses of participant" do
expect(mail.to).to match_array(["e.hillary@hitobito.example.com"])
expect(mail.bcc).to match_array(["admin@example.com"])
expect(mail.body.to_s).to include(
"Hallo Edmund,",
"Deine Abmeldung für den Kurs Eventus (Nummer: #{event.number}) wurde bestätigt."
)
end
end
12 changes: 12 additions & 0 deletions spec/models/event/participation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
require "spec_helper"

describe Event::Participation do
include ActiveJob::TestHelper

describe "::callbacks" do
subject(:participation) { Fabricate(:event_participation, event: events(:top_course)) }

Expand Down Expand Up @@ -120,4 +122,14 @@ def build_role(key, role)
end
end
end

describe "canceled" do
let(:event) { Fabricate(:sac_open_course) }
let(:participation) { event.participations.create!(person: people(:mitglied)) }

it "sends a confirmation email" do
expect { participation.update(state: :canceled, canceled_at: Time.zone.today) }
.to have_enqueued_mail(Event::ParticipationCanceledMailer, :confirmation).once
end
end
end

0 comments on commit 5000dde

Please sign in to comment.