Skip to content

A platform for community discussion. Free, open, simple.

DEV: Update topic referer spec (#40905)

David Taylorc464c676a5ec
diff --git a/spec/requests/topics_controller_spec.rb b/spec/requests/topics_controller_spec.rb
index fafb48647d7..30ece7fd033 100644
--- a/spec/requests/topics_controller_spec.rb
+++ b/spec/requests/topics_controller_spec.rb
@@ -3844,9 +3844,10 @@ RSpec.describe TopicsController do
end
end
- it "records redirects" do
+ it "records the referer for a visit arriving via redirect" do
get "/t/#{topic.id}", headers: { HTTP_REFERER: "http://twitter.com" }
- get "/t/#{topic.slug}/#{topic.id}", headers: { HTTP_REFERER: nil }
+ # Simulate browsers, which preserve Referer across same-origin redirects
+ follow_redirect!(headers: { "HTTP_REFERER" => "http://twitter.com" })
link = IncomingLink.first
expect(link.referer).to eq("http://twitter.com")