Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
Has a failing cucumber test
  • Loading branch information
thatkevin committed Jan 26, 2024
1 parent bc57bb6 commit 9eba348
Show file tree
Hide file tree
Showing 19 changed files with 52 additions and 53 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% if @petition.is_a?(::Archived::Petition) %>
<%= link_to 'Other parliamentary business', new_admin_archived_petition_email_path(@petition), class: 'petition-action-heading' %>
<%= link_to 'Updates', new_admin_archived_petition_email_path(@petition), class: 'petition-action-heading' %>
<% else %>
<%= link_to 'Other parliamentary business', new_admin_petition_email_path(@petition), class: 'petition-action-heading' %>
<%= link_to 'Updates', new_admin_petition_email_path(@petition), class: 'petition-action-heading' %>
<% end %>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h2 class="petition-action-heading">Other parliamentary business</h2>
<h2 class="petition-action-heading">Updates</h2>

<% if petition.emails.any?(&:persisted?) %>
<table class="petition-list petition-emails">
Expand All @@ -18,7 +18,7 @@
<%= button_to 'Edit', edit_admin_archived_petition_email_path(petition, email), method: :get, class: 'button' %>
<td><%= number_with_delimiter(email.email_count) || "–" %></td>
<td><%= date_format(email.emails_enqueued_at) || "–" %></td>
<%= button_to 'Delete', admin_archived_petition_email_path(petition, email), method: :delete, class: 'button-warning', data: { confirm: 'Delete other parliamentary business?' } %>
<%= button_to 'Delete', admin_archived_petition_email_path(petition, email), method: :delete, class: 'button-warning', data: { confirm: 'Delete update?' } %>
</td>
</tr>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/archived/petition_emails/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="grid-row">
<div class="column-two-thirds extra-gutter">
<h1>Edit other parliamentary business</h1>
<h1>Edit update</h1>

<%= form_for @email, url: admin_archived_petition_email_path(@petition, @email), method: :patch do |f| -%>
<%= form_row :for => [f.object, :subject] do %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h2 class="petition-action-heading">Other parliamentary business</h2>
<h2 class="petition-action-heading">Updates</h2>

<% if petition.emails.any?(&:persisted?) %>
<table class="petition-list petition-emails">
Expand All @@ -18,7 +18,7 @@
<td><%= date_format(email.emails_enqueued_at) || "–" %></td>
<td>
<%= button_to 'Edit', edit_admin_petition_email_path(petition, email), method: :get, class: 'button', disabled: @petition.editing_disabled? %>
<%= button_to 'Delete', admin_petition_email_path(petition, email), method: :delete, class: 'button-warning', disabled: @petition.editing_disabled?, data: { confirm: 'Delete other parliamentary business?' } %>
<%= button_to 'Delete', admin_petition_email_path(petition, email), method: :delete, class: 'button-warning', disabled: @petition.editing_disabled?, data: { confirm: 'Delete update?' } %>
</td>
</tr>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/petition_emails/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="grid-row">
<div class="column-two-thirds extra-gutter">
<h1>Edit other parliamentary business</h1>
<h1>Edit update</h1>

<%= form_for @email, url: admin_petition_email_path(@petition, @email), method: :patch do |f| -%>
<%= form_row :for => [f.object, :subject] do %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/petitions/_closed_petition_show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
</p>
</div>

<%= render 'threshold_details', petition: petition %>
<%= render 'other_business_details', petition: petition %>
<%= render 'update_details', petition: petition %>
<%= render 'update_details', petition: petition %>

<ul class="petition-meta">
<li>
Expand Down
2 changes: 1 addition & 1 deletion app/views/petitions/_open_petition_show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
</div>

<%= render 'threshold_details', petition: petition %>
<%= render 'other_business_details', petition: petition %>
<%= render 'update_details', petition: petition %>
<%= render 'share_petition', petition: petition %>

<ul class="petition-meta">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% unless petition.emails.empty? %>
<section class="about-item about-item-other-business" id="other-business" aria-labelledby="other-business-heading">
<h2 id="other-business-heading">Other parliamentary business</h2>
<h2 id="other-business-heading">Updates</h2>

<% petition.emails.each do |email| %>
<details>
Expand Down
8 changes: 4 additions & 4 deletions config/locales/admin.en-GB.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ en-GB:
parliament_archived: "Parliament archived successfully"
parliament_not_updated: "Parliament could not be updated - please check the form for errors"
parliament_updated: "Parliament updated successfully"
petition_email_created: "Created other parliamentary business successfully"
petition_email_updated: "Updated other parliamentary business successfully"
petition_email_deleted: "Deleted other parliamentary business successfully"
petition_email_not_deleted: "Unable to delete other parliamentary business - please contact support"
petition_email_created: "Created petition update successfully"
petition_email_updated: "Updated petition update successfully"
petition_email_deleted: "Deleted petition update successfully"
petition_email_not_deleted: "Unable to delete petition update - please contact support"
petition_not_found: "Cannot find petition with id: %{query}"
petition_updated: "Petition has been successfully updated"
petition_not_updated: "Petition could not be updated - please contact support"
Expand Down
20 changes: 10 additions & 10 deletions features/admin/petition_email.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Feature: Emailing petitioner supporters
And I am logged in as a sysadmin with the email "[email protected]", first_name "Admin", last_name "User"
When I am on the admin all petitions page
And I follow "Ban Badger Baiting"
And I follow "Other parliamentary business"
And I follow "Updates"
Then I should be on the admin email petitioners form page for "Ban Badger Baiting"
And the markup should be valid
When I press "Email 6 petitioners"
Expand All @@ -27,7 +27,7 @@ Feature: Emailing petitioner supporters
And I am logged in as a sysadmin with the email "[email protected]", first_name "Admin", last_name "User"
When I am on the admin all petitions page
And I follow "Ban Badger Baiting"
And I follow "Other parliamentary business"
And I follow "Updates"
Then I should be on the admin email petitioners form page for "Ban Badger Baiting"
And the markup should be valid
When I press "Save"
Expand All @@ -45,7 +45,7 @@ Feature: Emailing petitioner supporters
And I am logged in as a sysadmin with the email "[email protected]", first_name "Admin", last_name "User"
When I am on the admin all petitions page
And I follow "Ban Badger Baiting"
And I follow "Other parliamentary business"
And I follow "Updates"
Then I should be on the admin email petitioners form page for "Ban Badger Baiting"
And the markup should be valid
When I press "Save"
Expand All @@ -64,16 +64,16 @@ Feature: Emailing petitioner supporters
And I am logged in as a sysadmin with the email "[email protected]", first_name "Admin", last_name "User"
When I am on the admin all petitions page
And I follow "Ban Badger Baiting"
And I follow "Other parliamentary business"
And I follow "Updates"
Then I should be on the admin email petitioners form page for "Ban Badger Baiting"
And the markup should be valid
And I should see "This will be debated"
When I press "Edit"
Then I should see "Edit other parliamentary business"
Then I should see "Edit update"
When I fill in "Subject" with "This will not be debated"
And I press "Save"
Then I should see "Updated other parliamentary business successfully"
When I follow "Other parliamentary business"
Then I should see "Updated petition update successfully"
When I follow "Updates"
Then I should see "This will not be debated"

Scenario: Deleting an email to all petitioners
Expand All @@ -82,11 +82,11 @@ Feature: Emailing petitioner supporters
And I am logged in as a sysadmin with the email "[email protected]", first_name "Admin", last_name "User"
When I am on the admin all petitions page
And I follow "Ban Badger Baiting"
And I follow "Other parliamentary business"
And I follow "Updates"
Then I should be on the admin email petitioners form page for "Ban Badger Baiting"
And the markup should be valid
And I should see "This will be debated"
When I press "Delete"
Then I should see "Deleted other parliamentary business successfully"
When I follow "Other parliamentary business"
Then I should see "Deleted petition update successfully"
When I follow "Updates"
Then I should not see "This will be debated"
10 changes: 5 additions & 5 deletions features/joe_views_an_archived_petition.feature
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ Feature: Joe views an archived petition
Then I should see "Parliament debated this petition on 26 October 2015"
And I should see "Waiting for 1 day for Parliament to publish the debate outcome"

Scenario: Joe does not see information about other parliamentary business when there is none
Scenario: Joe does not see information about petition update when there is none
Given an archived petition "Ban Badger Baiting"
When I view the petition
Then I should not see "Other parliamentary business"
Then I should not see "Petition updates"

Scenario: Joe sees information about other parliamentary business when there is some
Given an archived petition "Ban Badger Baiting" has other parliamentary business
Scenario: Joe sees information about petition update when there is some
Given an archived petition "Ban Badger Baiting" has updates
When I view the petition
Then I should see the other business items
Then I should see the updates

@allow-rescue
Scenario: Joe tries to see a stopped archived petition
Expand Down
8 changes: 4 additions & 4 deletions features/step_definitions/petition_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@
end
end

Given(/^a petition "(.*?)" has other parliamentary business$/) do |petition_action|
Given(/^a petition "(.*?)" has updates$/) do |petition_action|
@petition = FactoryBot.create(:open_petition, action: petition_action)
@email = FactoryBot.create(:petition_email,
petition: @petition,
Expand All @@ -493,7 +493,7 @@
)
end

Given(/^an archived petition "(.*?)" has other parliamentary business$/) do |petition_action|
Given(/^an archived petition "(.*?)" has updates$/) do |petition_action|
@petition = FactoryBot.create(:archived_petition, action: petition_action)
@email = FactoryBot.create(:archived_petition_email,
petition: @petition,
Expand All @@ -502,9 +502,9 @@
)
end

Then(/^I should see the other business items$/) do
Then(/^I should see the updates$/) do
steps %Q(
Then I should see "Other parliamentary business"
Then I should see "Updates"
And I should see "Committee to discuss #{@petition.action}"
And I should see "The Petition Committee will discuss #{@petition.action} on the #{Date.tomorrow}"
)
Expand Down
10 changes: 5 additions & 5 deletions features/suzie_views_a_petition.feature
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,15 @@ Feature: Suzie views a petition
When I view the petition
Then I should not see the petition creator

Scenario: Suzie does not see information about other parliamentary business when there is none
Scenario: Suzie does not see information about petition updates when there is none
Given an open petition "Ban Badger Baiting"
When I view the petition
Then I should not see "Other parliamentary business"
Then I should not see "Updates"

Scenario: Suzie sees information about other parliamentary business when there is some
Given a petition "Ban Badger Baiting" has other parliamentary business
Scenario: Suzie sees information about petition updates when there is some
Given a petition "Ban Badger Baiting" has updates
When I view the petition
Then I should see the other business items
Then I should see the updates

Scenario: Suzie sees information about the outcomes when viewing a debated petition
Given a petition "Ban Badger Baiting" has been debated 2 days ago
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ def do_post(overrides = {})

it 'tells the moderator that their changes were saved' do
do_post
expect(flash[:notice]).to eq 'Created other parliamentary business successfully'
expect(flash[:notice]).to eq 'Created petition update successfully'
end

it 'stores the supplied email details in the db' do
Expand Down Expand Up @@ -893,7 +893,7 @@ def do_patch(overrides = {})

it 'tells the moderator that their changes were saved' do
do_patch
expect(flash[:notice]).to eq 'Updated other parliamentary business successfully'
expect(flash[:notice]).to eq 'Updated petition update successfully'
end

it 'stores the supplied email details in the db' do
Expand Down Expand Up @@ -1213,7 +1213,7 @@ def do_delete(overrides = {})

it 'tells the moderator that the record was deleted' do
do_delete
expect(flash[:notice]).to eq 'Deleted other parliamentary business successfully'
expect(flash[:notice]).to eq 'Deleted petition update successfully'
end
end

Expand All @@ -1229,7 +1229,7 @@ def do_delete(overrides = {})

it 'tells the moderator to contact support' do
do_delete
expect(flash[:notice]).to eq 'Unable to delete other parliamentary business - please contact support'
expect(flash[:notice]).to eq 'Unable to delete petition update - please contact support'
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions spec/controllers/admin/petition_emails_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def do_post(overrides = {})

it 'tells the moderator that their changes were saved' do
do_post
expect(flash[:notice]).to eq 'Created other parliamentary business successfully'
expect(flash[:notice]).to eq 'Created petition update successfully'
end

it 'stores the supplied email details in the db' do
Expand Down Expand Up @@ -888,7 +888,7 @@ def do_patch(overrides = {})

it 'tells the moderator that their changes were saved' do
do_patch
expect(flash[:notice]).to eq 'Updated other parliamentary business successfully'
expect(flash[:notice]).to eq 'Updated petition update successfully'
end

it 'stores the supplied email details in the db' do
Expand Down Expand Up @@ -1202,7 +1202,7 @@ def do_delete(overrides = {})

it 'tells the moderator that the record was deleted' do
do_delete
expect(flash[:notice]).to eq 'Deleted other parliamentary business successfully'
expect(flash[:notice]).to eq 'Deleted petition update successfully'
end
end

Expand All @@ -1218,7 +1218,7 @@ def do_delete(overrides = {})

it 'tells the moderator to contact support' do
do_delete
expect(flash[:notice]).to eq 'Unable to delete other parliamentary business - please contact support'
expect(flash[:notice]).to eq 'Unable to delete petition update - please contact support'
end
end
end
Expand Down
3 changes: 1 addition & 2 deletions spec/jobs/archived/email_petitioners_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
subject.perform(petition: petition, email: email, requested_at: requested_at_as_string)
}

context "when sending other parliamentary business emails" do
context "when sending update emails" do
it "records the number of emails sent" do
expect {
perform_enqueued_jobs {
Expand All @@ -38,7 +38,6 @@
}.from(nil).to(be_within(1.second).of(Time.current))
end
end

context "when the petition email has been deleted" do
before do
email.destroy
Expand Down
2 changes: 1 addition & 1 deletion spec/jobs/email_petitioners_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
subject.perform(petition: petition, email: email, requested_at: requested_at_as_string)
}

context "when sending other parliamentary business emails" do
context "when sending update emails" do
it "records the number of emails sent" do
expect {
perform_enqueued_jobs {
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/archived_petition_show_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@
expect(attributes.keys).not_to include("signatures_by_region")
end

it "includes other parliamentary business" do
it "includes petition updates" do
petition = FactoryBot.create :archived_petition
email_1 = FactoryBot.create :archived_petition_email, petition: petition, subject: "Original Government Response", body: "This is the original government response", created_at: 12.months.ago
email_2 = FactoryBot.create :archived_petition_email, petition: petition, subject: "Debate Decision", body: "Petitions committee will debate this petition", created_at: 13.months.ago
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/petition_show_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@
expect(attributes.keys).not_to include("signatures_by_region")
end

it "includes other parliamentary business" do
it "includes petition updates" do
petition = FactoryBot.create :open_petition
email_1 = FactoryBot.create :petition_email, petition: petition, subject: "Original Government Response", body: "This is the original government response", created_at: 1.day.ago
email_2 = FactoryBot.create :petition_email, petition: petition, subject: "Debate Decision", body: "Petitions committee will debate this petition", created_at: 2.days.ago
Expand Down

0 comments on commit 9eba348

Please sign in to comment.