Skip to content

Commit

Permalink
Fix more failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleMacPherson committed Jun 18, 2024
1 parent 5fc3900 commit 63d7645
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
4 changes: 2 additions & 2 deletions spec/models/job_application_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
before do
Publishers::JobApplicationReceivedNotifier.with(vacancy: subject.vacancy, job_application: subject)
.deliver(subject.vacancy.publisher)
expect(Notification.count).to eq 1
expect(Noticed::Notification.count).to eq 1
subject.destroy
end

it "removes the notification when destroyed" do
expect(Notification.count).to eq 0
expect(Noticed::Notification.count).to eq 0
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/models/vacancy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
before do
Publishers::JobApplicationReceivedNotifier.with(vacancy: subject, job_application: job_application)
.deliver(subject.publisher)
expect(Notification.count).to eq 1
expect(Noticed::Notification.count).to eq 1
subject.destroy
end

it "removes the notification when destroyed" do
expect(Notification.count).to eq 0
expect(Noticed::Notification.count).to eq 0
end
end

Expand Down
18 changes: 14 additions & 4 deletions spec/support/matchers/have_delivered_notification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,24 @@
match do |proc|
raise ArgumentError, "have_delivered_notification only supports block expectations" unless proc.respond_to?(:call)

expected_attributes = {
type: notification_type,
expected_notification_attributes = {
type: "#{notification_type}::Notification",
params: (hash_including(expected_params) if expected_params),
recipient: expected_recipient,
}.compact

expect(proc).to change { Notification.count }.by(1)
expect(Notification.last).to have_attributes(expected_attributes)
expected_event_attributes = {
type: notification_type,
params: (hash_including(expected_params) if expected_params),
}

expect(proc).to change { Noticed::Notification.count }.by(1)

notification = Noticed::Notification.last
event = Noticed::Event.find(notification.event_id)

expect(notification).to have_attributes(expected_notification_attributes)
expect(event).to have_attributes(expected_event_attributes)
end

chain :with_params, :expected_params
Expand Down

0 comments on commit 63d7645

Please sign in to comment.