diff --git a/app/serializers/prediction_serializer.rb b/app/serializers/prediction_serializer.rb index 6af6142a..b046048d 100644 --- a/app/serializers/prediction_serializer.rb +++ b/app/serializers/prediction_serializer.rb @@ -12,6 +12,7 @@ class PredictionSerializer < ActiveModel::Serializer :mean_confidence, :outcome, :prediction_group_id, + :last_judgement_at, :updated_at, :uuid, :version, @@ -23,4 +24,8 @@ class PredictionSerializer < ActiveModel::Serializer def creator_label object.creator.to_s end + + def last_judgement_at + object.judged_at + end end diff --git a/spec/requests/api/my_predictions_controller_spec.rb b/spec/requests/api/my_predictions_controller_spec.rb index 442133ed..50d46710 100644 --- a/spec/requests/api/my_predictions_controller_spec.rb +++ b/spec/requests/api/my_predictions_controller_spec.rb @@ -60,12 +60,16 @@ predictions = json_hash['predictions'] expect(predictions.length).to eq 2 + before_judgment_timestamp = Time.now + another_prediction.judgements.create!(outcome: true) + get url, params: params.merge(page_size: 1, page: 1) json_hash = JSON.parse(response.body) predictions = json_hash['predictions'] actor = json_hash['user'] expect(predictions.length).to eq 1 expect(predictions.first['description']).to eq another_prediction.description + expect(predictions.first['last_judgement_at'] > before_judgment_timestamp).to be true expect(actor['email']).to eq user.email get url, params: params.merge(page_size: 1, page: 2)