Sha256: 19354690f6a91bdae357da6b7fa69a0aab85f644b6b68ce7d970b8ef065336ff

Contents?: true

Size: 1.72 KB

Versions: 37

Compression:

Stored size: 1.72 KB

Contents

# frozen_string_literal: true

require "spec_helper"

shared_examples_for "reportable" do
  context "when reportable" do
    let(:user) { create(:user, organization: subject.organization) }
    let(:participatory_space) { subject.component.participatory_space }
    let(:moderation) { create(:moderation, reportable: subject, participatory_space: participatory_space, report_count: 1) }
    let!(:report) { create(:report, moderation: moderation, user: user) }

    describe "#reported_by?" do
      context "when the resource has not been reported by the given user" do
        let!(:report) { nil }

        it { expect(subject).not_to be_reported_by(user) }
      end

      context "when the resource has been reported" do
        it { expect(subject).to be_reported_by(user) }
      end
    end

    describe "#hidden?" do
      context "when the resource has not been hidden" do
        it { expect(subject).not_to be_hidden }
      end

      context "when the resource has been hidden" do
        let(:moderation) { create(:moderation, reportable: subject, participatory_space: participatory_space, report_count: 1, hidden_at: Time.current) }

        before do
          subject.reload
        end

        it { expect(subject).to be_hidden }
      end
    end

    describe "#reported?" do
      context "when the report count is equal to 0" do
        let(:moderation) { create(:moderation, reportable: subject, participatory_space: participatory_space, report_count: 0) }
        let!(:report) { nil }

        it { expect(subject).not_to be_reported }
      end

      context "when the report count is greater than 0" do
        before do
          subject.reload
        end

        it { expect(subject).to be_reported }
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

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