adds summary to proposals
This commit is contained in:
@@ -75,7 +75,7 @@ class ProposalsController < ApplicationController
|
|||||||
private
|
private
|
||||||
|
|
||||||
def proposal_params
|
def proposal_params
|
||||||
params.require(:proposal).permit(:title, :question, :description, :external_url, :responsible_name, :tag_list, :terms_of_service, :captcha, :captcha_key)
|
params.require(:proposal).permit(:title, :question, :summary, :description, :external_url, :responsible_name, :tag_list, :terms_of_service, :captcha, :captcha_key)
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_featured_tags
|
def load_featured_tags
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class Proposal < ActiveRecord::Base
|
|||||||
|
|
||||||
validates :title, presence: true
|
validates :title, presence: true
|
||||||
validates :question, presence: true
|
validates :question, presence: true
|
||||||
validates :description, presence: true
|
validates :summary, presence: true
|
||||||
validates :author, presence: true
|
validates :author, presence: true
|
||||||
validates :responsible_name, presence: true
|
validates :responsible_name, presence: true
|
||||||
|
|
||||||
@@ -131,7 +131,6 @@ class Proposal < ActiveRecord::Base
|
|||||||
def validate_description_length
|
def validate_description_length
|
||||||
validator = ActiveModel::Validations::LengthValidator.new(
|
validator = ActiveModel::Validations::LengthValidator.new(
|
||||||
attributes: :description,
|
attributes: :description,
|
||||||
minimum: 10,
|
|
||||||
maximum: Proposal.description_max_length)
|
maximum: Proposal.description_max_length)
|
||||||
validator.validate(self)
|
validator.validate(self)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -16,9 +16,10 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="small-12 column">
|
<div class="small-12 column">
|
||||||
<%= f.label :question, t("proposals.form.proposal_summary") %>
|
<%= f.label :summary, t("proposals.form.proposal_summary") %>
|
||||||
<span class="note"><%= t("proposals.form.proposal_summary_note") %></span>
|
<span class="note"><%= t("proposals.form.proposal_summary_note") %></span>
|
||||||
<textarea rows="4" placeholder="<%= t('proposals.form.proposal_summary') %>"></textarea>
|
<%= f.text_area :summary, rows: 4, maxlength: 200, label: false,
|
||||||
|
placeholder: t('proposals.form.proposal_summary') %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="ckeditor small-12 column">
|
<div class="ckeditor small-12 column">
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<%= l proposal.created_at.to_date %>
|
<%= l proposal.created_at.to_date %>
|
||||||
</p>
|
</p>
|
||||||
<div class="proposal-description">
|
<div class="proposal-description">
|
||||||
<%= link_to proposal.description, proposal %>
|
<%= link_to proposal.summary, proposal %>
|
||||||
<div class="truncate"></div>
|
<div class="truncate"></div>
|
||||||
</div>
|
</div>
|
||||||
<%= render "shared/tags", proposal: proposal, limit: 5 %>
|
<%= render "shared/tags", proposal: proposal, limit: 5 %>
|
||||||
|
|||||||
@@ -58,6 +58,8 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div><%= @proposal.summary %></div>
|
||||||
|
|
||||||
<%= safe_html_with_links @proposal.description %>
|
<%= safe_html_with_links @proposal.description %>
|
||||||
|
|
||||||
<% if @proposal.external_url.present? %>
|
<% if @proposal.external_url.present? %>
|
||||||
|
|||||||
5
db/migrate/20150914173834_add_summary_to_proposals.rb
Normal file
5
db/migrate/20150914173834_add_summary_to_proposals.rb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
class AddSummaryToProposals < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :proposals, :summary, :text, limit: 280
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20150914114019) do
|
ActiveRecord::Schema.define(version: 20150914173834) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
@@ -206,6 +206,7 @@ ActiveRecord::Schema.define(version: 20150914114019) do
|
|||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.string "responsible_name", limit: 60
|
t.string "responsible_name", limit: 60
|
||||||
|
t.text "summary"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "settings", force: :cascade do |t|
|
create_table "settings", force: :cascade do |t|
|
||||||
|
|||||||
@@ -114,6 +114,7 @@ FactoryGirl.define do
|
|||||||
|
|
||||||
factory :proposal do
|
factory :proposal do
|
||||||
sequence(:title) { |n| "Proposal #{n} title" }
|
sequence(:title) { |n| "Proposal #{n} title" }
|
||||||
|
summary 'In summary, what we want is...'
|
||||||
description 'Proposal description'
|
description 'Proposal description'
|
||||||
question 'Proposal question'
|
question 'Proposal question'
|
||||||
external_url 'http://external_documention.es'
|
external_url 'http://external_documention.es'
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ feature 'Proposals' do
|
|||||||
proposal.each do |proposal|
|
proposal.each do |proposal|
|
||||||
within('#proposals') do
|
within('#proposals') do
|
||||||
expect(page).to have_content proposal.title
|
expect(page).to have_content proposal.title
|
||||||
expect(page).to have_css("a[href='#{proposal_path(proposal)}']", text: proposal.description)
|
expect(page).to have_css("a[href='#{proposal_path(proposal)}']", text: proposal.summary)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -59,6 +59,7 @@ feature 'Proposals' do
|
|||||||
visit new_proposal_path
|
visit new_proposal_path
|
||||||
fill_in 'proposal_title', with: 'Help refugees'
|
fill_in 'proposal_title', with: 'Help refugees'
|
||||||
fill_in 'proposal_question', with: '¿Would you like to give assistance to war 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_description', with: 'This is very important because...'
|
||||||
fill_in 'proposal_external_url', with: 'http://rescue.org/refugees'
|
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'
|
||||||
@@ -70,6 +71,7 @@ feature 'Proposals' do
|
|||||||
expect(page).to have_content 'Proposal was successfully created.'
|
expect(page).to have_content 'Proposal was successfully created.'
|
||||||
expect(page).to have_content 'Help refugees'
|
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 '¿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 'This is very important because...'
|
||||||
expect(page).to have_content 'http://rescue.org/refugees'
|
expect(page).to have_content 'http://rescue.org/refugees'
|
||||||
expect(page).to have_content author.name
|
expect(page).to have_content author.name
|
||||||
@@ -83,6 +85,7 @@ feature 'Proposals' do
|
|||||||
visit new_proposal_path
|
visit new_proposal_path
|
||||||
fill_in 'proposal_title', with: 'Help refugees'
|
fill_in 'proposal_title', with: 'Help refugees'
|
||||||
fill_in 'proposal_question', with: '¿Would you like to give assistance to war 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_description', with: 'This is very important because...'
|
||||||
fill_in 'proposal_external_url', with: 'http://rescue.org/refugees'
|
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'
|
||||||
@@ -105,6 +108,7 @@ feature 'Proposals' do
|
|||||||
|
|
||||||
fill_in 'proposal_title', with: 'Help refugees'
|
fill_in 'proposal_title', with: 'Help refugees'
|
||||||
fill_in 'proposal_question', with: '¿Would you like to give assistance to war 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_description', with: 'This is very important because...'
|
||||||
fill_in 'proposal_external_url', with: 'http://rescue.org/refugees'
|
fill_in 'proposal_external_url', with: 'http://rescue.org/refugees'
|
||||||
fill_in 'proposal_captcha', with: correct_captcha_text
|
fill_in 'proposal_captcha', with: correct_captcha_text
|
||||||
@@ -121,6 +125,7 @@ feature 'Proposals' do
|
|||||||
visit new_proposal_path
|
visit new_proposal_path
|
||||||
fill_in 'proposal_title', with: "Great title"
|
fill_in 'proposal_title', with: "Great title"
|
||||||
fill_in 'proposal_question', with: '¿Would you like to give assistance to war 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: 'Very important issue...'
|
fill_in 'proposal_description', with: 'Very important issue...'
|
||||||
fill_in 'proposal_external_url', with: 'http://rescue.org/refugees'
|
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'
|
||||||
@@ -146,6 +151,7 @@ feature 'Proposals' do
|
|||||||
visit new_proposal_path
|
visit new_proposal_path
|
||||||
fill_in 'proposal_title', with: ""
|
fill_in 'proposal_title', with: ""
|
||||||
fill_in 'proposal_question', with: '¿Would you like to give assistance to war 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: 'Very important issue...'
|
fill_in 'proposal_description', with: 'Very important issue...'
|
||||||
fill_in 'proposal_external_url', with: 'http://rescue.org/refugees'
|
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'
|
||||||
@@ -178,6 +184,7 @@ feature 'Proposals' do
|
|||||||
visit new_proposal_path
|
visit new_proposal_path
|
||||||
fill_in 'proposal_title', with: 'Testing an attack'
|
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_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_description', with: '<p>This is <script>alert("an attack");</script></p>'
|
||||||
fill_in 'proposal_external_url', with: 'http://rescue.org/refugees'
|
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'
|
||||||
@@ -200,6 +207,7 @@ feature 'Proposals' do
|
|||||||
visit new_proposal_path
|
visit new_proposal_path
|
||||||
fill_in 'proposal_title', with: 'Testing auto link'
|
fill_in 'proposal_title', with: 'Testing auto link'
|
||||||
fill_in 'proposal_question', with: 'Should I stay or should I go?'
|
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_description', with: '<p>This is a link www.example.org</p>'
|
||||||
fill_in 'proposal_responsible_name', with: 'Isabel Garcia'
|
fill_in 'proposal_responsible_name', with: 'Isabel Garcia'
|
||||||
fill_in 'proposal_captcha', with: correct_captcha_text
|
fill_in 'proposal_captcha', with: correct_captcha_text
|
||||||
@@ -219,6 +227,7 @@ feature 'Proposals' do
|
|||||||
visit new_proposal_path
|
visit new_proposal_path
|
||||||
fill_in 'proposal_title', with: 'Testing auto link'
|
fill_in 'proposal_title', with: 'Testing auto link'
|
||||||
fill_in 'proposal_question', with: 'Should I stay or should I go?'
|
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: "<script>alert('hey')</script> <a href=\"javascript:alert('surprise!')\">click me<a/> http://example.org"
|
fill_in 'proposal_description', with: "<script>alert('hey')</script> <a href=\"javascript:alert('surprise!')\">click me<a/> http://example.org"
|
||||||
fill_in 'proposal_responsible_name', with: 'Isabel Garcia'
|
fill_in 'proposal_responsible_name', with: 'Isabel Garcia'
|
||||||
fill_in 'proposal_captcha', with: correct_captcha_text
|
fill_in 'proposal_captcha', with: correct_captcha_text
|
||||||
@@ -255,6 +264,7 @@ feature 'Proposals' do
|
|||||||
|
|
||||||
fill_in 'proposal_title', with: 'A test with enough characters'
|
fill_in 'proposal_title', with: 'A test with enough characters'
|
||||||
fill_in 'proposal_question', with: '¿Would you like to give assistance to war 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_ckeditor 'proposal_description', with: 'A description with enough characters'
|
||||||
fill_in 'proposal_external_url', with: 'http://rescue.org/refugees'
|
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'
|
||||||
@@ -278,6 +288,7 @@ feature 'Proposals' do
|
|||||||
|
|
||||||
fill_in 'proposal_title', with: 'A test of dangerous strings'
|
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_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_description', with: 'A description suitable for this test'
|
||||||
fill_in 'proposal_external_url', with: 'http://rescue.org/refugees'
|
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'
|
||||||
@@ -331,6 +342,7 @@ feature 'Proposals' do
|
|||||||
|
|
||||||
fill_in 'proposal_title', with: "End child poverty"
|
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_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_description', with: "Let's do something to end child poverty"
|
||||||
fill_in 'proposal_external_url', with: 'http://rescue.org/refugees'
|
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'
|
||||||
@@ -339,6 +351,7 @@ feature 'Proposals' do
|
|||||||
click_button "Save changes"
|
click_button "Save changes"
|
||||||
|
|
||||||
expect(page).to have_content "Proposal was successfully updated."
|
expect(page).to have_content "Proposal was successfully updated."
|
||||||
|
expect(page).to have_content "Basically..."
|
||||||
expect(page).to have_content "End child poverty"
|
expect(page).to have_content "End child poverty"
|
||||||
expect(page).to have_content "Let's do something to end child poverty"
|
expect(page).to have_content "Let's do something to end child poverty"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -22,12 +22,12 @@ describe Proposal do
|
|||||||
expect(proposal).to_not be_valid
|
expect(proposal).to_not be_valid
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#description" do
|
it "should not be valid without a summary" do
|
||||||
it "should be mandatory" do
|
proposal.summary = nil
|
||||||
proposal.description = nil
|
expect(proposal).to_not be_valid
|
||||||
expect(proposal).to_not be_valid
|
end
|
||||||
end
|
|
||||||
|
|
||||||
|
describe "#description" do
|
||||||
it "should be sanitized" do
|
it "should be sanitized" do
|
||||||
proposal.description = "<script>alert('danger');</script>"
|
proposal.description = "<script>alert('danger');</script>"
|
||||||
proposal.valid?
|
proposal.valid?
|
||||||
|
|||||||
Reference in New Issue
Block a user