Sha256: e1350bcab8705093e8cfbde910df36c02f5b809dfa0057606f4bec598ace82b7

Contents?: true

Size: 1.14 KB

Versions: 11

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

require "spec_helper"

module Decidim
  module Admin
    describe CreateStaticPage do
      describe "call" do
        let(:organization) { create(:organization) }
        let(:form) { StaticPageForm.from_model(build(:static_page)).with_context(current_organization: organization) }
        let(:command) { described_class.new(form) }

        describe "when the form is not valid" do
          before do
            expect(form).to receive(:invalid?).and_return(true)
          end

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

          it "doesn't create a page" do
            expect do
              command.call
            end.not_to change { StaticPage.count }
          end
        end

        describe "when the form is valid" do
          it "broadcasts ok" do
            expect { command.call }.to broadcast(:ok)
          end

          it "creates a page in the organization" do
            expect do
              command.call
            end.to change { organization.static_pages.count }.by(1)
          end
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
decidim-0.6.8 decidim-admin/spec/commands/create_static_page_spec.rb
decidim-0.6.7 decidim-admin/spec/commands/create_static_page_spec.rb
decidim-0.6.6 decidim-admin/spec/commands/create_static_page_spec.rb
decidim-0.6.5 decidim-admin/spec/commands/create_static_page_spec.rb
decidim-0.6.4 decidim-admin/spec/commands/create_static_page_spec.rb
decidim-0.6.3 decidim-admin/spec/commands/create_static_page_spec.rb
decidim-0.6.2 decidim-admin/spec/commands/create_static_page_spec.rb
decidim-0.6.1 decidim-admin/spec/commands/create_static_page_spec.rb
decidim-0.6.0 decidim-admin/spec/commands/create_static_page_spec.rb
decidim-0.5.1 decidim-admin/spec/commands/create_static_page_spec.rb
decidim-0.5.0 decidim-admin/spec/commands/create_static_page_spec.rb