Skip to content

Commit

Permalink
Merge pull request #3057 from alphagov/fix-stdout-test
Browse files Browse the repository at this point in the history
Fix test outputting to stdout
  • Loading branch information
kevindew authored Nov 20, 2024
2 parents 4c52a82 + 97f32d5 commit ce63f15
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions spec/integration/govuk_index/updating_popularity_data_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,19 @@
expect_document_is_in_rummager({ "link" => id, "popularity" => popularity }, type: "edition", index: "govuk_test")
end

it "ignores popularity update if version has moved on" do
id = insert_document("govuk_test", { title: "govuk_test_doc", popularity: 0.222, format: "help_page" }, type: "edition", version: 2)
commit_index("govuk_test")

document_count = 4
setup_page_traffic_data(document_count:)
it "ignores documents that aren't in the index" do
id = "test_id"

allow(ScrollEnumerator).to receive(:new).and_return([
{
"identifier" => { "_id" => id, "_version" => 1 },
"document" => { "link" => id, "popularity" => 0.222 },
},
])
allow(ScrollEnumerator).to receive(:new).and_return([id])
allow(Sidekiq.logger).to receive(:warn)
processor = instance_double("Index::ElasticsearchProcessor", commit: nil, save: nil)
allow(Index::ElasticsearchProcessor).to receive(:new).and_return(processor)

GovukIndex::PopularityUpdater.update("govuk_test")

expect_document_is_in_rummager({ "link" => id, "popularity" => 0.222 }, type: "edition", index: "govuk_test")
expect(Sidekiq.logger)
.to have_received(:warn).with("Skipping #{id} as it is not in the index")
expect(processor).not_to have_received(:save)
end

it "copies version information" do
Expand Down

0 comments on commit ce63f15

Please sign in to comment.