Sha256: 6beace839e204ad69ae4e37faa9e054ef4dddc6276e9838dcd8251e5da375502

Contents?: true

Size: 1.4 KB

Versions: 42

Compression:

Stored size: 1.4 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: 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

42 entries across 42 versions & 1 rubygems

Version Path
decidim-core-0.27.9 lib/decidim/core/test/shared_examples/counts_commentators_as_newsletter_participants.rb
decidim-core-0.27.8 lib/decidim/core/test/shared_examples/counts_commentators_as_newsletter_participants.rb
decidim-core-0.27.7 lib/decidim/core/test/shared_examples/counts_commentators_as_newsletter_participants.rb
decidim-core-0.27.6 lib/decidim/core/test/shared_examples/counts_commentators_as_newsletter_participants.rb
decidim-core-0.26.10 lib/decidim/core/test/shared_examples/counts_commentators_as_newsletter_participants.rb
decidim-core-0.26.9 lib/decidim/core/test/shared_examples/counts_commentators_as_newsletter_participants.rb
decidim-core-0.27.5 lib/decidim/core/test/shared_examples/counts_commentators_as_newsletter_participants.rb
decidim-core-0.26.8 lib/decidim/core/test/shared_examples/counts_commentators_as_newsletter_participants.rb
decidim-core-0.27.4 lib/decidim/core/test/shared_examples/counts_commentators_as_newsletter_participants.rb
decidim-core-0.27.3 lib/decidim/core/test/shared_examples/counts_commentators_as_newsletter_participants.rb
decidim-core-0.26.7 lib/decidim/core/test/shared_examples/counts_commentators_as_newsletter_participants.rb
decidim-core-0.26.5 lib/decidim/core/test/shared_examples/counts_commentators_as_newsletter_participants.rb
decidim-core-0.27.2 lib/decidim/core/test/shared_examples/counts_commentators_as_newsletter_participants.rb
decidim-core-0.27.1 lib/decidim/core/test/shared_examples/counts_commentators_as_newsletter_participants.rb
decidim-core-0.26.4 lib/decidim/core/test/shared_examples/counts_commentators_as_newsletter_participants.rb
decidim-core-0.27.0 lib/decidim/core/test/shared_examples/counts_commentators_as_newsletter_participants.rb
decidim-core-0.26.3 lib/decidim/core/test/shared_examples/counts_commentators_as_newsletter_participants.rb
decidim-core-0.27.0.rc2 lib/decidim/core/test/shared_examples/counts_commentators_as_newsletter_participants.rb
decidim-core-0.27.0.rc1 lib/decidim/core/test/shared_examples/counts_commentators_as_newsletter_participants.rb
decidim-core-0.26.2 lib/decidim/core/test/shared_examples/counts_commentators_as_newsletter_participants.rb