Skip to content

Commit 4520a0e

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 2dca661 commit 4520a0e

4 files changed

Lines changed: 30 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
@@ -25,7 +25,7 @@ def filter
2525
end
2626

2727
def edition_scope
28-
Edition.with_translations(I18n.locale)
28+
Edition.with_translations(I18n.locale).in_pre_publication_state
2929
end
3030

3131
def params_filters

features/admin-statistics-announcements.feature

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,13 @@ 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

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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Admin::StatisticsAnnouncementPublicationsControllerTest < ActionController
3333
test "GET :index with search value passes title and default params to filter" do
3434
default_filter_params_with_title = @default_filter_params.merge(title: @title)
3535

36-
Admin::EditionFilter.expects(:new).with([@official_statistics_publication], @user, default_filter_params_with_title)
36+
Admin::EditionFilter.expects(:new).with(Edition.with_translations(I18n.locale).in_pre_publication_state, @user, default_filter_params_with_title)
3737

3838
get :index, params: { statistics_announcement_id: @official_statistics_announcement, title: @title }
3939
end

0 commit comments

Comments
 (0)