Sha256: 8d82b9b8b0b7a54d5dde75e1e044b6ae75b72c90c3b274f19555247e994517dd

Contents?: true

Size: 1.41 KB

Versions: 8

Compression:

Stored size: 1.41 KB

Contents

# frozen_string_literal: true

require "spec_helper"

module Decidim
  module Proposals
    describe ProposalsController, type: :controller do
      let(:user) { create(:user, :confirmed, organization: feature.organization) }

      routes do
        Decidim::Proposals::Engine.routes
      end

      before do
        @request.env["decidim.current_organization"] = feature.organization
        @request.env["decidim.current_participatory_process"] = feature.participatory_process
        @request.env["decidim.current_feature"] = feature
        sign_in user
      end

      let(:params) do
        {
          feature_id: feature.id,
          participatory_process_id: feature.participatory_process.id
        }
      end

      describe "POST create" do
        context "when creation is not enabled" do
          let(:feature) { create(:proposal_feature) }

          it "raises an error" do
            expect(CreateProposal).not_to receive(:call)

            post :create, params: params

            expect(flash[:alert]).not_to be_empty
            expect(response).to have_http_status(302)
          end
        end

        context "when creation is enabled" do
          let(:feature) { create(:proposal_feature, :with_creation_enabled) }

          it "creates a proposal" do
            expect(CreateProposal).to receive(:call)

            post :create, params: params
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
decidim-0.4.3 decidim-proposals/spec/controllers/decidim/proposals_controller_spec.rb
decidim-0.4.2 decidim-proposals/spec/controllers/decidim/proposals_controller_spec.rb
decidim-0.4.1 decidim-proposals/spec/controllers/decidim/proposals_controller_spec.rb
decidim-0.4.0 decidim-proposals/spec/controllers/decidim/proposals_controller_spec.rb
decidim-0.3.2 decidim-proposals/spec/controllers/decidim/proposals_controller_spec.rb
decidim-0.3.1 decidim-proposals/spec/controllers/decidim/proposals_controller_spec.rb
decidim-0.3.0 decidim-proposals/spec/controllers/decidim/proposals_controller_spec.rb
decidim-0.2.0 decidim-proposals/spec/controllers/decidim/proposals_controller_spec.rb