File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change 1
1
class SerializableTask < JSONAPI ::Serializable ::Resource
2
2
type 'tasks'
3
3
4
+ has_one :latest_submission
4
5
has_many :submissions
5
6
belongs_to :framework
6
7
Original file line number Diff line number Diff line change 61
61
expect ( json [ 'data' ] [ 2 ] ) . to have_attribute ( :status ) . with_value ( 'in_progress' )
62
62
end
63
63
64
- it 'can optionally return included models ' do
64
+ it 'can optionally include submissions ' do
65
65
task = FactoryBot . create ( :task )
66
66
submission = FactoryBot . create ( :submission , task : task , aasm_state : 'pending' )
67
67
75
75
expect ( json [ 'included' ] [ 0 ] )
76
76
. to have_attribute ( :status ) . with_value ( 'pending' )
77
77
end
78
+
79
+ it 'can optionally include the latest_submission' do
80
+ task = FactoryBot . create ( :task )
81
+ submission = FactoryBot . create ( :submission , task : task , aasm_state : 'pending' )
82
+
83
+ get '/v1/tasks?include=latest_submission'
84
+
85
+ expect ( response ) . to be_successful
86
+ expect ( json [ 'data' ] [ 0 ] ) . to have_id ( task . id )
87
+ expect ( json [ 'data' ] [ 0 ] )
88
+ . to have_relationship ( :latest_submission )
89
+ . with_data ( 'id' => submission . id , 'type' => 'submissions' )
90
+
91
+ expect ( json [ 'included' ] [ 0 ] )
92
+ . to have_attribute ( :status ) . with_value ( 'pending' )
93
+ end
78
94
end
79
95
80
96
describe 'GET /tasks?filter[status]=' do
You can’t perform that action at this time.
0 commit comments