Merge pull request #1605 from bertocq/feature/legislation_process_summary

Legislative Process summary
This commit is contained in:
Raimond Garcia
2017-06-08 11:54:38 +02:00
committed by GitHub
10 changed files with 53 additions and 7 deletions

View File

@@ -35,8 +35,7 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll
def process_params
params.require(:legislation_process).permit(
:title,
:description_summary,
:target_summary,
:summary,
:description,
:target,
:how_to_participate,

View File

@@ -164,6 +164,19 @@
</div>
</div>
<div class="row">
<div class="small-12 medium-4 column">
<%= f.label :summary %>
<small><%= t('admin.legislation.processes.form.use_markdown') %></small>
</div>
<div class="small-12 medium-8 column">
<%= f.text_area :summary,
label: false,
rows: 2,
placeholder: t('admin.legislation.processes.form.summary_placeholder') %>
</div>
</div>
<div class="row">
<div class="small-12 medium-4 column">
<%= f.label :description %>

View File

@@ -13,7 +13,7 @@
</div>
<div class="small-12 medium-11 column end">
<%= markdown(first_paragraph(process.description)) %>
<%= markdown(process.summary.present? ? process.summary : first_paragraph(process.description)) %>
</div>
</div>

View File

@@ -206,6 +206,7 @@ en:
end: End
use_markdown: Use Markdown to format the text
title_placeholder: The title of the process
summary_placeholder: Short summary of the description
description_placeholder: Add a description of the process
target_placeholder: Describe who is the target of the process
how_to_participate_placeholder: Describe how to participate

View File

@@ -206,6 +206,7 @@ es:
end: Fin
use_markdown: Usa Markdown para formatear el texto
title_placeholder: Escribe el título del proceso
summary_placeholder: Resumen corto de la descripción
description_placeholder: Añade una descripción del proceso
target_placeholder: Describe a quién va dirigido
how_to_participate_placeholder: Describe cómo participar

View File

@@ -634,6 +634,7 @@ print "Creating legislation processes"
(1..5).each do |i|
process = ::Legislation::Process.create!(title: Faker::Lorem.sentence(3).truncate(60),
description: Faker::Lorem.paragraphs.join("\n\n"),
summary: Faker::Lorem.paragraph,
target: Faker::Lorem.paragraphs.join("\n\n"),
how_to_participate: Faker::Lorem.paragraphs.join("\n\n"),
additional_info: Faker::Lorem.paragraphs.join("\n\n"),
@@ -657,4 +658,4 @@ end
end
puts ""
puts "All dev seeds created successfuly 👍"
puts "All dev seeds created successfuly 👍"

View File

@@ -0,0 +1,5 @@
class AddSummaryToLegislativeProcess < ActiveRecord::Migration
def change
add_column :legislation_processes, :summary, :text, limit: 280
end
end

View File

@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170519084239) do
ActiveRecord::Schema.define(version: 20170602162155) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -418,6 +418,7 @@ ActiveRecord::Schema.define(version: 20170519084239) do
t.datetime "hidden_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.text "summary"
end
add_index "legislation_processes", ["allegations_end_date"], name: "index_legislation_processes_on_allegations_end_date", using: :btree

View File

@@ -603,6 +603,7 @@ FactoryGirl.define do
factory :legislation_process, class: 'Legislation::Process' do
title "A collaborative legislation process"
description "Description of the process"
summary "Summary of the process"
target "Who will affected by this law?"
how_to_participate "You can participate by answering some questions"
start_date Date.current - 5.days

View File

@@ -39,6 +39,7 @@ feature 'Admin legislation processes' do
click_link "New process"
fill_in 'legislation_process_title', with: 'An example legislation process'
fill_in 'legislation_process_summary', with: 'Summary of the process'
fill_in 'legislation_process_description', with: 'Describing the process'
fill_in 'legislation_process_target', with: 'This thing affects people'
fill_in 'legislation_process_how_to_participate', with: 'You can partipate in this thing by doing...'
@@ -57,12 +58,30 @@ feature 'Admin legislation processes' do
click_button 'Create process'
expect(page).to have_content 'An example legislation process'
expect(page).to have_content 'Process created successfully'
click_link 'Click to visit'
expect(page).to have_content 'An example legislation process'
expect(page).not_to have_content 'Summary of the process'
expect(page).to have_content 'Describing the process'
expect(page).to have_content 'This thing affects people'
visit legislation_processes_path
expect(page).to have_content 'An example legislation process'
expect(page).to have_content 'Summary of the process'
expect(page).not_to have_content 'Describing the process'
expect(page).not_to have_content 'This thing affects people'
end
end
context 'Update' do
scenario 'Deactivate debate phase', :js do
process = create(:legislation_process, title: 'An example legislation process')
scenario 'Deactivate debate phase', js: true do
process = create(:legislation_process,
title: 'An example legislation process',
summary: 'Summarizing the process',
description: 'Description of the process')
visit admin_root_path
within('#side_menu') do
@@ -75,11 +94,16 @@ feature 'Admin legislation processes' do
expect(find("#debate_phase_active")).to be_checked
uncheck "debate_phase_active"
fill_in 'legislation_process_summary', with: ''
click_button "Save changes"
expect(page).to have_content "Process updated successfully"
expect(find("#debate_start_date").value).to be_blank
expect(find("#debate_end_date").value).to be_blank
visit legislation_processes_path
expect(page).not_to have_content 'Summarizing the process'
expect(page).to have_content 'Description of the process'
end
end
end