- # -------------------------------------
- # Test reading old relations.
- # -------------------------------------
- def test_history
- # check that a visible relations is returned properly
- get api_relation_history_path(create(:relation, :with_history))
- assert_response :success
-
- # check chat a non-existent relations is not returned
- get api_relation_history_path(0)
- assert_response :not_found
- end
-
- ##
- # test the redaction of an old version of a relation, while not being
- # authorised.
- def test_redact_relation_unauthorised
- relation = create(:relation, :with_history, :version => 4)
- relation_v3 = relation.old_relations.find_by(:version => 3)
-
- do_redact_relation(relation_v3, create(:redaction))
- assert_response :unauthorized, "should need to be authenticated to redact."
- end
-
- ##
- # test the redaction of an old version of a relation, while being
- # authorised as a normal user.
- def test_redact_relation_normal_user
- relation = create(:relation, :with_history, :version => 4)
- relation_v3 = relation.old_relations.find_by(:version => 3)
-
- auth_header = bearer_authorization_header
-
- do_redact_relation(relation_v3, create(:redaction), auth_header)
- assert_response :forbidden, "should need to be moderator to redact."
- end
-