Skip to content

Commit

Permalink
Remove all references to question and external_url fields
Browse files Browse the repository at this point in the history
  • Loading branch information
decabeza committed Apr 30, 2019
1 parent 4648906 commit f407875
Show file tree
Hide file tree
Showing 11 changed files with 10 additions and 64 deletions.
2 changes: 0 additions & 2 deletions app/models/proposal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
11 changes: 0 additions & 11 deletions app/views/proposals/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 0 additions & 2 deletions lib/tasks/proposal_actions.rake
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 0 additions & 2 deletions spec/features/management/proposals_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
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_video_url", with: "https://www.youtube.com/watch?v=yRYFKcMa_Ek"
Expand All @@ -33,7 +32,6 @@
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 "https://www.youtube.com/watch?v=yRYFKcMa_Ek"
Expand Down
25 changes: 1 addition & 24 deletions spec/features/proposals_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@

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 proposal.author.name
expect(page).to have_content I18n.l(proposal.created_at.to_date)
Expand Down Expand Up @@ -218,7 +217,6 @@
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_video_url", with: "https://www.youtube.com/watch?v=yPQfcG-eimk"
Expand All @@ -238,7 +236,6 @@
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 "https://www.youtube.com/watch?v=yPQfcG-eimk"
Expand All @@ -255,7 +252,6 @@
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_responsible_name", with: "Some other robot"
Expand All @@ -276,10 +272,8 @@

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:https://google.com/robots.txt"
fill_in "proposal_responsible_name", with: "Some other robot"
check "proposal_terms_of_service"

Expand All @@ -296,10 +290,8 @@

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:https://rescue.org/refugees"
fill_in "proposal_responsible_name", with: "Isabel Garcia"
fill_in "proposal_responsible_name", with: "Isabel Garcia"
check "proposal_terms_of_service"
Expand All @@ -321,7 +313,6 @@
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..."
check "proposal_terms_of_service"
Expand Down Expand Up @@ -350,10 +341,8 @@

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:https://rescue.org/refugees"
fill_in "proposal_responsible_name", with: "Isabel Garcia"
check "proposal_terms_of_service"

Expand All @@ -375,7 +364,6 @@

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"
Expand All @@ -398,7 +386,6 @@

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"
Expand Down Expand Up @@ -435,13 +422,7 @@
login_as(author)

visit new_proposal_path

fill_in "proposal_title", with: "Help 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_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"

Expand All @@ -463,10 +444,8 @@
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:https://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"
Expand Down Expand Up @@ -622,7 +601,6 @@
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_responsible_name", with: "Isabel Garcia"
Expand Down Expand Up @@ -1825,7 +1803,6 @@

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_video_url", with: "https://www.youtube.com/watch?v=yPQfcG-eimk"
fill_in "proposal_tag_list", with: "Refugees, Solidarity"
Expand Down
3 changes: 0 additions & 3 deletions spec/features/tags/proposals_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@

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"
Expand All @@ -97,7 +96,6 @@
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_video_url", with: "https://www.youtube.com/watch?v=Ae6gQmhaMn4"
Expand Down Expand Up @@ -141,7 +139,6 @@
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_responsible_name", with: "Isabel Garcia"
Expand Down
17 changes: 0 additions & 17 deletions spec/models/proposal_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,6 @@
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"
Expand Down
1 change: 0 additions & 1 deletion spec/shared/features/mappable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ def do_login_for(user)

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

Expand Down
1 change: 0 additions & 1 deletion spec/shared/features/nested_documentable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,6 @@ def expect_document_has_cached_attachment(index, extension)
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

Expand Down
1 change: 0 additions & 1 deletion spec/shared/features/nested_imageable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ def imageable_attach_new_file(_imageable_factory_name, path, success = true)
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

Expand Down
9 changes: 9 additions & 0 deletions spec/support/common_actions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ def validate_officer
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?

Expand Down

0 comments on commit f407875

Please sign in to comment.