Sha256: dc977e7a410249953c048bf8c3e5075d4b3fde47c9ae0fa6b1125cceebf8ba72

Contents?: true

Size: 1.61 KB

Versions: 9

Compression:

Stored size: 1.61 KB

Contents

# frozen_string_literal: true

require "spec_helper"

module Decidim
  module Pages
    module Admin
      describe UpdatePage, :db do
        let(:current_organization) { create(:organization) }
        let(:participatory_process) { create(:participatory_process, organization: current_organization) }
        let(:feature) { create(:feature, manifest_name: "pages", participatory_process: participatory_process) }
        let(:page) { create(:page, feature: feature) }
        let(:form_params) do
          {
            "body" => page.body,
            "page" => {
              "commentable" => false
            }
          }
        end
        let(:form) do
          PageForm.from_params(
            form_params
          ).with_context(
            current_organization: current_organization
          )
        end
        let(:command) { described_class.new(form, page) }

        describe "when the form is invalid" 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 update the page" do
            expect(page).not_to receive(:update_attributes!)
            command.call
          end
        end

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

          it "creates a new page with the same name as the feature" do
            expect(page).to receive(:update_attributes!)
            command.call
          end
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
decidim-0.4.4 decidim-pages/spec/commands/update_page_spec.rb
decidim-0.4.3 decidim-pages/spec/commands/update_page_spec.rb
decidim-0.4.2 decidim-pages/spec/commands/update_page_spec.rb
decidim-0.4.1 decidim-pages/spec/commands/update_page_spec.rb
decidim-0.4.0 decidim-pages/spec/commands/update_page_spec.rb
decidim-0.3.2 decidim-pages/spec/commands/update_page_spec.rb
decidim-0.3.1 decidim-pages/spec/commands/update_page_spec.rb
decidim-0.3.0 decidim-pages/spec/commands/update_page_spec.rb
decidim-0.2.0 decidim-pages/spec/commands/update_page_spec.rb