FIX: TopicTimestampChanger should not allow timestamps in the future.

This commit is contained in:
Guo Xiang Tan
2017-05-22 16:03:49 +08:00
parent 4382a0bb07
commit 238a156300
4 changed files with 46 additions and 33 deletions

View File

@@ -560,11 +560,11 @@ class TopicsController < ApplicationController
begin
TopicTimestampChanger.new(
topic_id: params[:topic_id].to_i,
timestamp: params[:timestamp].to_i
timestamp: params[:timestamp].to_f
).change!
render json: success_json
rescue ActiveRecord::RecordInvalid
rescue ActiveRecord::RecordInvalid, TopicTimestampChanger::InvalidTimestampError
render json: failed_json, status: 422
end
end