Sha256: be3ce1c4e0111e1e2ccbf1aa8684fa45fad9525aadf15577c9795697cc48978f

Contents?: true

Size: 1.52 KB

Versions: 23

Compression:

Stored size: 1.52 KB

Contents

# frozen_string_literal: true

require "spec_helper"

shared_examples_for "reportable" do
  let(:user) { create(:user, organization: subject.organization) }
  let(:participatory_space) { subject.feature.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.reported_by?(user)).to be_falsey }
    end

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

  context "#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) }
      it { expect(subject).to be_hidden }
    end
  end

  context "#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
      it { expect(subject).to be_reported }
    end
  end
end

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
decidim-core-0.7.4 lib/decidim/core/test/shared_examples/reportable.rb
decidim-core-0.7.3 lib/decidim/core/test/shared_examples/reportable.rb
decidim-core-0.7.2 lib/decidim/core/test/shared_examples/reportable.rb
decidim-core-0.7.1 lib/decidim/core/test/shared_examples/reportable.rb
decidim-core-0.7.0 lib/decidim/core/test/shared_examples/reportable.rb
decidim-core-0.6.8 lib/decidim/core/test/shared_examples/reportable.rb
decidim-0.6.8 decidim-core/lib/decidim/core/test/shared_examples/reportable.rb
decidim-core-0.6.7 lib/decidim/core/test/shared_examples/reportable.rb
decidim-0.6.7 decidim-core/lib/decidim/core/test/shared_examples/reportable.rb
decidim-core-0.6.6 lib/decidim/core/test/shared_examples/reportable.rb
decidim-0.6.6 decidim-core/lib/decidim/core/test/shared_examples/reportable.rb
decidim-core-0.6.5 lib/decidim/core/test/shared_examples/reportable.rb
decidim-0.6.5 decidim-core/lib/decidim/core/test/shared_examples/reportable.rb
decidim-core-0.6.4 lib/decidim/core/test/shared_examples/reportable.rb
decidim-0.6.4 decidim-core/lib/decidim/core/test/shared_examples/reportable.rb
decidim-core-0.6.3 lib/decidim/core/test/shared_examples/reportable.rb
decidim-0.6.3 decidim-core/lib/decidim/core/test/shared_examples/reportable.rb
decidim-core-0.6.2 lib/decidim/core/test/shared_examples/reportable.rb
decidim-0.6.2 decidim-core/lib/decidim/core/test/shared_examples/reportable.rb
decidim-core-0.6.1 lib/decidim/core/test/shared_examples/reportable.rb