Sha256: fde059012a14c47ee0b5b272e806f8fe307c114d4c0b35e5385193601b0106db

Contents?: true

Size: 1.15 KB

Versions: 4

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true
require "spec_helper"

module Decidim
  module Admin
    describe HideResource 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 "hides the resource" do
          command.call
          expect(reportable.reload).to be_hidden
        end
      end

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

        it "broadcasts invalid" do
          expect { command.call }.to broadcast(:invalid)
        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

4 entries across 4 versions & 1 rubygems

Version Path
decidim-0.1.0 decidim-admin/spec/commands/hide_resource_spec.rb
decidim-0.0.8.1 decidim-admin/spec/commands/hide_resource_spec.rb
decidim-0.0.7 decidim-admin/spec/commands/hide_resource_spec.rb
decidim-0.0.6 decidim-admin/spec/commands/hide_resource_spec.rb