Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def filter
end

def edition_scope
Edition.with_translations(I18n.locale)
Edition.with_translations(I18n.locale).in_pre_publication_state
end

def params_filters
Expand Down
8 changes: 7 additions & 1 deletion features/admin-statistics-announcements.feature
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,13 @@ Feature: Statistical release announcements
Then I should see a warning that there are upcoming releases without a linked publication
And I should be able to view these upcoming releases without a linked publication

Scenario: linking a document to a statistics announcement
Scenario: attempting to link a document to a published statistics announcement
Given I am a GDS editor in the organisation "Department for Beards"
And a published statistics publication called "Beard statistics - January 2014"
And a statistics announcement called "January's beard statistics" exists
Then I should not be able to link the announcement to the publication

Scenario: linking a document to a draft statistics announcement
Given I am a GDS editor in the organisation "Department for Beards"
And a draft statistics publication called "Beard statistics - January 2014"
And a statistics announcement called "January's beard statistics" exists
Expand Down
21 changes: 21 additions & 0 deletions features/step_definitions/admin_statistics_announcements_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@
)
end

Given(/^a published statistics publication called "(.*?)"$/) do |title|
@statistics_publication = create(
:publication,
:published,
access_limited: false,
publication_type_id: PublicationType::OfficialStatistics.id,
title:,
)
end

Given(/^there is a statistics announcement by my organisation$/) do
@organisation_announcement = create(:statistics_announcement, organisation_ids: [@user.organisation.id])
end
Expand Down Expand Up @@ -97,6 +107,17 @@
find(".govuk-link", text: "Connect").click
end

Then("I should not be able to link the announcement to the publication") do
visit admin_statistics_announcement_path(@statistics_announcement)

click_on "Add existing document"

fill_in "title", with: "statistics"
click_on "Search"

expect(page).to_not have_selector(".govuk-link", text: "Connect")
end

Then(/^I should see that the announcement is linked to the publication$/) do
expect(page).to have_current_path(admin_statistics_announcement_path(@statistics_announcement))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Admin::StatisticsAnnouncementPublicationsControllerTest < ActionController
test "GET :index with search value passes title and default params to filter" do
default_filter_params_with_title = @default_filter_params.merge(title: @title)

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

get :index, params: { statistics_announcement_id: @official_statistics_announcement, title: @title }
end
Expand Down