Skip to content
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.

Commit

Permalink
Add last_judgement_at to API
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwebb76 committed Aug 1, 2023
1 parent da263c3 commit 9d956c2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/serializers/prediction_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class PredictionSerializer < ActiveModel::Serializer
:mean_confidence,
:outcome,
:prediction_group_id,
:last_judgement_at,
:updated_at,
:uuid,
:version,
Expand All @@ -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
4 changes: 4 additions & 0 deletions spec/requests/api/my_predictions_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 9d956c2

Please sign in to comment.