<% ::Legislation::DraftVersion::VALID_STATUSES.each do |status| %>
<%= f.radio_button :status, status, label: false %>
- <%= f.label t("admin.legislation.draft_versions.statuses.#{status}") %>
+ <%= f.label "status_#{status}", t("admin.legislation.draft_versions.statuses.#{status}") %>
<% end %>
diff --git a/app/views/admin/legislation/processes/index.html.erb b/app/views/admin/legislation/processes/index.html.erb
index 7d4bd2996..a4a0a7f3e 100644
--- a/app/views/admin/legislation/processes/index.html.erb
+++ b/app/views/admin/legislation/processes/index.html.erb
@@ -20,6 +20,8 @@
| <%= t("admin.legislation.processes.process.title") %> |
+ <%= t("admin.legislation.processes.process.status") %> |
+ <%= t("admin.legislation.processes.process.creation_date") %> |
<%= t("admin.legislation.processes.process.comments") %> |
|
@@ -30,6 +32,8 @@
<%= link_to process.title, edit_admin_legislation_process_path(process) %>
|
+ <%= t("admin.legislation.processes.process.status_#{process.status}") %> |
+ <%= I18n.l process.created_at.to_date %> |
<%= process.total_comments %> |
<%= link_to t("admin.legislation.processes.index.delete"), admin_legislation_process_path(process),
diff --git a/app/views/layouts/_flash.html.erb b/app/views/layouts/_flash.html.erb
index 9f55b449a..a0f129224 100644
--- a/app/views/layouts/_flash.html.erb
+++ b/app/views/layouts/_flash.html.erb
@@ -5,7 +5,7 @@
×
- <%= flash_message %>
+ <%= flash_message.try(:html_safe) %>
diff --git a/app/views/legislation/draft_versions/_process_header.html.erb b/app/views/legislation/draft_versions/_process_header.html.erb
deleted file mode 100644
index 3c0c94d3f..000000000
--- a/app/views/legislation/draft_versions/_process_header.html.erb
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
- <%= process.title %>
-
-
-
-
-
-
diff --git a/app/views/legislation/draft_versions/changes.html.erb b/app/views/legislation/draft_versions/changes.html.erb
index 0f2015cda..c158b9540 100644
--- a/app/views/legislation/draft_versions/changes.html.erb
+++ b/app/views/legislation/draft_versions/changes.html.erb
@@ -1,6 +1,6 @@
<% provide :title do %><%= "#{@draft_version.title} - #{t('.title')} - #{@process.title}" %><% end %>
-<%= render 'process_header', process: @process %>
+<%= render 'legislation/processes/header', process: @process, header: :small %>
<%= render 'legislation/processes/key_dates', process: @process, phase: :allegations %>
diff --git a/app/views/legislation/draft_versions/show.html.erb b/app/views/legislation/draft_versions/show.html.erb
index 8ab20eea9..a1a1c15a2 100644
--- a/app/views/legislation/draft_versions/show.html.erb
+++ b/app/views/legislation/draft_versions/show.html.erb
@@ -1,6 +1,6 @@
<% provide :title do %><%= "#{@draft_version.title} - #{@process.title}" %><% end %>
-<%= render 'process_header', process: @process %>
+<%= render 'legislation/processes/header', process: @process, header: :small %>
<%= render 'legislation/processes/key_dates', process: @process, phase: :allegations %>
diff --git a/app/views/legislation/processes/_header.html.erb b/app/views/legislation/processes/_header.html.erb
new file mode 100644
index 000000000..c73c732af
--- /dev/null
+++ b/app/views/legislation/processes/_header.html.erb
@@ -0,0 +1,24 @@
+<% if header == :small %>
+
+
+
+ <%= process.title %>
+
+
+
+
+
+
+
+
+ <%= render 'legislation/processes/header_full', process: @process, hidden: true %>
+<% else %>
+ <%= render 'legislation/processes/header_full', process: @process, hidden: false %>
+<% end %>
diff --git a/app/views/legislation/processes/_header_full.html.erb b/app/views/legislation/processes/_header_full.html.erb
index d631f8de5..e3f3420cf 100644
--- a/app/views/legislation/processes/_header_full.html.erb
+++ b/app/views/legislation/processes/_header_full.html.erb
@@ -1,4 +1,4 @@
-
+
<%= t('.title') %>
diff --git a/app/views/legislation/processes/_process.html.erb b/app/views/legislation/processes/_process.html.erb
index 9eac89a7b..87c10cc4c 100644
--- a/app/views/legislation/processes/_process.html.erb
+++ b/app/views/legislation/processes/_process.html.erb
@@ -3,7 +3,7 @@
<%= link_to process.title, process %>
- <%= process.description %>
+ <%= markdown(first_paragraph(process.description)) %>
diff --git a/app/views/legislation/processes/index.html.erb b/app/views/legislation/processes/index.html.erb
index 1400f7854..1d2e6caa3 100644
--- a/app/views/legislation/processes/index.html.erb
+++ b/app/views/legislation/processes/index.html.erb
@@ -19,8 +19,12 @@
- <%= render @processes %>
- <%= paginate @processes %>
+ <% if @processes.any? %>
+ <%= render @processes %>
+ <%= paginate @processes %>
+ <% else %>
+ <%= t(".no_#{@current_filter}_processes") %>
+ <% end %>
diff --git a/app/views/legislation/processes/phase_empty.html.erb b/app/views/legislation/processes/phase_empty.html.erb
index 427339b82..6fb588faf 100644
--- a/app/views/legislation/processes/phase_empty.html.erb
+++ b/app/views/legislation/processes/phase_empty.html.erb
@@ -1,6 +1,6 @@
<% provide :title do %><%= @process.title %><% end %>
-<%= render 'legislation/processes/header_full', process: @process %>
+<%= render 'legislation/processes/header', process: @process, header: :full %>
<%= render 'legislation/processes/key_dates', process: @process, phase: @phase %>
diff --git a/app/views/legislation/processes/phase_not_open.html.erb b/app/views/legislation/processes/phase_not_open.html.erb
index 6bd82c969..0b3b90f01 100644
--- a/app/views/legislation/processes/phase_not_open.html.erb
+++ b/app/views/legislation/processes/phase_not_open.html.erb
@@ -1,6 +1,6 @@
<% provide :title do %><%= @process.title %><% end %>
-<%= render 'legislation/processes/header_full', process: @process %>
+<%= render 'legislation/processes/header', process: @process, header: :full %>
<%= render 'legislation/processes/key_dates', process: @process, phase: @phase %>
diff --git a/app/views/legislation/processes/show.html.erb b/app/views/legislation/processes/show.html.erb
index b24f7668b..410068831 100644
--- a/app/views/legislation/processes/show.html.erb
+++ b/app/views/legislation/processes/show.html.erb
@@ -1,6 +1,6 @@
<% provide :title do %><%= @process.title %><% end %>
-<%= render 'header_full', process: @process %>
+<%= render 'legislation/processes/header', process: @process, header: :full %>
<%= render 'key_dates', process: @process, phase: :debate %>
diff --git a/app/views/legislation/questions/_participation_not_allowed.html.erb b/app/views/legislation/questions/_participation_not_allowed.html.erb
index b330f7fe0..b186c2f5b 100644
--- a/app/views/legislation/questions/_participation_not_allowed.html.erb
+++ b/app/views/legislation/questions/_participation_not_allowed.html.erb
@@ -17,4 +17,8 @@
signin: link_to(t("legislation.questions.participation.signin"), new_user_session_path),
signup: link_to(t("legislation.questions.participation.signup"), new_user_registration_path)).html_safe %>
+<% elsif !@process.open_phase?(:debate) %>
+
+ <%= t("legislation.questions.participation.debate_phase_not_open") %>
+
<% end %>
diff --git a/app/views/legislation/questions/show.html.erb b/app/views/legislation/questions/show.html.erb
index be8e90445..808b5d331 100644
--- a/app/views/legislation/questions/show.html.erb
+++ b/app/views/legislation/questions/show.html.erb
@@ -16,6 +16,13 @@
<% end %>
<% end %>
+ <% elsif @question.first_question_id %>
+ <%= link_to legislation_process_question_path(@process, @question.first_question_id), class: "quiz-next-link" do %>
+ <%= content_tag :div, class: "quiz-next" do %>
+ <%= t('.first_question') %>
+
+ <% end %>
+ <% end %>
<% end %>
@@ -32,7 +39,7 @@
<%= t('.share') %>
-
+
facebook
google_plus
diff --git a/config/i18n-tasks.yml b/config/i18n-tasks.yml
index cd2f77a0b..822fe9e1d 100644
--- a/config/i18n-tasks.yml
+++ b/config/i18n-tasks.yml
@@ -149,6 +149,8 @@ ignore_unused:
- 'views.pagination.*' # kaminari
- 'shared.suggest.*'
- 'invisible_captcha.*'
+ - 'admin.legislation.processes.process.*'
+ - 'legislation.processes.index.*'
# - '{devise,kaminari,will_paginate}.*'
# - 'simple_form.{yes,no}'
# - 'simple_form.{placeholders,hints,labels}.*'
diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml
index a0896d6c4..6362828bd 100755
--- a/config/locales/admin.en.yml
+++ b/config/locales/admin.en.yml
@@ -84,6 +84,14 @@ en:
title: Hidden debates
legislation:
processes:
+ create:
+ notice: 'Process created successfully. Click to visit'
+ error: Process couldn't be created
+ update:
+ notice: 'Process updated successfully. Click to visit'
+ error: Process couldn't be updated
+ destroy:
+ notice: Process deleted successfully
edit:
back: Back
submit_button: Save changes
@@ -113,11 +121,24 @@ en:
process:
title: Process
comments: Comments
+ status: Status
+ creation_date: Creation date
+ status_open: Open
+ status_closed: Closed
+ status_planned: Planned
subnav:
info: Information
draft_texts: Text
questions: Debate
draft_versions:
+ create:
+ notice: 'Draft created successfully. Click to visit'
+ error: Draft couldn't be created
+ update:
+ notice: 'Draft updated successfully. Click to visit'
+ error: Draft couldn't be updated
+ destroy:
+ notice: Draft deleted successfully
edit:
back: Back
submit_button: Save changes
@@ -152,6 +173,14 @@ en:
final_version: Final version
status: Status
questions:
+ create:
+ notice: 'Question created successfully. Click to visit'
+ error: Question couldn't be created
+ update:
+ notice: 'Question updated successfully. Click to visit'
+ error: Question couldn't be updated
+ destroy:
+ notice: Question deleted successfully
edit:
back: Back
title: "Edit “%{question_title}”"
diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml
index 94676c9f0..1b5bf4ffe 100644
--- a/config/locales/admin.es.yml
+++ b/config/locales/admin.es.yml
@@ -82,6 +82,14 @@ es:
title: Debates ocultos
legislation:
processes:
+ create:
+ notice: 'Proceso creado correctamente. Haz click para verlo'
+ error: No se ha podido crear el proceso
+ update:
+ notice: 'Proceso actualizado correctamente. Haz click para verlo'
+ error: No se ha podido actualizar el proceso
+ destroy:
+ notice: Proceso eliminado correctamente
edit:
back: Volver
submit_button: Guardar cambios
@@ -111,11 +119,24 @@ es:
process:
title: Proceso
comments: Comentarios
+ status: Estado
+ creation_date: Fecha creación
+ status_open: Abierto
+ status_closed: Cerrado
+ status_planned: Próximamente
subnav:
info: Información
draft_texts: Texto
questions: Debate
draft_versions:
+ create:
+ notice: 'Borrador creado correctamente. Haz click para verlo'
+ error: No se ha podido crear el borrador
+ update:
+ notice: 'Borrador actualizado correctamente. Haz click para verlo'
+ error: No se ha podido actualizar el borrador
+ destroy:
+ notice: Borrador eliminado correctamente
edit:
back: Volver
submit_button: Guardar cambios
@@ -150,6 +171,14 @@ es:
final_version: Versión final
status: Estado
questions:
+ create:
+ notice: 'Pregunta creada correctamente. Haz click para verla'
+ error: No se ha podido crear la pregunta
+ update:
+ notice: 'Pregunta actualizada correctamente. Haz click para verla'
+ error: No se ha podido actualizar la pregunta
+ destroy:
+ notice: Pregunta eliminada correctamente
edit:
back: Volver
title: "Editar “%{question_title}”"
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 0e1a2c829..fdc7e4e0e 100755
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -239,6 +239,8 @@ en:
text_body: Text
text_comments: Comments
processes:
+ header:
+ view_process_information: View process information
debate:
empty_questions: There aren't any questions
participate: Participate in the debate
@@ -254,6 +256,9 @@ en:
open: Open processes
next: Next
past: Past
+ no_open_processes: There aren't open processes
+ no_next_processes: There aren't planned processes
+ no_past_processes: There aren't past processes
phase_not_open:
not_open: This phase is not open yet
phase_empty:
@@ -278,6 +283,7 @@ en:
answer_question: Submit answer
comments: Comments
next_question: Next question
+ first_question: First question
share: Share
share_twitter: Share on Twitter
share_facebook: Share on Facebook
@@ -291,6 +297,7 @@ en:
unauthenticated: You must %{signin} or %{signup} to participate.
verified_only: Only verified users can participate, %{verify_account}.
verify_account: verify your account
+ debate_phase_not_open: Debate phase has finished and answers are not accepted anymore
locale: English
notifications:
index:
diff --git a/config/locales/es.yml b/config/locales/es.yml
index 3459f3494..f9ec8596b 100755
--- a/config/locales/es.yml
+++ b/config/locales/es.yml
@@ -239,6 +239,8 @@ es:
text_body: Texto
text_comments: Comentarios
processes:
+ header:
+ view_process_information: Ver información del proceso
debate:
empty_questions: No hay preguntas
participate: Realiza tus aportaciones al debate previo participando en los siguientes temas.
@@ -254,6 +256,9 @@ es:
open: Procesos activos
next: Próximamente
past: Terminados
+ no_open_processes: No hay procesos activos
+ no_next_processes: No hay procesos planeados
+ no_past_processes: No hay procesos terminados
phase_not_open:
not_open: Esta fase del proceso todavía no está abierta
phase_empty:
@@ -278,6 +283,7 @@ es:
answer_question: Enviar respuesta
comments: Comentarios
next_question: Siguiente pregunta
+ first_question: Primera pregunta
share: Compartir
share_twitter: Compartir en Twitter
share_facebook: Compartir en Facebook
@@ -291,6 +297,7 @@ es:
unauthenticated: Necesitas %{signin} o %{signup} para participar en el debate.
verified_only: Solo los usuarios verificados pueden participar en el debate, %{verify_account}.
verify_account: verifica tu cuenta
+ debate_phase_not_open: La fase de debate previo ya ha finalizado y en este momento no se aceptan respuestas
locale: Español
notifications:
index:
diff --git a/spec/features/legislation/processes_spec.rb b/spec/features/legislation/processes_spec.rb
index 8ae51c559..66356dff8 100644
--- a/spec/features/legislation/processes_spec.rb
+++ b/spec/features/legislation/processes_spec.rb
@@ -4,6 +4,17 @@ feature 'Legislation' do
context 'processes home page' do
+ scenario 'Processes can be listed' do
+ visit legislation_processes_path
+ expect(page).to have_text "There aren't open processes"
+
+ visit legislation_processes_path(filter: 'next')
+ expect(page).to have_text "There aren't planned processes"
+
+ visit legislation_processes_path(filter: 'past')
+ expect(page).to have_text "There aren't past processes"
+ end
+
scenario 'Processes can be listed' do
processes = create_list(:legislation_process, 3)
diff --git a/spec/helpers/text_helper_spec.rb b/spec/helpers/text_helper_spec.rb
new file mode 100644
index 000000000..cc9300b7f
--- /dev/null
+++ b/spec/helpers/text_helper_spec.rb
@@ -0,0 +1,17 @@
+require 'rails_helper'
+
+describe TextHelper do
+
+ describe "#first_paragraph" do
+ it "should return the first paragraph of a text" do
+ text = "\n\nThis is the first paragraph\n\nThis is the second paragraph\n"
+ expect(first_paragraph(text)).to eq("This is the first paragraph")
+ end
+
+ it "should return blank if the text is blank" do
+ expect(first_paragraph("")).to eq("")
+ expect(first_paragraph(nil)).to eq("")
+ end
+ end
+
+end
diff --git a/spec/models/legislation/process_spec.rb b/spec/models/legislation/process_spec.rb
index 4fbfeb587..fd83d8989 100644
--- a/spec/models/legislation/process_spec.rb
+++ b/spec/models/legislation/process_spec.rb
@@ -1,10 +1,10 @@
require 'rails_helper'
RSpec.describe Legislation::Process, type: :model do
- let(:legislation_process) { build(:legislation_process) }
+ let(:process) { create(:legislation_process) }
it "should be valid" do
- expect(legislation_process).to be_valid
+ expect(process).to be_valid
end
describe "date ranges validations" do
@@ -76,8 +76,6 @@ RSpec.describe Legislation::Process, type: :model do
describe "#open_phase?" do
it "checks debate phase" do
- process = create(:legislation_process)
-
# future
process.update_attributes(debate_start_date: Date.current + 2.days, debate_end_date: Date.current + 3.days)
expect(process.open_phase?(:debate)).to be false
@@ -96,7 +94,6 @@ RSpec.describe Legislation::Process, type: :model do
end
it "checks allegations phase" do
- process = create(:legislation_process)
# future
process.update_attributes(allegations_start_date: Date.current + 2.days, allegations_end_date: Date.current + 3.days)
@@ -116,8 +113,6 @@ RSpec.describe Legislation::Process, type: :model do
end
it "checks draft publication phase" do
- process = create(:legislation_process)
-
# future
process.update_attributes(draft_publication_date: Date.current + 2.days)
expect(process.open_phase?(:draft_publication)).to be false
@@ -132,8 +127,6 @@ RSpec.describe Legislation::Process, type: :model do
end
it "checks final version publication phase" do
- process = create(:legislation_process)
-
# future
process.update_attributes(final_publication_date: Date.current + 2.days)
expect(process.open_phase?(:final_version_publication)).to be false
@@ -150,8 +143,6 @@ RSpec.describe Legislation::Process, type: :model do
describe "#show_phase?" do
it "checks debate phase" do
- process = create(:legislation_process)
-
# future
process.update_attributes(debate_start_date: Date.current + 2.days, debate_end_date: Date.current + 3.days)
expect(process.show_phase?(:debate)).to be false
@@ -170,8 +161,6 @@ RSpec.describe Legislation::Process, type: :model do
end
it "checks allegations phase" do
- process = create(:legislation_process)
-
# future
process.update_attributes(allegations_start_date: Date.current + 2.days, allegations_end_date: Date.current + 3.days)
expect(process.show_phase?(:allegations)).to be false
@@ -190,8 +179,6 @@ RSpec.describe Legislation::Process, type: :model do
end
it "checks draft publication phase" do
- process = create(:legislation_process)
-
# future
process.update_attributes(draft_publication_date: Date.current + 2.days)
expect(process.show_phase?(:draft_publication)).to be false
@@ -206,8 +193,6 @@ RSpec.describe Legislation::Process, type: :model do
end
it "checks final version publication phase" do
- process = create(:legislation_process)
-
# future
process.update_attributes(final_publication_date: Date.current + 2.days)
expect(process.show_phase?(:final_version_publication)).to be false
@@ -221,4 +206,20 @@ RSpec.describe Legislation::Process, type: :model do
expect(process.show_phase?(:final_version_publication)).to be true
end
end
+
+ describe "#status" do
+ it "should detect planned phase" do
+ process.update_attributes(start_date: Date.current + 2.days)
+ expect(process.status).to eq(:planned)
+ end
+
+ it "should detect closed phase" do
+ process.update_attributes(end_date: Date.current - 2.days)
+ expect(process.status).to eq(:closed)
+ end
+
+ it "should detect open phase" do
+ expect(process.status).to eq(:open)
+ end
+ end
end
diff --git a/spec/models/legislation/question_spec.rb b/spec/models/legislation/question_spec.rb
index 660f87cd2..216b9cbfd 100644
--- a/spec/models/legislation/question_spec.rb
+++ b/spec/models/legislation/question_spec.rb
@@ -1,10 +1,10 @@
require 'rails_helper'
RSpec.describe Legislation::Question, type: :model do
- let(:legislation_question) { build(:legislation_question) }
+ let(:question) { create(:legislation_question) }
it "should be valid" do
- expect(legislation_question).to be_valid
+ expect(question).to be_valid
end
context "can be deleted" do
@@ -17,7 +17,6 @@ RSpec.describe Legislation::Question, type: :model do
end
example "when it has options but no answers" do
- question = create(:legislation_question)
create(:legislation_question_option, question: question, value: "Yes")
create(:legislation_question_option, question: question, value: "No")
@@ -27,7 +26,6 @@ RSpec.describe Legislation::Question, type: :model do
end
example "when it has options and answers" do
- question = create(:legislation_question)
option_1 = create(:legislation_question_option, question: question, value: "Yes")
option_2 = create(:legislation_question_option, question: question, value: "No")
create(:legislation_answer, question: question, question_option: option_1)
@@ -38,4 +36,27 @@ RSpec.describe Legislation::Question, type: :model do
end.to change { Legislation::Question.count }.by(-1)
end
end
+
+ describe "#next_question_id" do
+ let!(:question1) { create(:legislation_question) }
+ let!(:question2) { create(:legislation_question, legislation_process_id: question1.legislation_process_id) }
+
+ it "should return the next question" do
+ expect(question1.next_question_id).to eq(question2.id)
+ end
+
+ it "should return nil" do
+ expect(question2.next_question_id).to be_nil
+ end
+ end
+
+ describe "#first_question_id" do
+ let!(:question1) { create(:legislation_question) }
+ let!(:question2) { create(:legislation_question, legislation_process_id: question1.legislation_process_id) }
+
+ it "should return the first question" do
+ expect(question1.first_question_id).to eq(question1.id)
+ expect(question2.first_question_id).to eq(question1.id)
+ end
+ end
end
|