Sha256: 6fe39298261f48e20de968716ad4ab014536a671d9ad8236ee1626fa64883487

Contents?: true

Size: 1.45 KB

Versions: 9

Compression:

Stored size: 1.45 KB

Contents

# frozen_string_literal: true
require "spec_helper"

module Decidim
  module Admin
    describe StaticPagesController, type: :controller do
      let(:organization) { create :organization }
      let(:user) { create(:user, :admin, :confirmed, organization: organization) }

      before do
        @request.env["decidim.current_organization"] = organization
        sign_in user, scope: :user
      end

      context "when creating a page" do
        it "injects the organization to the form" do
          post :create, params: {}

          expect(assigns(:form).organization).to eq(organization)
        end
      end

      context "when updating a page" do
        let!(:page) { create(:static_page, organization: organization) }

        it "injects the organization to the form" do
          put :update, params: { id: page.id }.with_indifferent_access

          expect(assigns(:form).organization).to eq(organization)
        end

        context "when no slug is given" do
          it "injects it to the form" do
            put :update, params: { id: page.id }.with_indifferent_access

            expect(assigns(:form).slug).to eq(page.slug)
          end
        end

        context "when a slug is given" do
          it "does not overwrite it" do
            put :update, params: { id: page.id, static_page: { slug: "new-slug" } }.with_indifferent_access

            expect(assigns(:form).slug).to eq("new-slug")
          end
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
decidim-0.1.0 decidim-admin/spec/controllers/static_pages_controller_spec.rb
decidim-0.0.8.1 decidim-admin/spec/controllers/static_pages_controller_spec.rb
decidim-0.0.7 decidim-admin/spec/controllers/static_pages_controller_spec.rb
decidim-0.0.6 decidim-admin/spec/controllers/static_pages_controller_spec.rb
decidim-0.0.5 decidim-admin/spec/controllers/static_pages_controller_spec.rb
decidim-0.0.4 decidim-admin/spec/controllers/static_pages_controller_spec.rb
decidim-0.0.3 decidim-admin/spec/controllers/static_pages_controller_spec.rb
decidim-0.0.2 decidim-admin/spec/controllers/static_pages_controller_spec.rb
decidim-0.0.1 decidim-admin/spec/controllers/static_pages_controller_spec.rb