Skip to content

Commit

Permalink
Fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleMacPherson committed Jun 18, 2024
1 parent b43e47e commit 5fc3900
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "rails_helper"

RSpec.describe SendJobApplicationDataExpiryNotifierJob do
let(:notification) { instance_double(Publishers::JobApplicationDataExpiryNotification) }
let(:notification) { instance_double(Publishers::JobApplicationDataExpiryNotifier) }
let(:organisation) { create(:school) }
let(:publisher) { create(:publisher, organisations: [organisation]) }
let!(:vacancy) { create(:vacancy, expires_at: 351.days.ago, publisher: publisher, organisations: [organisation]) }
Expand All @@ -10,7 +10,7 @@

context "when the vacancy has no job applications" do
it "does not send notifications" do
expect(Publishers::JobApplicationDataExpiryNotification).not_to receive(:with).with(vacancy: vacancy, publisher: publisher)
expect(Publishers::JobApplicationDataExpiryNotifier).not_to receive(:with).with(vacancy: vacancy, publisher: publisher)
described_class.perform_now
end
end
Expand All @@ -20,7 +20,7 @@

context "when the vacancy expired 351 days ago" do
it "sends notifications" do
expect(Publishers::JobApplicationDataExpiryNotification).to receive(:with).with(vacancy: vacancy, publisher: publisher).and_return(notification)
expect(Publishers::JobApplicationDataExpiryNotifier).to receive(:with).with(vacancy: vacancy, publisher: publisher).and_return(notification)
expect(notification).to receive(:deliver).with(publisher)
described_class.perform_now
end
Expand All @@ -30,7 +30,7 @@
let!(:vacancy) { create(:vacancy, expires_at: 1.day.ago, publisher: publisher, organisations: [organisation]) }

it "does not send notifications" do
expect(Publishers::JobApplicationDataExpiryNotification).not_to receive(:with).with(vacancy: vacancy, publisher: publisher)
expect(Publishers::JobApplicationDataExpiryNotifier).not_to receive(:with).with(vacancy: vacancy, publisher: publisher)
described_class.perform_now
end
end
Expand Down
5 changes: 0 additions & 5 deletions spec/models/notification_spec.rb

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
let(:job_application) { create(:job_application, :status_submitted, vacancy: vacancy) }

describe "#timestamp" do
subject { Notification.last.to_notification.timestamp }
subject { Noticed::Notification.last.timestamp }

context "when the notification is delivered today" do
before do
Expand Down
4 changes: 3 additions & 1 deletion spec/requests/publishers/notifications_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
let(:organisation) { build(:school) }
let(:vacancy) { create(:vacancy, organisations: [organisation]) }
let(:job_application) { create(:job_application, vacancy: vacancy) }
let!(:notification) { create(:notification, :job_application_received, recipient: publisher, params: { vacancy: vacancy, job_application: job_application }) }
# let!(:notification) { create(:notification, :job_application_received, recipient: publisher, params: { vacancy: vacancy, job_application: job_application }) }

before do
Publishers::JobApplicationReceivedNotifier.with(vacancy: vacancy, job_application: job_application).deliver(publisher)
allow_any_instance_of(Publishers::BaseController).to receive(:current_organisation).and_return(organisation)
sign_in(publisher, scope: :publisher)
end
Expand All @@ -18,6 +19,7 @@
end

it "marks notifications as read" do
notification = publisher.notifications.first
freeze_time do
expect { get publishers_notifications_path }.to change { notification.reload.read_at }.from(nil).to(Time.current)
end
Expand Down

0 comments on commit 5fc3900

Please sign in to comment.