Sha256: f14c0b923ca73ac4789f42dd1e8edef9cc3e9a461c15b8f92054a1015f8f178f
Contents?: true
Size: 1.88 KB
Versions: 1
Compression:
Stored size: 1.88 KB
Contents
# frozen_string_literal: true require "spec_helper" module Decidim module Admin describe CreateCategory, :db do describe "call" do let(:organization) { create(:organization) } let(:participatory_process) { create :participatory_process, organization: organization } let(:form_params) do { "category" => { "name_en" => Decidim::Faker::Localized.paragraph(3), "name_es" => Decidim::Faker::Localized.paragraph(3), "name_ca" => Decidim::Faker::Localized.paragraph(3), "description_en" => Decidim::Faker::Localized.paragraph(3), "description_es" => Decidim::Faker::Localized.paragraph(3), "description_ca" => Decidim::Faker::Localized.paragraph(3) } } end let(:form) do CategoryForm.from_params( form_params, current_process: participatory_process ).with_context( current_organization: organization ) end let(:command) { described_class.new(form, participatory_process) } 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 category" do expect do command.call end.not_to change { Category.count } end end describe "when the form is valid" do it "broadcasts ok" do expect { command.call }.to broadcast(:ok) end it "creates a new category" do expect do command.call end.to change { participatory_process.categories.count }.by(1) end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
decidim-0.1.0 | decidim-admin/spec/commands/create_category_spec.rb |