From ae27eba2b5d422c49494807ad91e9e0362f049ed Mon Sep 17 00:00:00 2001 From: Bertocq Date: Fri, 2 Jun 2017 18:34:56 +0200 Subject: [PATCH 1/5] Add summary column to Legislative Processes table --- .../20170602162155_add_summary_to_legislative_process.rb | 5 +++++ db/schema.rb | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20170602162155_add_summary_to_legislative_process.rb diff --git a/db/migrate/20170602162155_add_summary_to_legislative_process.rb b/db/migrate/20170602162155_add_summary_to_legislative_process.rb new file mode 100644 index 000000000..7ac9d2255 --- /dev/null +++ b/db/migrate/20170602162155_add_summary_to_legislative_process.rb @@ -0,0 +1,5 @@ +class AddSummaryToLegislativeProcess < ActiveRecord::Migration + def change + add_column :legislation_processes, :summary, :text, limit: 280 + end +end diff --git a/db/schema.rb b/db/schema.rb index 6e2c2214e..7e49bdfc7 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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 From a33341ec52fa50062518859b19bbfe16b26d6eb8 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Fri, 2 Jun 2017 19:17:49 +0200 Subject: [PATCH 2/5] Increase admin legislative process feature spec to also check detail and list views --- .../admin/legislation/processes_spec.rb | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/spec/features/admin/legislation/processes_spec.rb b/spec/features/admin/legislation/processes_spec.rb index 72937a787..f34e93d3d 100644 --- a/spec/features/admin/legislation/processes_spec.rb +++ b/spec/features/admin/legislation/processes_spec.rb @@ -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 From c05744b846bd56c076b4f918321babc85d361806 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Fri, 2 Jun 2017 19:19:10 +0200 Subject: [PATCH 3/5] Add summary field to the admin form for Legislative Processes, plus placeholder translations --- .../admin/legislation/processes_controller.rb | 3 +-- .../admin/legislation/processes/_form.html.erb | 13 +++++++++++++ config/locales/admin.en.yml | 1 + config/locales/admin.es.yml | 1 + 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/controllers/admin/legislation/processes_controller.rb b/app/controllers/admin/legislation/processes_controller.rb index 8cc678151..268ef35c1 100644 --- a/app/controllers/admin/legislation/processes_controller.rb +++ b/app/controllers/admin/legislation/processes_controller.rb @@ -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, diff --git a/app/views/admin/legislation/processes/_form.html.erb b/app/views/admin/legislation/processes/_form.html.erb index 89fd114a1..75c47aa39 100644 --- a/app/views/admin/legislation/processes/_form.html.erb +++ b/app/views/admin/legislation/processes/_form.html.erb @@ -164,6 +164,19 @@ +
+
+ <%= f.label :summary %> + <%= t('admin.legislation.processes.form.use_markdown') %> +
+
+ <%= f.text_area :summary, + label: false, + rows: 2, + placeholder: t('admin.legislation.processes.form.summary_placeholder') %> +
+
+
<%= f.label :description %> diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index 49cb23ff0..1f7eef0a5 100755 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -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 diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml index 64e899312..bdcfa2e6e 100644 --- a/config/locales/admin.es.yml +++ b/config/locales/admin.es.yml @@ -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 From 2c76f1cb3b981884851265f430880c776dd75d06 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Fri, 2 Jun 2017 19:19:23 +0200 Subject: [PATCH 4/5] Show legislative process summary on list, keep first description paragraph as fallback --- app/views/legislation/processes/_process.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/legislation/processes/_process.html.erb b/app/views/legislation/processes/_process.html.erb index c70d71a6e..77ee985d9 100644 --- a/app/views/legislation/processes/_process.html.erb +++ b/app/views/legislation/processes/_process.html.erb @@ -13,7 +13,7 @@
- <%= markdown(first_paragraph(process.description)) %> + <%= markdown(process.summary.present? ? process.summary : first_paragraph(process.description)) %>
From 8d0e76bcd3c4951603894c2ba8705d6cf8d0cb59 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Fri, 2 Jun 2017 19:19:41 +0200 Subject: [PATCH 5/5] Add summary field to Legislative Processes factory and at dev_seed --- db/dev_seeds.rb | 3 ++- spec/factories.rb | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/db/dev_seeds.rb b/db/dev_seeds.rb index b45eff5d8..a787edbde 100644 --- a/db/dev_seeds.rb +++ b/db/dev_seeds.rb @@ -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 👍" \ No newline at end of file +puts "All dev seeds created successfuly 👍" diff --git a/spec/factories.rb b/spec/factories.rb index af1120089..ed89ec154 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -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