Sha256: e132daa266a6ac9e0291308e690c8f45fb608fdbfbdaea1f30cc45c347d49afa

Contents?: true

Size: 1.2 KB

Versions: 20

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

require "spec_helper"

module Decidim
  module Admin
    describe UnreportResource do
      let(:reportable) { create(:dummy_resource) }
      let(:moderation) { create(:moderation, reportable: reportable, report_count: 1) }
      let!(:report) { create(:report, moderation: moderation) }
      let(:command) { described_class.new(reportable) }

      context "when everything is ok" do
        it "broadcasts ok" do
          expect { command.call }.to broadcast(:ok)
        end

        it "resets the report count" do
          command.call
          expect(reportable.reload.moderation.report_count).to eq(0)
        end

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

          it "unhides the resource" do
            command.call
            expect(reportable.reload).not_to be_hidden
          end
        end
      end

      context "when the resource is not reported" do
        let(:moderation) { nil }
        let!(:report) { nil }

        it "broadcasts invalid" do
          expect { command.call }.to broadcast(:invalid)
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
decidim-0.6.8 decidim-admin/spec/commands/unreport_resource_spec.rb
decidim-0.6.7 decidim-admin/spec/commands/unreport_resource_spec.rb
decidim-0.6.6 decidim-admin/spec/commands/unreport_resource_spec.rb
decidim-0.6.5 decidim-admin/spec/commands/unreport_resource_spec.rb
decidim-0.6.4 decidim-admin/spec/commands/unreport_resource_spec.rb
decidim-0.6.3 decidim-admin/spec/commands/unreport_resource_spec.rb
decidim-0.6.2 decidim-admin/spec/commands/unreport_resource_spec.rb
decidim-0.6.1 decidim-admin/spec/commands/unreport_resource_spec.rb
decidim-0.6.0 decidim-admin/spec/commands/unreport_resource_spec.rb
decidim-0.5.1 decidim-admin/spec/commands/unreport_resource_spec.rb
decidim-0.5.0 decidim-admin/spec/commands/unreport_resource_spec.rb
decidim-0.4.4 decidim-admin/spec/commands/unreport_resource_spec.rb
decidim-0.4.3 decidim-admin/spec/commands/unreport_resource_spec.rb
decidim-0.4.2 decidim-admin/spec/commands/unreport_resource_spec.rb
decidim-0.4.1 decidim-admin/spec/commands/unreport_resource_spec.rb
decidim-0.4.0 decidim-admin/spec/commands/unreport_resource_spec.rb
decidim-0.3.2 decidim-admin/spec/commands/unreport_resource_spec.rb
decidim-0.3.1 decidim-admin/spec/commands/unreport_resource_spec.rb
decidim-0.3.0 decidim-admin/spec/commands/unreport_resource_spec.rb
decidim-0.2.0 decidim-admin/spec/commands/unreport_resource_spec.rb