Sha256: bddfa0436f6511680d48515186850a7eaab125cfae7d4b11a4d49e969e21c0c3

Contents?: true

Size: 1.39 KB

Versions: 16

Compression:

Stored size: 1.39 KB

Contents

# frozen_string_literal: true

require "spec_helper"

shared_examples_for "counts commentators as newsletter participants" do
  # non participant commentator (comments into other spaces)
  let!(:non_participant) { create(:user, :confirmed, newsletter_notifications_at: Time.current, organization: component_out_of_newsletter.organization) }
  # expects resource_out_of_newsletter to belong to a space which has NOT been selected in the newsletter
  let!(:outlier_comment) { create(:comment, author: non_participant, commentable: resource_out_of_newsletter) }

  let(:commentators_ids) { [] }
  let(:recipients_ids) { author_ids + commentators_ids }

  context "without commentators" do
    it "returns zero participants" do
      expect(subject).to match_array(recipients_ids)
    end
  end

  context "with commentators, counts commentators in the current space" do
    # participant commentator
    let!(:commentator_participant) { create(:user, :confirmed, newsletter_notifications_at: Time.current, organization:) }
    # expects resource_in_newsletter to belong to a space selected in the newsletter
    let!(:comment_in_newsletter) { create(:comment, author: commentator_participant, commentable: resource_in_newsletter) }
    let(:commentators_ids) { [commentator_participant.id] }

    it "returns only commenters in the selected spaces" do
      expect(subject).to match_array(recipients_ids)
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
decidim-core-0.30.0.rc1 lib/decidim/core/test/shared_examples/counts_commentators_as_newsletter_participants.rb
decidim-core-0.29.2 lib/decidim/core/test/shared_examples/counts_commentators_as_newsletter_participants.rb
decidim-core-0.28.5 lib/decidim/core/test/shared_examples/counts_commentators_as_newsletter_participants.rb
decidim-core-0.29.1 lib/decidim/core/test/shared_examples/counts_commentators_as_newsletter_participants.rb
decidim-core-0.28.4 lib/decidim/core/test/shared_examples/counts_commentators_as_newsletter_participants.rb
decidim-core-0.29.0 lib/decidim/core/test/shared_examples/counts_commentators_as_newsletter_participants.rb
decidim-core-0.28.3 lib/decidim/core/test/shared_examples/counts_commentators_as_newsletter_participants.rb
decidim-core-0.29.0.rc4 lib/decidim/core/test/shared_examples/counts_commentators_as_newsletter_participants.rb
decidim-core-0.29.0.rc3 lib/decidim/core/test/shared_examples/counts_commentators_as_newsletter_participants.rb
decidim-core-0.29.0.rc2 lib/decidim/core/test/shared_examples/counts_commentators_as_newsletter_participants.rb
decidim-core-0.29.0.rc1 lib/decidim/core/test/shared_examples/counts_commentators_as_newsletter_participants.rb
decidim-core-0.28.2 lib/decidim/core/test/shared_examples/counts_commentators_as_newsletter_participants.rb
decidim-core-0.28.1 lib/decidim/core/test/shared_examples/counts_commentators_as_newsletter_participants.rb
decidim-core-0.28.0 lib/decidim/core/test/shared_examples/counts_commentators_as_newsletter_participants.rb
decidim-core-0.28.0.rc5 lib/decidim/core/test/shared_examples/counts_commentators_as_newsletter_participants.rb
decidim-core-0.28.0.rc4 lib/decidim/core/test/shared_examples/counts_commentators_as_newsletter_participants.rb