Sha256: 3a48988c5ab8c92dad79eaea59cae6334eda1fad7739317d4f6ac3555f0e0b62

Contents?: true

Size: 1.87 KB

Versions: 38

Compression:

Stored size: 1.87 KB

Contents

# frozen_string_literal: true

shared_examples "manage moderations" do
  let!(:moderations) do
    reportables.first(reportables.length - 1).map do |reportable|
      moderation = create(:moderation, reportable: reportable, report_count: 1)
      create(:report, moderation: moderation)
      moderation
    end
  end
  let!(:moderation) { moderations.first }
  let!(:hidden_moderations) do
    reportables.last(1).map do |reportable|
      moderation = create(:moderation, reportable: reportable, report_count: 3, hidden_at: Time.current)
      create_list(:report, 3, moderation: moderation, reason: :spam)
      moderation
    end
  end

  before do
    visit participatory_space_path
    click_link "Moderations"
  end

  context "when listing moderations" do
    it "user can review them" do
      moderations.each do |moderation|
        within "tr[data-id=\"#{moderation.id}\"]" do
          expect(page).to have_css("a[href='#{moderation.reportable.reported_content_url}']")
          expect(page).to have_content "Spam"
        end
      end
    end

    it "user can un-report a resource" do
      within "tr[data-id=\"#{moderation.id}\"]" do
        click_link "Unreport"
      end

      expect(page).to have_admin_callout("Resource successfully unreported")
    end

    it "user can hide a resource" do
      within "tr[data-id=\"#{moderation.id}\"]" do
        click_link "Hide"
      end

      expect(page).to have_admin_callout("Resource successfully hidden")
      expect(page).to have_no_content(moderation.reportable.reported_content_url)
    end
  end

  context "when listing hidden resources" do
    it "user can review them" do
      click_link "Hidden"

      hidden_moderations.each do |moderation|
        within "tr[data-id=\"#{moderation.id}\"]" do
          expect(page).to have_css("a[href='#{moderation.reportable.reported_content_url}']")
        end
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
decidim-admin-0.23.6 lib/decidim/admin/test/manage_moderations_examples.rb
decidim-admin-0.23.5 lib/decidim/admin/test/manage_moderations_examples.rb
decidim-admin-0.23.4 lib/decidim/admin/test/manage_moderations_examples.rb
decidim-admin-0.23.3 lib/decidim/admin/test/manage_moderations_examples.rb
decidim-admin-0.23.2 lib/decidim/admin/test/manage_moderations_examples.rb
decidim-admin-0.23.1 lib/decidim/admin/test/manage_moderations_examples.rb
decidim-admin-0.23.1.rc1 lib/decidim/admin/test/manage_moderations_examples.rb
decidim-admin-0.23.0 lib/decidim/admin/test/manage_moderations_examples.rb
decidim-admin-0.22.0 lib/decidim/admin/test/manage_moderations_examples.rb
decidim-admin-0.21.0 lib/decidim/admin/test/manage_moderations_examples.rb
decidim-admin-0.20.1 lib/decidim/admin/test/manage_moderations_examples.rb
decidim-admin-0.20.0 lib/decidim/admin/test/manage_moderations_examples.rb
decidim-admin-0.19.1 lib/decidim/admin/test/manage_moderations_examples.rb
decidim-admin-0.18.1 lib/decidim/admin/test/manage_moderations_examples.rb
decidim-admin-0.19.0 lib/decidim/admin/test/manage_moderations_examples.rb
decidim-admin-0.17.2 lib/decidim/admin/test/manage_moderations_examples.rb
decidim-admin-0.18.0 lib/decidim/admin/test/manage_moderations_examples.rb
decidim-admin-0.17.1 lib/decidim/admin/test/manage_moderations_examples.rb
decidim-admin-0.16.1 lib/decidim/admin/test/manage_moderations_examples.rb
decidim-admin-0.17.0 lib/decidim/admin/test/manage_moderations_examples.rb