diff --git a/app/controllers/management/proposals_controller.rb b/app/controllers/management/proposals_controller.rb index 2c497299a..f24e94303 100644 --- a/app/controllers/management/proposals_controller.rb +++ b/app/controllers/management/proposals_controller.rb @@ -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 diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index 4372ecc63..5cc9b7e10 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -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], diff --git a/app/models/proposal.rb b/app/models/proposal.rb index dd72d5173..ff5479ad8 100644 --- a/app/models/proposal.rb +++ b/app/models/proposal.rb @@ -117,7 +117,6 @@ class Proposal < ApplicationRecord def searchable_values { title => "A", - question => "B", author.username => "B", tag_list.join(" ") => "B", geozone.try(:name) => "B", diff --git a/app/views/admin/hidden_proposals/index.html.erb b/app/views/admin/hidden_proposals/index.html.erb index c0af9bc59..4e23b8c5b 100644 --- a/app/views/admin/hidden_proposals/index.html.erb +++ b/app/views/admin/hidden_proposals/index.html.erb @@ -22,13 +22,9 @@
<%= proposal.summary %>
<%= proposal.description %> - <% if proposal.external_url.present? %> -<%= text_with_links proposal.external_url %>
- <% end %> <% if proposal.video_url.present? %><%= text_with_links proposal.video_url %>
<% end %> -<%= proposal.question %>
- <%= t("proposals.show.title_external_url") %> + <%= t("documents.additional") %>
<%= render partial: "documents/additional_document", collection: documents, as: :document %>- - <%= t("proposals.show.title_external_url") %> -
- <%= text_with_links @proposal.external_url %> -@@ -62,10 +52,6 @@
#{Faker::Lorem.paragraphs.join("
")}
" 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 = "#{Faker::Lorem.paragraphs.join("
")}
" 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 = "#{Faker::Lorem.paragraphs.join("
")}
" 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(","), diff --git a/db/migrate/20190307165132_remove_question_and_external_url_from_proposals.rb b/db/migrate/20190307165132_remove_question_and_external_url_from_proposals.rb new file mode 100644 index 000000000..42c6dbbbd --- /dev/null +++ b/db/migrate/20190307165132_remove_question_and_external_url_from_proposals.rb @@ -0,0 +1,6 @@ +class RemoveQuestionAndExternalUrlFromProposals < ActiveRecord::Migration + def change + remove_column :proposals, :question, :string + remove_column :proposals, :external_url, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 780a0cea6..a49ab75a7 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -728,7 +728,6 @@ ActiveRecord::Schema.define(version: 20190411090023) do 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 @@ -1172,8 +1171,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 @@ -1203,7 +1200,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 diff --git a/spec/factories/proposals.rb b/spec/factories/proposals.rb index 1b0327559..0821eb168 100644 --- a/spec/factories/proposals.rb +++ b/spec/factories/proposals.rb @@ -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" diff --git a/spec/features/admin/hidden_proposals_spec.rb b/spec/features/admin/hidden_proposals_spec.rb index eb8c69b59..724b8ffea 100644 --- a/spec/features/admin/hidden_proposals_spec.rb +++ b/spec/features/admin/hidden_proposals_spec.rb @@ -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 diff --git a/spec/features/management/proposals_spec.rb b/spec/features/management/proposals_spec.rb index 03519d02d..4475fbdd6 100644 --- a/spec/features/management/proposals_spec.rb +++ b/spec/features/management/proposals_spec.rb @@ -25,7 +25,6 @@ feature "Proposals" do 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" @@ -37,7 +36,6 @@ feature "Proposals" do 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) diff --git a/spec/features/proposals_spec.rb b/spec/features/proposals_spec.rb index a54884e4d..8203c9421 100644 --- a/spec/features/proposals_spec.rb +++ b/spec/features/proposals_spec.rb @@ -127,7 +127,6 @@ feature "Proposals" do 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)) @@ -222,7 +221,6 @@ feature "Proposals" do 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" @@ -243,7 +241,6 @@ feature "Proposals" do 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" @@ -261,7 +258,6 @@ feature "Proposals" do 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" @@ -328,7 +324,6 @@ feature "Proposals" do 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" @@ -442,10 +437,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_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" @@ -632,7 +625,6 @@ feature "Proposals" do 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" @@ -1835,7 +1827,6 @@ feature "Successful proposals" do 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" diff --git a/spec/features/tags/proposals_spec.rb b/spec/features/tags/proposals_spec.rb index eb330b79d..6aec4910c 100644 --- a/spec/features/tags/proposals_spec.rb +++ b/spec/features/tags/proposals_spec.rb @@ -100,7 +100,6 @@ feature "Tags" do 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" @@ -145,7 +144,6 @@ feature "Tags" do 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" diff --git a/spec/models/proposal_spec.rb b/spec/models/proposal_spec.rb index 426e59e70..2eb777d5d 100644 --- a/spec/models/proposal_spec.rb +++ b/spec/models/proposal_spec.rb @@ -491,12 +491,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 +569,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 +576,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 diff --git a/spec/support/common_actions/proposals.rb b/spec/support/common_actions/proposals.rb index 93797935b..2ee198d14 100644 --- a/spec/support/common_actions/proposals.rb +++ b/spec/support/common_actions/proposals.rb @@ -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