- # Check the RSS feed
- def test_rss
- user = create(:user)
- # The fourth test below is surprisingly sensitive to timestamp ordering when the timestamps are equal.
- trace_a = create(:trace, :visibility => "public", :timestamp => 4.seconds.ago) do |trace|
- create(:tracetag, :trace => trace, :tag => "London")
- end
- trace_b = create(:trace, :visibility => "public", :timestamp => 3.seconds.ago) do |trace|
- create(:tracetag, :trace => trace, :tag => "Birmingham")
- end
- create(:trace, :visibility => "private", :user => user, :timestamp => 2.seconds.ago) do |trace|
- create(:tracetag, :trace => trace, :tag => "London")
- end
- create(:trace, :visibility => "private", :user => user, :timestamp => 1.second.ago) do |trace|
- create(:tracetag, :trace => trace, :tag => "Birmingham")
- end
-
- # First with the public feed
- get traces_rss_path
- check_trace_feed [trace_b, trace_a]
-
- # Restrict traces to those with a given tag
- get traces_rss_path(:tag => "London")
- check_trace_feed [trace_a]
- end
-
- # Check the RSS feed for a specific user
- def test_rss_user
- user = create(:user)
- second_user = create(:user)
- create(:user)
- create(:trace)
- trace_b = create(:trace, :visibility => "public", :timestamp => 4.seconds.ago, :user => user)
- trace_c = create(:trace, :visibility => "public", :timestamp => 3.seconds.ago, :user => user) do |trace|
- create(:tracetag, :trace => trace, :tag => "London")
- end
- create(:trace, :visibility => "private")
-
- # Test a user with no traces
- get traces_rss_path(:display_name => second_user.display_name)
- check_trace_feed []
-
- # Test the user with the traces - should see only public ones
- get traces_rss_path(:display_name => user.display_name)
- check_trace_feed [trace_c, trace_b]
-
- # Should only see traces with the correct tag when a tag is specified
- get traces_rss_path(:display_name => user.display_name, :tag => "London")
- check_trace_feed [trace_c]
-
- # Should no traces if the user does not exist
- get traces_rss_path(:display_name => "UnknownUser")
- check_trace_feed []
- end
-