Sha256: ab62356a072ca0be9a4beefdd6640be855b883edcdb133d19714813f619697cb

Contents?: true

Size: 1.91 KB

Versions: 14

Compression:

Stored size: 1.91 KB

Contents

# frozen_string_literal: true

require "spec_helper"

shared_examples_for "resource endorsed event" do
  include_context "when a simple event"

  let(:event_name) { "decidim.events.resource_endorsed" }
  let(:author) { create :user, organization: resource.organization }

  let(:extra) { { endorser_id: author.id } }
  let(:endorsement) { create :endorsement, resource: resource, author: author }
  let(:resource_path) { resource_locator(resource).path }
  let(:follower) { create(:user, organization: resource.organization) }
  let(:follow) { create(:follow, followable: author, user: follower) }

  it_behaves_like "a simple event"

  describe "types" do
    subject { described_class }

    it "supports notifications" do
      expect(subject.types).to include :notification
    end

    it "supports emails" do
      expect(subject.types).to include :email
    end
  end

  describe "email_subject" do
    it "is generated correctly" do
      expect(subject.email_subject).to eq("#{author_presenter.nickname} has performed a new endorsement")
    end
  end

  describe "email_intro" do
    it "is generated correctly" do
      expect(subject.email_intro)
        .to eq("#{author.name} #{author_presenter.nickname}, who you are following," \
               " has just endorsed \"#{translated resource.title}\" and we think it may be interesting to you. Check it out and contribute:")
    end
  end

  describe "notification_title" do
    it "is generated correctly" do
      expect(subject.notification_title)
        .to include("The <a href=\"#{resource_path}\">#{translated resource.title}</a> #{resource_type} has been endorsed by ")

      expect(subject.notification_title)
        .to include("<a href=\"/profiles/#{author.nickname}\">#{author.name} #{author_presenter.nickname}</a>.")
    end
  end

  describe "resource_text" do
    it "shows the resource text" do
      expect(subject.resource_text).to eq resource_text
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
decidim-core-0.26.10 lib/decidim/core/test/shared_examples/resource_endorsed_event_examples.rb
decidim-core-0.26.9 lib/decidim/core/test/shared_examples/resource_endorsed_event_examples.rb
decidim-core-0.27.5 lib/decidim/core/test/shared_examples/resource_endorsed_event_examples.rb
decidim-core-0.26.8 lib/decidim/core/test/shared_examples/resource_endorsed_event_examples.rb
decidim-core-0.27.4 lib/decidim/core/test/shared_examples/resource_endorsed_event_examples.rb
decidim-core-0.27.3 lib/decidim/core/test/shared_examples/resource_endorsed_event_examples.rb
decidim-core-0.26.7 lib/decidim/core/test/shared_examples/resource_endorsed_event_examples.rb
decidim-core-0.26.5 lib/decidim/core/test/shared_examples/resource_endorsed_event_examples.rb
decidim-core-0.27.2 lib/decidim/core/test/shared_examples/resource_endorsed_event_examples.rb
decidim-core-0.27.1 lib/decidim/core/test/shared_examples/resource_endorsed_event_examples.rb
decidim-core-0.26.4 lib/decidim/core/test/shared_examples/resource_endorsed_event_examples.rb
decidim-core-0.27.0 lib/decidim/core/test/shared_examples/resource_endorsed_event_examples.rb
decidim-core-0.26.3 lib/decidim/core/test/shared_examples/resource_endorsed_event_examples.rb
decidim-core-0.27.0.rc2 lib/decidim/core/test/shared_examples/resource_endorsed_event_examples.rb