Sha256: 4da0de722a48530e53048bc5566090cbc04a1d8f6bac6dcdcaa6c040e3f3a346

Contents?: true

Size: 1.6 KB

Versions: 17

Compression:

Stored size: 1.6 KB

Contents

# frozen_string_literal: true

shared_context "with editor content containing hashtags and mentions" do
  let(:hashtag) { create(:hashtag, organization:) }
  let(:hashtag2) { create(:hashtag, organization:) }
  let(:user) { create(:user, :confirmed, organization:) }
  let(:user2) { create(:user, :confirmed, organization:) }
  let(:user_group) { create(:user_group, :confirmed, organization:) }
  let(:user_group2) { create(:user_group, :confirmed, organization:) }

  let(:html) do
    <<~HTML
      <p>Paragraph with a hashtag #{hashtag.to_global_id} and another hashtag #{hashtag2.to_global_id}</p>
      <p>Paragraph with a user mention #{user.to_global_id} and another user mention #{user2.to_global_id}</p>
      <p>Paragraph with a user group mention #{user_group.to_global_id} and another user group mention #{user_group2.to_global_id}</p>
    HTML
  end
  let(:editor_html) do
    <<~HTML
      <p>Paragraph with a hashtag #{html_hashtag(hashtag)} and another hashtag #{html_hashtag(hashtag2)}</p>
      <p>Paragraph with a user mention #{html_mention(user)} and another user mention #{html_mention(user2)}</p>
      <p>Paragraph with a user group mention #{html_mention(user_group)} and another user group mention #{html_mention(user_group2)}</p>
    HTML
  end

  def html_hashtag(hashtag)
    %(<span data-type="hashtag" data-label="##{hashtag.name}">##{hashtag.name}</span>)
  end

  def html_mention(mentionable)
    mention = "@#{mentionable.nickname}"
    label = "#{mention} (#{CGI.escapeHTML(mentionable.name)})"
    %(<span data-type="mention" data-id="#{mention}" data-label="#{label}">#{label}</span>)
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

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