Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/allow to change participatory texts title without uploading file #4761

1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -11,6 +11,7 @@

**Changed**:

- **decidim-proposals** Allow to change participatory texts title without uploading file. [\#4761](https://github.com/decidim/decidim/pull/4761)
- **decidim-proposals** Change collaborative draft contributors permissions [\#4712](https://github.com/decidim/decidim/pull/4712)
- **decidim-admin**: Change admin moderations manager [\#4717](https://github.com/decidim/decidim/pull/4717)

Expand Down
Expand Up @@ -39,6 +39,8 @@ def save_participatory_text_meta(form)
end

def parse_participatory_text_doc(form)
return if form.document.blank?

markdown = DocToMarkdown.new(form.document_text, form.document_type).to_md
parser = MarkdownToProposals.new(form.current_component, form.current_user)
parser.parse(markdown)
Expand Down
Expand Up @@ -12,7 +12,6 @@ class ImportParticipatoryTextForm < Decidim::Form
translatable_attribute :description, String
attribute :document

validates :document, presence: true
validates :title, translatable_presence: true

def default_locale
Expand Down
1 change: 1 addition & 0 deletions decidim-proposals/lib/decidim/proposals/admin_engine.rb
Expand Up @@ -25,6 +25,7 @@ class AdminEngine < ::Rails::Engine
collection do
get :new_import
post :import
patch :import
oriolgual marked this conversation as resolved.
Show resolved Hide resolved
post :publish
end
end
Expand Down
Expand Up @@ -14,12 +14,17 @@ module Admin
participatory_space: create(:participatory_process)
)
end
let(:form_doc) do
instance_double(File,
blank?: false)
end
let(:form) do
instance_double(
ImportParticipatoryTextForm,
current_component: current_component,
title: {},
description: {},
document: form_doc,
document_text: document_file,
document_type: document_type,
current_user: create(:user),
Expand Down
Expand Up @@ -10,7 +10,7 @@ module Admin

let(:user) { create(:user, :confirmed, :admin, organization: component.organization) }
let(:component) { create :proposal_component, :with_participatory_texts_enabled }
let(:document_file) { nil }
let(:document_file) { fixture_file_upload(Decidim::Dev.asset("participatory_text.md")) }
let(:title) { { en: ::Faker::Book.title } }
let(:params) do
{
Expand All @@ -30,6 +30,8 @@ module Admin

describe "POST import" do
context "when the command fails" do
let(:title) { {} }

it "renders new_import template" do
post :import, params: params
expect(response).to render_template(:new_import)
Expand All @@ -38,8 +40,6 @@ module Admin
end

context "when the command succeeds" do
let(:document_file) { fixture_file_upload(Decidim::Dev.asset("participatory_text.md")) }

it "parses the document" do
post :import, params: params
expect(response).to redirect_to participatory_texts_path(component_id: component.id, initiative_slug: "asdf")
Expand Down
Expand Up @@ -46,7 +46,7 @@ module Admin
context "when the document is not valid" do
let(:document_file) { nil }

it { is_expected.to be_invalid }
it { is_expected.to be_valid }
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion decidim-proposals/spec/system/participatory_texts_spec.rb
Expand Up @@ -2,7 +2,7 @@

require "spec_helper"

describe "Proposals", type: :system do
describe "Participatory texts", type: :system do
include_context "with a component"
let(:manifest_name) { "proposals" }

Expand Down