Skip to content

Commit

Permalink
Indicate when a consultation is unopened
Browse files Browse the repository at this point in the history
Consultations can be published with an open date in the future.
This back-ports the unopened consultation fixes that have been applied
to government-frontend, which will be used after migration.
  • Loading branch information
fofr committed Dec 2, 2016
1 parent c916ad6 commit f577542
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
17 changes: 15 additions & 2 deletions app/views/consultations/show.html.erb
Expand Up @@ -35,8 +35,7 @@

<%= render partial: "document_summary", locals: { document: @document } %>
</div>
<% else %>
<% elsif @document.closed? %>
<% if @document.outcome_published? %>
<%= content_tag_for(:div, @document.outcome, class: 'consultation-response') do %>
<% if @document.outcome.attachments.any? %>
Expand Down Expand Up @@ -91,6 +90,20 @@
<p>This consultation ran from <span><%= absolute_time(@document.opening_at, class: 'opening-at') %> to<br><%= absolute_time(@document.closing_at, class: 'closing-at') %></span></p>
</div>

<%= render partial: "document_summary", locals: { document: @document } %>
</div>
<% else %>

<div class="status-block">
<h2>This consultation opens on <%= absolute_time(@document.opening_at, class: 'opening-at') %></h2>
</div>

<div class="consultation-block <%= consultation_css_class(@document) %>">
<div class="consultation-dates">
<p>This consultation opens on<br><span><%= absolute_time(@document.opening_at, class: 'opening-at') %></span></p>
<p>It closes on<br><span><%= absolute_time(@document.closing_at, class: 'closing-at') %></span></p>
</div>

<%= render partial: "document_summary", locals: { document: @document } %>
</div>
<% end %>
Expand Down
6 changes: 6 additions & 0 deletions features/consultations.feature
Expand Up @@ -19,6 +19,12 @@ Scenario: Publishing a submitted consultation
Then I should see the consultation "Beard Length Review" in the list of published documents
And the consultation "Beard Length Review" should be visible to the public

Scenario: Viewing an unopened consultation
Given I am an editor
And an unopened consultation exists
When I visit the consultation
Then the date the consultation opens should be viewable

Scenario: Adding an outcome to a closed consultation
Given I am an editor
And a closed consultation exists
Expand Down
15 changes: 15 additions & 0 deletions features/step_definitions/consultation_steps.rb
Expand Up @@ -2,6 +2,15 @@
create(:closed_consultation)
end

Given(/^an unopened consultation exists$/) do
create(:unopened_consultation)
end

When /^I visit the consultation$/ do
consultation = Consultation.find_by!(title: 'consultation-title')
visit consultation_path(consultation.document)
end

When /^I draft a new consultation "([^"]*)"$/ do |title|
publishing_api_has_policies([title])

Expand Down Expand Up @@ -65,6 +74,12 @@
end
end

Then /^the date the consultation opens should be viewable$/ do
assert has_content?('This consultation opens on')
assert has_content?('It closes on')
refute has_content?('Original consultation')
end

Then(/^the public feedback should be viewable$/) do
select_most_recent_consultation_from_list
view_visible_consultation_on_website
Expand Down
5 changes: 5 additions & 0 deletions test/factories/consultations.rb
Expand Up @@ -28,6 +28,11 @@
closing_at { 1.day.ago }
end

factory :unopened_consultation, parent: :published_consultation do
opening_at { 2.days.from_now }
closing_at { 3.days.from_now }
end

factory :consultation_with_outcome, parent: :closed_consultation do
outcome { create(:consultation_outcome) }
end
Expand Down

0 comments on commit f577542

Please sign in to comment.