Sha256: f90c398d5a5abee3ca7127fffbe2882f80d2746e9017f96b7c682c726d87c189

Contents?: true

Size: 1.26 KB

Versions: 12

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

shared_examples_for "emits an upcoming notificaton" do
  context "when it's a future meeting" do
    let(:future_start_date) { 3.days.from_now }

    before do
      meeting.start_time = future_start_date
    end

    it "schedules a upcoming meeting notification job 48h before start time" do
      expect(Decidim::Meetings::UpcomingMeetingNotificationJob)
        .to receive(:generate_checksum).and_return "1234"

      expect(Decidim::Meetings::UpcomingMeetingNotificationJob)
        .to receive_message_chain(:set, :perform_later) # rubocop:disable RSpec/MessageChain
        .with(set: meeting.start_time - Decidim::Meetings.upcoming_meeting_notification)
        .with(kind_of(Integer), "1234")

      subject.call
    end
  end

  context "when it's a past meeting" do
    let(:past_start_date) { 1.day.ago }

    before do
      meeting.start_time = past_start_date
    end

    it "doesn't schedule an upcoming meeting notification" do
      expect(Decidim::Meetings::UpcomingMeetingNotificationJob).not_to receive(:generate_checksum)
      expect(Decidim::Meetings::UpcomingMeetingNotificationJob).not_to receive(:set)
      expect(Decidim::Meetings::UpcomingMeetingNotificationJob).not_to receive(:perform_later)

      subject.call
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
decidim-meetings-0.26.10 lib/decidim/meetings/test/notifications_handling.rb
decidim-meetings-0.26.9 lib/decidim/meetings/test/notifications_handling.rb
decidim-meetings-0.26.8 lib/decidim/meetings/test/notifications_handling.rb
decidim-meetings-0.26.7 lib/decidim/meetings/test/notifications_handling.rb
decidim-meetings-0.26.5 lib/decidim/meetings/test/notifications_handling.rb
decidim-meetings-0.26.4 lib/decidim/meetings/test/notifications_handling.rb
decidim-meetings-0.26.3 lib/decidim/meetings/test/notifications_handling.rb
decidim-meetings-0.26.2 lib/decidim/meetings/test/notifications_handling.rb
decidim-meetings-0.26.1 lib/decidim/meetings/test/notifications_handling.rb
decidim-meetings-0.26.0 lib/decidim/meetings/test/notifications_handling.rb
decidim-meetings-0.26.0.rc2 lib/decidim/meetings/test/notifications_handling.rb
decidim-meetings-0.26.0.rc1 lib/decidim/meetings/test/notifications_handling.rb