- ##
- # test the unredaction of an old version of a way, while being
- # authorised as a moderator.
- def test_unredact_way_moderator
- moderator_user = create(:moderator_user)
- way = create(:way, :with_history, :version => 2)
- way_v1 = way.old_ways.find_by(:version => 1)
- way_v1.redact!(create(:redaction))
-
- basic_authorization moderator_user.email, "test"
-
- post :redact, :params => { :id => way_v1.way_id, :version => way_v1.version }
- assert_response :success, "should be OK to unredact old version as moderator."
-
- # check moderator can still see the unredacted data, without passing
- # the appropriate flag
- get :version, :params => { :id => way_v1.way_id, :version => way_v1.version }
- assert_response :success, "After unredaction, node should not be gone for moderator."
-
- # and when accessed via history
- get :history, :params => { :id => way_v1.way_id }
- assert_response :success, "Unredaction shouldn't have stopped history working."
- assert_select "osm way[id='#{way_v1.way_id}'][version='#{way_v1.version}']", 1, "way #{way_v1.way_id} version #{way_v1.version} should still be present in the history for moderators."
-
- basic_authorization create(:user).email, "test"
-
- # check normal user can now see the unredacted data
- get :version, :params => { :id => way_v1.way_id, :version => way_v1.version }
- assert_response :success, "After redaction, node should not be gone for moderator, when flag passed."
-
- # and when accessed via history
- get :history, :params => { :id => way_v1.way_id }
- assert_response :success, "Redaction shouldn't have stopped history working."
- assert_select "osm way[id='#{way_v1.way_id}'][version='#{way_v1.version}']", 1, "way #{way_v1.way_id} version #{way_v1.version} should still be present in the history for normal users."
+ test "show unrevealed redacted versions to anonymous users" do
+ way = create_redacted_way
+ get old_way_path(way, 1)
+ assert_response :success
+ assert_template "old_ways/show"
+ assert_template :layout => "map"
+ assert_select "td", :text => "TOP SECRET", :count => 0
+ assert_select ".secondary-actions a[href='#{way_path way}']", :count => 1
+ assert_select ".secondary-actions a[href='#{old_way_path way, 1, :params => { :show_redactions => true }}']", :count => 0
+ assert_select ".secondary-actions a[href='#{old_way_path way, 1}']", :count => 0
+ assert_select ".secondary-actions a[href='#{api_old_way_path way, 1}']", :count => 0
+ end
+
+ test "show unrevealed redacted versions to regular users" do
+ session_for(create(:user))
+ way = create_redacted_way
+ get old_way_path(way, 1)
+ assert_response :success
+ assert_template "old_ways/show"
+ assert_template :layout => "map"
+ assert_select "td", :text => "TOP SECRET", :count => 0
+ assert_select ".secondary-actions a[href='#{way_path way}']", :count => 1
+ assert_select ".secondary-actions a[href='#{old_way_path way, 1, :params => { :show_redactions => true }}']", :count => 0
+ assert_select ".secondary-actions a[href='#{old_way_path way, 1}']", :count => 0
+ assert_select ".secondary-actions a[href='#{api_old_way_path way, 1}']", :count => 0
+ end
+
+ test "show unrevealed redacted versions to moderators" do
+ session_for(create(:moderator_user))
+ way = create_redacted_way
+ get old_way_path(way, 1)
+ assert_response :success
+ assert_template "old_ways/show"
+ assert_template :layout => "map"
+ assert_select "td", :text => "TOP SECRET", :count => 0
+ assert_select ".secondary-actions a[href='#{way_path way}']", :count => 1
+ assert_select ".secondary-actions a[href='#{old_way_path way, 1, :params => { :show_redactions => true }}']", :count => 1
+ assert_select ".secondary-actions a[href='#{old_way_path way, 1}']", :count => 0
+ assert_select ".secondary-actions a[href='#{api_old_way_path way, 1}']", :count => 0