From 5b129b933fc2cb3428ad58e3cd79debfb504ec5f Mon Sep 17 00:00:00 2001 From: iagirre Date: Thu, 5 Oct 2017 13:38:19 +0200 Subject: [PATCH 1/4] Removed documents from questions (documentable from model and uploader from _form in views) --- app/models/poll/question.rb | 5 ----- app/views/admin/poll/questions/_form.html.erb | 4 ---- 2 files changed, 9 deletions(-) diff --git a/app/models/poll/question.rb b/app/models/poll/question.rb index 1e94e0180..e6ef482a9 100644 --- a/app/models/poll/question.rb +++ b/app/models/poll/question.rb @@ -1,11 +1,6 @@ class Poll::Question < ActiveRecord::Base include Measurable include Searchable - include Documentable - documentable max_documents_allowed: 1, - max_file_size: 3.megabytes, - accepted_content_types: [ "application/pdf" ] - accepts_nested_attributes_for :documents, allow_destroy: true acts_as_paranoid column: :hidden_at include ActsAsParanoidAliases diff --git a/app/views/admin/poll/questions/_form.html.erb b/app/views/admin/poll/questions/_form.html.erb index 56b7ec93f..d97e498f6 100644 --- a/app/views/admin/poll/questions/_form.html.erb +++ b/app/views/admin/poll/questions/_form.html.erb @@ -16,10 +16,6 @@ <%= f.text_field :title, maxlength: Poll::Question.title_max_length %> -
- <%= render 'documents/nested_documents', documentable: @question, f: f %> -
-
<%= f.label :video_url, t("proposals.form.proposal_video_url") %>

<%= t("proposals.form.proposal_video_url_note") %>

From 75d841e2fe4da632c901ab2b745aba3bd1b2ee68 Mon Sep 17 00:00:00 2001 From: iagirre Date: Thu, 5 Oct 2017 15:31:21 +0200 Subject: [PATCH 2/4] Fixed the correct specs and views to make the test pass. --- app/views/admin/poll/questions/show.html.erb | 8 -------- spec/features/admin/poll/questions_spec.rb | 18 ------------------ 2 files changed, 26 deletions(-) diff --git a/app/views/admin/poll/questions/show.html.erb b/app/views/admin/poll/questions/show.html.erb index 7037afd5f..959cc0fd4 100644 --- a/app/views/admin/poll/questions/show.html.erb +++ b/app/views/admin/poll/questions/show.html.erb @@ -56,13 +56,5 @@ <%= @question.video_url %>

<% end %> - - <% if @question.documents.any? %> -

- <%= t("admin.questions.show.documents") %> -
- <%= @question.documents.first.title %> -

- <% end %>
diff --git a/spec/features/admin/poll/questions_spec.rb b/spec/features/admin/poll/questions_spec.rb index 7e103c647..5c8cba9c1 100644 --- a/spec/features/admin/poll/questions_spec.rb +++ b/spec/features/admin/poll/questions_spec.rb @@ -111,22 +111,4 @@ feature 'Admin poll questions' do pending "Mark all city by default when creating a poll question from a successful proposal" - it_behaves_like "nested documentable", - "administrator", - "poll_question", - "new_admin_question_path", - { }, - "documentable_fill_new_valid_poll_question", - "Save", - "Star Wars: Episode IV - A New Hope" - - it_behaves_like "nested documentable", - "administrator", - "poll_question", - "edit_admin_question_path", - { "id": "id" }, - nil, - "Save", - "Changes saved" - end From 82cf1fc28526133c4c3a0d425c4ddb8219125ae0 Mon Sep 17 00:00:00 2001 From: iagirre Date: Thu, 5 Oct 2017 15:55:37 +0200 Subject: [PATCH 3/4] Remove unused i18n-keys: admin.questions.show.documents, value: Documents(1) (en and es) --- config/locales/en/admin.yml | 1 - config/locales/es/admin.yml | 1 - 2 files changed, 2 deletions(-) diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml index 8202695f1..6446c0d05 100644 --- a/config/locales/en/admin.yml +++ b/config/locales/en/admin.yml @@ -594,7 +594,6 @@ en: valid_answers: Valid answers add_answer: "Add answer" video_url: External video - documents: Documents (1) answers: title: Answer description: Description diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml index 3ff3abcb5..1d5f6b86d 100644 --- a/config/locales/es/admin.yml +++ b/config/locales/es/admin.yml @@ -595,7 +595,6 @@ es: add_answer: "Añadir respuesta" description: Descripción video_url: Video externo - documents: Documentos (1) preview: Ver en la web answers: title: Respuesta From b31abb64d75a8028f75eedf2999b2084f961c563 Mon Sep 17 00:00:00 2001 From: iagirre Date: Thu, 5 Oct 2017 17:28:24 +0200 Subject: [PATCH 4/4] Removed the methods not used from nested_documentable specs (the ones that were deleted in the questions specs) and removed also the document params from questions_params (not used anymore). --- app/controllers/admin/poll/questions_controller.rb | 3 +-- spec/shared/features/nested_documentable.rb | 8 +------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/app/controllers/admin/poll/questions_controller.rb b/app/controllers/admin/poll/questions_controller.rb index 107c06740..5cf587735 100644 --- a/app/controllers/admin/poll/questions_controller.rb +++ b/app/controllers/admin/poll/questions_controller.rb @@ -56,8 +56,7 @@ class Admin::Poll::QuestionsController < Admin::Poll::BaseController private def question_params - params.require(:poll_question).permit(:poll_id, :title, :question, :proposal_id, :valid_answers, :video_url, - documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy]) + params.require(:poll_question).permit(:poll_id, :title, :question, :proposal_id, :valid_answers, :video_url) end def search_params diff --git a/spec/shared/features/nested_documentable.rb b/spec/shared/features/nested_documentable.rb index 8780936a7..255f018e5 100644 --- a/spec/shared/features/nested_documentable.rb +++ b/spec/shared/features/nested_documentable.rb @@ -263,7 +263,6 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na end - end end @@ -275,7 +274,7 @@ rescue return end -def documentable_attach_new_file(documentable_factory_name, index, path, success = true) +def documentable_attach_new_file(_documentable_factory_name, index, path, success = true) click_link "Add new document" document = all(".document")[index] document_input = document.find("input[type=file]", visible: false) @@ -318,8 +317,3 @@ def documentable_fill_new_valid_budget_investment fill_in_ckeditor "budget_investment_description", with: "Budget investment description" check :budget_investment_terms_of_service end - -def documentable_fill_new_valid_poll_question - page.select documentable.poll.name, from: 'poll_question_poll_id' - fill_in 'poll_question_title', with: "Star Wars: Episode IV - A New Hope" -end