Skip to content

Commit 2cfd443

Browse files
Update filter of StatisticsAnnouncement
Only present to the user documents with an unpublished edition in the results page for filtering documents to connect to a StatisticsAnnouncement. This prevents a user connecting a published edition which had unintended consequences.
1 parent ab5cf45 commit 2cfd443

4 files changed

Lines changed: 31 additions & 3 deletions

File tree

app/controllers/admin/statistics_announcement_publications_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def params_filters
3535
end
3636

3737
def params_filters_with_default_state
38-
params_filters.reverse_merge("state" => "active")
38+
params_filters.reverse_merge("state" => "active", "in_pre_publication_state" => true)
3939
end
4040

4141
def edition_filter_options

features/admin-statistics-announcements.feature

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,18 @@ Feature: Statistical release announcements
5555
Then I should see a warning that there are upcoming releases without a linked publication
5656
And I should be able to view these upcoming releases without a linked publication
5757

58-
Scenario: linking a document to a statistics announcement
58+
Scenario: attempting to link a document to a published statistics announcement
59+
Given I am a GDS editor in the organisation "Department for Beards"
60+
And a published statistics publication called "Beard statistics - January 2014"
61+
And a statistics announcement called "January's beard statistics" exists
62+
Then I should not be able to link the announcement to the publication
63+
64+
Scenario: linking a document to a draft statistics announcement
5965
Given I am a GDS editor in the organisation "Department for Beards"
6066
And a draft statistics publication called "Beard statistics - January 2014"
6167
And a statistics announcement called "January's beard statistics" exists
6268
When I link the announcement to the publication
63-
Then I should see that the announcement is linked to the publication
69+
Then I should see that the announcement is linked to the publication
6470

6571
Scenario: cancelling a statistics announcement
6672
Given I am a GDS editor in the organisation "Department for Beards"

features/step_definitions/admin_statistics_announcements_steps.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@
1212
)
1313
end
1414

15+
Given(/^a published statistics publication called "(.*?)"$/) do |title|
16+
@statistics_publication = create(
17+
:publication,
18+
:published,
19+
access_limited: false,
20+
publication_type_id: PublicationType::OfficialStatistics.id,
21+
title:,
22+
)
23+
end
24+
1525
Given(/^there is a statistics announcement by my organisation$/) do
1626
@organisation_announcement = create(:statistics_announcement, organisation_ids: [@user.organisation.id])
1727
end
@@ -97,6 +107,17 @@
97107
find(".govuk-link", text: "Connect").click
98108
end
99109

110+
Then("I should not be able to link the announcement to the publication") do
111+
visit admin_statistics_announcement_path(@statistics_announcement)
112+
113+
click_on "Add existing document"
114+
115+
fill_in "title", with: "statistics"
116+
click_on "Search"
117+
118+
expect(page).to_not have_selector(".govuk-link", text: "Connect")
119+
end
120+
100121
Then(/^I should see that the announcement is linked to the publication$/) do
101122
expect(page).to have_current_path(admin_statistics_announcement_path(@statistics_announcement))
102123

test/functional/admin/statistics_announcement_publications_controller_test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class Admin::StatisticsAnnouncementPublicationsControllerTest < ActionController
1010
state: "active",
1111
type: @official_statistics_announcement.publication_type.key,
1212
per_page: 15,
13+
without_draft: true,
1314
}
1415
end
1516

0 commit comments

Comments
 (0)