Merge pull request #3397 from consul/proposals-form

Remove question and external_url fields from proposals and legislation proposals
This commit is contained in:
Alberto
2019-05-17 17:08:56 +02:00
committed by GitHub
35 changed files with 39 additions and 227 deletions

View File

@@ -53,7 +53,7 @@ class Legislation::ProposalsController < Legislation::BaseController
def proposal_params
params.require(:legislation_proposal).permit(:legislation_process_id, :title,
:question, :summary, :description, :video_url, :tag_list,
:summary, :description, :video_url, :tag_list,
:terms_of_service, :geozone_id,
image_attributes: image_attributes,
documents_attributes: [:id, :title, :attachment, :cached_attachment, :user_id])

View File

@@ -52,9 +52,9 @@ class Management::ProposalsController < Management::BaseController
end
def proposal_params
params.require(:proposal).permit(:title, :question, :summary, :description, :external_url,
:video_url, :responsible_name, :tag_list, :terms_of_service,
:geozone_id, :skip_map,
params.require(:proposal).permit(:title, :summary, :description, :video_url,
:responsible_name, :tag_list, :terms_of_service, :geozone_id,
:skip_map,
map_location_attributes: [:latitude, :longitude, :zoom])
end

View File

@@ -96,8 +96,8 @@ class ProposalsController < ApplicationController
private
def proposal_params
params.require(:proposal).permit(:title, :question, :summary, :description, :external_url,
:video_url, :responsible_name, :tag_list, :terms_of_service,
params.require(:proposal).permit(:title, :summary, :description, :video_url,
:responsible_name, :tag_list, :terms_of_service,
:geozone_id, :skip_map, image_attributes: image_attributes,
documents_attributes: [:id, :title, :attachment,
:cached_attachment, :user_id, :_destroy],

View File

@@ -60,7 +60,6 @@ class Legislation::Proposal < ApplicationRecord
def searchable_values
{ title => "A",
question => "B",
author.username => "B",
tag_list.join(" ") => "B",
geozone.try(:name) => "B",

View File

@@ -38,14 +38,12 @@ class Proposal < ApplicationRecord
has_many :polls, as: :related
validates :title, presence: true
validates :question, presence: true
validates :summary, presence: true
validates :author, presence: true
validates :responsible_name, presence: true, unless: :skip_user_verification?
validates :title, length: { in: 4..Proposal.title_max_length }
validates :description, length: { maximum: Proposal.description_max_length }
validates :question, length: { in: 10..Proposal.question_max_length }
validates :responsible_name, length: { in: 6..Proposal.responsible_name_max_length }, unless: :skip_user_verification?
validates :retired_reason, inclusion: { in: RETIRE_OPTIONS, allow_nil: true }
@@ -117,7 +115,6 @@ class Proposal < ApplicationRecord
def searchable_values
{ title => "A",
question => "B",
author.username => "B",
tag_list.join(" ") => "B",
geozone.try(:name) => "B",

View File

@@ -22,13 +22,9 @@
<div class="moderation-description">
<p><small><%= proposal.summary %></small></p>
<%= proposal.description %>
<% if proposal.external_url.present? %>
<p><%= text_with_links proposal.external_url %></p>
<% end %>
<% if proposal.video_url.present? %>
<p><%= text_with_links proposal.video_url %></p>
<% end %>
<p><%= proposal.question %></p>
</div>
</td>
<td class="align-top">

View File

@@ -12,7 +12,6 @@
<%= link_to proposal.title, proposal_path(proposal) %>
<p>
<%= proposal.summary %><br>
<strong><%= proposal.question %></strong>
</p>
</td>
<td>

View File

@@ -4,7 +4,7 @@
<div class="small-12 column">
<div class="additional-document-link">
<p>
<strong><%= t("proposals.show.title_external_url") %></strong>
<strong><%= t("documents.additional") %></strong>
</p>
<%= render partial: "documents/additional_document", collection: documents, as: :document %>
</div>

View File

@@ -59,16 +59,6 @@
<%= safe_html_with_links @proposal.description %>
<% if @proposal.external_url.present? %>
<div class="document-link">
<p>
<span class="icon-document"></span>&nbsp;
<strong><%= t("proposals.show.title_external_url") %></strong>
</p>
<%= text_with_links @proposal.external_url %>
</div>
<% end %>
<% if @proposal.video_url.present? %>
<div class="video-link">
<p>
@@ -80,8 +70,6 @@
<% end %>
<h4><%= @proposal.question %></h4>
<% if feature?(:allow_attached_documents) %>
<%= render "documents/documents",
documents: @proposal.documents,

View File

@@ -10,17 +10,6 @@
<%= f.invisible_captcha :subtitle %>
<div class="small-12 column">
<%= f.label :question, t("proposals.form.proposal_question") %>
<p class="help-text" id="question-help-text">
<%= t("proposals.form.proposal_question_example_html") %>
</p>
<%= f.text_field :question, maxlength: Proposal.question_max_length,
placeholder: t("proposals.form.proposal_question"),
label: false,
aria: {describedby: "question-help-text"} %>
</div>
<div class="small-12 column">
<%= f.label :summary, t("proposals.form.proposal_summary") %>
<p class="help-text" id="summary-help-text"><%= t("proposals.form.proposal_summary_note") %></p>
@@ -41,11 +30,6 @@
aria: {describedby: "video-url-help-text"} %>
</div>
<div class="small-12 column">
<%= f.label :external_url, t("proposals.form.proposal_external_url") %>
<%= f.text_field :external_url, placeholder: t("proposals.form.proposal_external_url"), label: false %>
</div>
<% if feature?(:allow_images) %>
<div class="images small-12 column">
<%= render "images/nested_image", imageable: @proposal, f: f %>

View File

@@ -42,16 +42,6 @@
</div>
<% end %>
<% if @proposal.external_url.present? %>
<div class="document-link">
<p>
<span class="icon-document"></span>&nbsp;
<strong><%= t("proposals.show.title_external_url") %></strong>
</p>
<%= text_with_links @proposal.external_url %>
</div>
<% end %>
<% if @proposal.video_url.present? %>
<div class="video-link">
<p>
@@ -62,10 +52,6 @@
</div>
<% end %>
<% if @proposal.question.present? %>
<h4><%= @proposal.question %></h4>
<% end %>
<% if @proposal.retired? %>
<div id="retired_explanation" class="callout">
<h2>

View File

@@ -27,7 +27,6 @@ Proposal:
id: integer
title: string
description: string
external_url: string
cached_votes_up: integer
comments_count: integer
hot_score: integer

View File

@@ -2,6 +2,7 @@ en:
documents:
title: Documents
max_documents_allowed_reached_html: You have reached the maximum number of documents allowed! <strong>You have to delete one before you can upload another.</strong>
additional: Additional documentation
form:
title: Documents
title_placeholder: Add a descriptive title for the document

View File

@@ -338,9 +338,6 @@ en:
other: Other
form:
geozone: Scope of operation
proposal_external_url: Link to additional documentation
proposal_question: Proposal question
proposal_question_example_html: "Must be summarised in one question with a Yes or No answer"
proposal_responsible_name: Full name of the person submitting the proposal
proposal_responsible_name_note: "(individually or as representative of a collective; will not be displayed publically)"
proposal_summary: Proposal summary
@@ -462,7 +459,6 @@ en:
share: Share
no_notifications: "This proposal has no notifications."
embed_video_title: "Video on %{proposal}"
title_external_url: "Additional documentation"
title_video_url: "External video"
author: Author
draft: Proposal in draft. Cannot yet get supports, nor does it appear in the list of proposals.

View File

@@ -2,6 +2,7 @@ es:
documents:
title: Documentos
max_documents_allowed_reached_html: "¡Has alcanzado el número máximo de documentos permitidos! <strong>Tienes que eliminar uno antes de poder subir otro.</strong>"
additional: Documentación adicional
form:
title: Documentos
title_placeholder: Añade un título descriptivo para el documento

View File

@@ -338,9 +338,6 @@ es:
other: Otra
form:
geozone: Ámbito de actuación
proposal_external_url: Enlace a documentación adicional
proposal_question: Pregunta de la propuesta
proposal_question_example_html: "Debe ser resumida en una pregunta cuya respuesta sea Sí o No"
proposal_responsible_name: Nombre y apellidos de la persona que hace esta propuesta
proposal_responsible_name_note: "(individualmente o como representante de un colectivo; no se mostrará públicamente)"
proposal_summary: Resumen de la propuesta
@@ -462,7 +459,6 @@ es:
share: Compartir
no_notifications: "Esta propuesta no tiene notificaciones."
embed_video_title: "Vídeo en %{proposal}"
title_external_url: "Documentación adicional"
title_video_url: "Vídeo externo"
author: Autor
draft: Propuesta en borrador. Todavía no puede recoger apoyos, ni aparece en la lista de propuestas.

View File

@@ -2,7 +2,6 @@ section "Creating legislation proposals" do
10.times do
Legislation::Proposal.create!(title: Faker::Lorem.sentence(3).truncate(60),
description: Faker::Lorem.paragraphs.join("\n\n"),
question: Faker::Lorem.sentence(3),
summary: Faker::Lorem.paragraph,
author: User.all.sample,
process: Legislation::Process.all.sample,

View File

@@ -28,10 +28,8 @@ section "Creating Proposals" do
description = "<p>#{Faker::Lorem.paragraphs.join("</p><p>")}</p>"
proposal = Proposal.create!(author: author,
title: Faker::Lorem.sentence(3).truncate(60),
question: Faker::Lorem.sentence(3) + "?",
summary: Faker::Lorem.sentence(3),
responsible_name: Faker::Name.name,
external_url: Faker::Internet.url,
description: description,
created_at: rand((Time.current - 1.week)..Time.current),
tag_list: tags.sample(3).join(","),
@@ -51,10 +49,8 @@ section "Creating Archived Proposals" do
months_to_archive_proposals = Setting["months_to_archive_proposals"]
proposal = Proposal.create!(author: author,
title: Faker::Lorem.sentence(3).truncate(60),
question: Faker::Lorem.sentence(3) + "?",
summary: Faker::Lorem.sentence(3),
responsible_name: Faker::Name.name,
external_url: Faker::Internet.url,
description: description,
tag_list: tags.sample(3).join(","),
geozone: Geozone.all.sample,
@@ -73,10 +69,8 @@ section "Creating Successful Proposals" do
description = "<p>#{Faker::Lorem.paragraphs.join("</p><p>")}</p>"
proposal = Proposal.create!(author: author,
title: Faker::Lorem.sentence(3).truncate(60),
question: Faker::Lorem.sentence(3) + "?",
summary: Faker::Lorem.sentence(3),
responsible_name: Faker::Name.name,
external_url: Faker::Internet.url,
description: description,
created_at: rand((Time.current - 1.week)..Time.current),
tag_list: tags.sample(3).join(","),
@@ -94,10 +88,8 @@ section "Creating Successful Proposals" do
description = "<p>#{Faker::Lorem.paragraphs.join("</p><p>")}</p>"
proposal = Proposal.create!(author: author,
title: Faker::Lorem.sentence(4).truncate(60),
question: Faker::Lorem.sentence(6) + "?",
summary: Faker::Lorem.sentence(3),
responsible_name: Faker::Name.name,
external_url: Faker::Internet.url,
description: description,
created_at: rand((Time.current - 1.week)..Time.current),
tag_list: tags.sample(3).join(","),

View File

@@ -0,0 +1,6 @@
class RemoveQuestionAndExternalUrlFromProposals < ActiveRecord::Migration
def change
remove_column :proposals, :question, :string
remove_column :proposals, :external_url, :string
end
end

View File

@@ -0,0 +1,6 @@
class RemoveQuestionAndExternalUrlFromLegislationProposals < ActiveRecord::Migration
def change
remove_column :legislation_proposals, :question, :string
remove_column :legislation_proposals, :external_url, :string
end
end

View File

@@ -729,8 +729,6 @@ ActiveRecord::Schema.define(version: 20190411090023) do
t.integer "legislation_process_id"
t.string "title", limit: 80
t.text "description"
t.string "question"
t.string "external_url"
t.integer "author_id"
t.datetime "hidden_at"
t.integer "flags_count", default: 0
@@ -1174,8 +1172,6 @@ ActiveRecord::Schema.define(version: 20190411090023) do
create_table "proposals", force: :cascade do |t|
t.string "title", limit: 80
t.text "description"
t.string "question"
t.string "external_url"
t.integer "author_id"
t.datetime "hidden_at"
t.integer "flags_count", default: 0
@@ -1205,7 +1201,6 @@ ActiveRecord::Schema.define(version: 20190411090023) do
t.index ["geozone_id"], name: "index_proposals_on_geozone_id", using: :btree
t.index ["hidden_at"], name: "index_proposals_on_hidden_at", using: :btree
t.index ["hot_score"], name: "index_proposals_on_hot_score", using: :btree
t.index ["question"], name: "index_proposals_on_question", using: :btree
t.index ["summary"], name: "index_proposals_on_summary", using: :btree
t.index ["title"], name: "index_proposals_on_title", using: :btree
t.index ["tsv"], name: "index_proposals_on_tsv", using: :gin

View File

@@ -415,10 +415,8 @@ namespace :proposal_actions do
description = "<p>This is an example of a successful proposal with an ideal progress.</p>"
proposal = Proposal.create!(author: author,
title: Faker::Lorem.sentence(3).truncate(60),
question: Faker::Lorem.sentence(3) + "?",
summary: Faker::Lorem.sentence(3),
responsible_name: Faker::Name.name,
external_url: Faker::Internet.url,
description: description,
created_at: Time.now - expected_supports.length.days,
tag_list: "Example",

View File

@@ -3,8 +3,6 @@ FactoryBot.define do
sequence(:title) { |n| "Proposal #{n} title" }
sequence(:summary) { |n| "In summary, what we want is... #{n}" }
description "Proposal description"
question "Proposal question"
external_url "http://external_documention.es"
video_url "https://youtu.be/nhuNb0XtRhQ"
responsible_name "John Snow"
terms_of_service "1"

View File

@@ -22,8 +22,6 @@ feature "Admin hidden proposals" do
expect(page).to have_content(proposal.title)
expect(page).to have_content(proposal.summary)
expect(page).to have_content(proposal.description)
expect(page).to have_content(proposal.question)
expect(page).to have_content(proposal.external_url)
expect(page).to have_content(proposal.video_url)
end

View File

@@ -117,6 +117,10 @@ feature "Admin poll questions" do
click_button "Save"
expect(page).to have_content(proposal.title)
visit admin_questions_path
expect(page).to have_content(proposal.title)
end
scenario "Update" do

View File

@@ -22,10 +22,8 @@ feature "Proposals" do
end
fill_in "proposal_title", with: "Help refugees"
fill_in "proposal_question", with: "¿Would you like to give assistance to war refugees?"
fill_in "proposal_summary", with: "In summary, what we want is..."
fill_in "proposal_description", with: "This is very important because..."
fill_in "proposal_external_url", with: "http://rescue.org/refugees"
fill_in "proposal_video_url", with: "https://www.youtube.com/watch?v=yRYFKcMa_Ek"
check "proposal_terms_of_service"
@@ -34,10 +32,8 @@ feature "Proposals" do
expect(page).to have_content "Proposal created successfully."
expect(page).to have_content "Help refugees"
expect(page).to have_content "¿Would you like to give assistance to war refugees?"
expect(page).to have_content "In summary, what we want is..."
expect(page).to have_content "This is very important because..."
expect(page).to have_content "http://rescue.org/refugees"
expect(page).to have_content "https://www.youtube.com/watch?v=yRYFKcMa_Ek"
expect(page).to have_content user.name
expect(page).to have_content I18n.l(Proposal.last.created_at.to_date)

View File

@@ -125,9 +125,7 @@ feature "Proposals" do
expect(page).to have_content proposal.title
expect(page).to have_content proposal.code
expect(page).to have_content "Proposal question"
expect(page).to have_content "Proposal description"
expect(page).to have_content "http://external_documention.es"
expect(page).to have_content proposal.author.name
expect(page).to have_content I18n.l(proposal.created_at.to_date)
expect(page).to have_selector(avatar(proposal.author.name))
@@ -219,10 +217,8 @@ feature "Proposals" do
visit new_proposal_path
fill_in "proposal_title", with: "Help refugees"
fill_in "proposal_question", with: "¿Would you like to give assistance to war refugees?"
fill_in "proposal_summary", with: "In summary, what we want is..."
fill_in "proposal_description", with: "This is very important because..."
fill_in "proposal_external_url", with: "http://rescue.org/refugees"
fill_in "proposal_video_url", with: "https://www.youtube.com/watch?v=yPQfcG-eimk"
fill_in "proposal_responsible_name", with: "Isabel Garcia"
fill_in "proposal_tag_list", with: "Refugees, Solidarity"
@@ -240,10 +236,8 @@ feature "Proposals" do
click_link "Not now, go to my proposal"
expect(page).to have_content "Help refugees"
expect(page).to have_content "¿Would you like to give assistance to war refugees?"
expect(page).to have_content "In summary, what we want is..."
expect(page).to have_content "This is very important because..."
expect(page).to have_content "http://rescue.org/refugees"
expect(page).to have_content "https://www.youtube.com/watch?v=yPQfcG-eimk"
expect(page).to have_content author.name
expect(page).to have_content "Refugees"
@@ -258,10 +252,8 @@ feature "Proposals" do
visit new_proposal_path
fill_in "proposal_title", with: "I am a bot"
fill_in "proposal_subtitle", with: "This is the honeypot field"
fill_in "proposal_question", with: "This is a question"
fill_in "proposal_summary", with: "This is the summary"
fill_in "proposal_description", with: "This is the description"
fill_in "proposal_external_url", with: "http://google.com/robots.txt"
fill_in "proposal_responsible_name", with: "Some other robot"
check "proposal_terms_of_service"
@@ -280,10 +272,8 @@ feature "Proposals" do
visit new_proposal_path
fill_in "proposal_title", with: "I am a bot"
fill_in "proposal_question", with: "This is a question"
fill_in "proposal_summary", with: "This is the summary"
fill_in "proposal_description", with: "This is the description"
fill_in "proposal_external_url", with: "http://google.com/robots.txt"
fill_in "proposal_responsible_name", with: "Some other robot"
check "proposal_terms_of_service"
@@ -300,10 +290,8 @@ feature "Proposals" do
visit new_proposal_path
fill_in "proposal_title", with: "Help refugees"
fill_in "proposal_question", with: "¿Would you like to give assistance to war refugees?"
fill_in "proposal_summary", with: "In summary, what we want is..."
fill_in "proposal_description", with: "This is very important because..."
fill_in "proposal_external_url", with: "http://rescue.org/refugees"
fill_in "proposal_responsible_name", with: "Isabel Garcia"
fill_in "proposal_responsible_name", with: "Isabel Garcia"
check "proposal_terms_of_service"
@@ -325,10 +313,8 @@ feature "Proposals" do
expect(page).not_to have_selector("#proposal_responsible_name")
fill_in "proposal_title", with: "Help refugees"
fill_in "proposal_question", with: "¿Would you like to give assistance to war refugees?"
fill_in "proposal_summary", with: "In summary, what we want is..."
fill_in "proposal_description", with: "This is very important because..."
fill_in "proposal_external_url", with: "http://rescue.org/refugees"
check "proposal_terms_of_service"
click_button "Create proposal"
@@ -355,10 +341,8 @@ feature "Proposals" do
visit new_proposal_path
fill_in "proposal_title", with: "Testing an attack"
fill_in "proposal_question", with: "¿Would you like to give assistance to war refugees?"
fill_in "proposal_summary", with: "In summary, what we want is..."
fill_in "proposal_description", with: "<p>This is <script>alert('an attack');</script></p>"
fill_in "proposal_external_url", with: "http://rescue.org/refugees"
fill_in "proposal_responsible_name", with: "Isabel Garcia"
check "proposal_terms_of_service"
@@ -380,7 +364,6 @@ feature "Proposals" do
visit new_proposal_path
fill_in "proposal_title", with: "Testing auto link"
fill_in "proposal_question", with: "Should I stay or should I go?"
fill_in "proposal_summary", with: "In summary, what we want is..."
fill_in "proposal_description", with: "<p>This is a link www.example.org</p>"
fill_in "proposal_responsible_name", with: "Isabel Garcia"
@@ -403,7 +386,6 @@ feature "Proposals" do
visit new_proposal_path
fill_in "proposal_title", with: "Testing auto link"
fill_in "proposal_question", with: "Should I stay or should I go?"
fill_in "proposal_summary", with: "In summary, what we want is..."
fill_in "proposal_description", with: js_injection_string
fill_in "proposal_responsible_name", with: "Isabel Garcia"
@@ -440,15 +422,7 @@ feature "Proposals" do
login_as(author)
visit new_proposal_path
fill_in "proposal_title", with: "Help refugees"
fill_in "proposal_question", with: "¿Would you like to give assistance to war refugees?"
fill_in "proposal_summary", with: "In summary, what we want is..."
fill_in "proposal_description", with: "This is very important because..."
fill_in "proposal_external_url", with: "http://rescue.org/refugees"
fill_in "proposal_video_url", with: "https://www.youtube.com/watch?v=yPQfcG-eimk"
fill_in "proposal_responsible_name", with: "Isabel Garcia"
check "proposal_terms_of_service"
fill_in_proposal
click_button "Create proposal"
@@ -470,10 +444,8 @@ feature "Proposals" do
visit new_proposal_path
fill_in "proposal_title", with: "Help refugees"
fill_in "proposal_question", with: "¿Would you like to give assistance to war refugees?"
fill_in "proposal_summary", with: "In summary, what we want is..."
fill_in "proposal_description", with: "This is very important because..."
fill_in "proposal_external_url", with: "http://rescue.org/refugees"
fill_in "proposal_video_url", with: "https://www.youtube.com/watch?v=yPQfcG-eimk"
fill_in "proposal_responsible_name", with: "Isabel Garcia"
check "proposal_terms_of_service"
@@ -629,10 +601,8 @@ feature "Proposals" do
expect(page).to have_current_path(edit_proposal_path(proposal))
fill_in "proposal_title", with: "End child poverty"
fill_in "proposal_question", with: "¿Would you like to give assistance to war refugees?"
fill_in "proposal_summary", with: "Basically..."
fill_in "proposal_description", with: "Let's do something to end child poverty"
fill_in "proposal_external_url", with: "http://rescue.org/refugees"
fill_in "proposal_responsible_name", with: "Isabel Garcia"
click_button "Save changes"
@@ -1833,9 +1803,7 @@ feature "Successful proposals" do
fill_in "proposal_title", with: "Help refugees"
fill_in "proposal_summary", with: "In summary what we want is..."
fill_in "proposal_question", with: "Would you like to?"
fill_in "proposal_description", with: "This is very important because..."
fill_in "proposal_external_url", with: "http://rescue.org/refugees"
fill_in "proposal_video_url", with: "https://www.youtube.com/watch?v=yPQfcG-eimk"
fill_in "proposal_tag_list", with: "Refugees, Solidarity"
check "proposal_terms_of_service"

View File

@@ -70,7 +70,6 @@ feature "Tags" do
visit new_proposal_path
fill_in "proposal_title", with: "Help refugees"
fill_in "proposal_question", with: "¿Would you like to give assistance to war refugees?"
fill_in "proposal_summary", with: "In summary, what we want is..."
fill_in "proposal_description", with: "This is very important because..."
fill_in "proposal_responsible_name", with: "Isabel Garcia"
@@ -97,10 +96,8 @@ feature "Tags" do
visit new_proposal_path
fill_in "proposal_title", with: "Help refugees"
fill_in "proposal_question", with: "¿Would you like to give assistance to war refugees?"
fill_in "proposal_summary", with: "In summary, what we want is..."
fill_in_ckeditor "proposal_description", with: "A description with enough characters"
fill_in "proposal_external_url", with: "http://rescue.org/refugees"
fill_in "proposal_video_url", with: "https://www.youtube.com/watch?v=Ae6gQmhaMn4"
fill_in "proposal_responsible_name", with: "Isabel Garcia"
check "proposal_terms_of_service"
@@ -142,10 +139,8 @@ feature "Tags" do
visit new_proposal_path
fill_in "proposal_title", with: "A test of dangerous strings"
fill_in "proposal_question", with: "¿Would you like to give assistance to war refugees?"
fill_in "proposal_summary", with: "In summary, what we want is..."
fill_in "proposal_description", with: "A description suitable for this test"
fill_in "proposal_external_url", with: "http://rescue.org/refugees"
fill_in "proposal_responsible_name", with: "Isabel Garcia"
check "proposal_terms_of_service"

View File

@@ -1,66 +0,0 @@
require "rails_helper"
describe Proposals do
describe "Move external_url to description" do
let :run_rake_task do
Rake::Task["proposals:move_external_url_to_description"].reenable
Rake.application.invoke_task "proposals:move_external_url_to_description"
end
context "Move external_url to description for Proposals" do
it "When proposal has external_url" do
proposal = create(:proposal, description: "<p>Lorem ipsum dolor sit amet</p>",
external_url: "http://consul.dev")
run_rake_task
proposal.reload
expect(proposal.description).to eq "<p>Lorem ipsum dolor sit amet</p> "\
'<p><a href="http://consul.dev" '\
'target="_blank" rel="nofollow">'\
"http://consul.dev</a></p>"
expect(proposal.external_url).to eq ""
end
it "When proposal has not external_url" do
proposal = create(:proposal, description: "<p>Lorem ipsum dolor sit amet</p>",
external_url: "")
run_rake_task
proposal.reload
expect(proposal.description).to eq "<p>Lorem ipsum dolor sit amet</p>"
expect(proposal.external_url).to eq ""
end
end
context "Move external_url to description for Legislation proposals" do
it "When legislation proposal has external_url" do
legislation_proposal = create(:legislation_proposal, description: "<p>Ut enim ad minim</p>",
external_url: "http://consulproject.org")
run_rake_task
legislation_proposal.reload
expect(legislation_proposal.description).to eq "<p>Ut enim ad minim</p> "\
'<p><a href="http://consulproject.org" '\
'target="_blank" rel="nofollow">'\
"http://consulproject.org</a></p>"
expect(legislation_proposal.external_url).to eq ""
end
it "When legislation proposal has not external_url" do
legislation_proposal = create(:legislation_proposal, description: "<p>Ut enim ad minim</p>",
external_url: "")
run_rake_task
legislation_proposal.reload
expect(legislation_proposal.description).to eq "<p>Ut enim ad minim</p>"
expect(legislation_proposal.external_url).to eq ""
end
end
end
end

View File

@@ -54,23 +54,6 @@ describe Proposal do
end
end
describe "#question" do
it "is not valid without a question" do
proposal.question = nil
expect(proposal).not_to be_valid
end
it "is not valid when very short" do
proposal.question = "abc"
expect(proposal).not_to be_valid
end
it "is not valid when very long" do
proposal.question = "a" * 141
expect(proposal).not_to be_valid
end
end
describe "#video_url" do
it "is not valid when URL is not from Youtube or Vimeo" do
proposal.video_url = "https://twitter.com"
@@ -491,12 +474,6 @@ describe Proposal do
expect(results).to eq([proposal])
end
it "searches by question" do
proposal = create(:proposal, question: "to be or not to be")
results = described_class.search("to be or not to be")
expect(results).to eq([proposal])
end
it "searches by author name" do
author = create(:user, username: "Danny Trejo")
proposal = create(:proposal, author: author)
@@ -575,7 +552,6 @@ describe Proposal do
context "order" do
it "orders by weight" do
proposal_question = create(:proposal, question: "stop corruption")
proposal_title = create(:proposal, title: "stop corruption")
proposal_description = create(:proposal, description: "stop corruption")
proposal_summary = create(:proposal, summary: "stop corruption")
@@ -583,9 +559,8 @@ describe Proposal do
results = described_class.search("stop corruption")
expect(results.first).to eq(proposal_title)
expect(results.second).to eq(proposal_question)
expect(results.third).to eq(proposal_summary)
expect(results.fourth).to eq(proposal_description)
expect(results.second).to eq(proposal_summary)
expect(results.third).to eq(proposal_description)
end
it "orders by weight and then by votes" do

View File

@@ -250,7 +250,6 @@ end
def fill_in_proposal_form
fill_in "proposal_title", with: "Help refugees"
fill_in "proposal_question", with: "¿Would you like to give assistance to war refugees?"
fill_in "proposal_summary", with: "In summary, what we want is..."
end

View File

@@ -365,7 +365,6 @@ end
def documentable_fill_new_valid_proposal
fill_in :proposal_title, with: "Proposal title #{rand(9999)}"
fill_in :proposal_summary, with: "Proposal summary"
fill_in :proposal_question, with: "Proposal question?"
check :proposal_terms_of_service
end

View File

@@ -291,7 +291,6 @@ end
def imageable_fill_new_valid_proposal
fill_in :proposal_title, with: "Proposal title"
fill_in :proposal_summary, with: "Proposal summary"
fill_in :proposal_question, with: "Proposal question?"
check :proposal_terms_of_service
end

View File

@@ -26,6 +26,15 @@ module CommonActions
to receive(:verify_officer_assignment).and_return(true)
end
def fill_in_proposal
fill_in "proposal_title", with: "Help refugees"
fill_in "proposal_summary", with: "In summary what we want is..."
fill_in "proposal_description", with: "This is very important because..."
fill_in "proposal_video_url", with: "https://www.youtube.com/watch?v=yPQfcG-eimk"
fill_in "proposal_responsible_name", with: "Isabel Garcia"
check "proposal_terms_of_service"
end
def set_officing_booth(booth=nil)
booth = create(:poll_booth) if booth.blank?

View File

@@ -1,8 +1,8 @@
module Proposals
def create_successful_proposals
[create(:proposal, title: "Winter is coming", question: "Do you speak it?",
[create(:proposal, title: "Winter is coming",
cached_votes_up: Proposal.votes_needed_for_success + 100),
create(:proposal, title: "Fire and blood", question: "You talking to me?",
create(:proposal, title: "Fire and blood",
cached_votes_up: Proposal.votes_needed_for_success + 1)]
end