Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion app/serializers/contributed_resource_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,17 @@ def get_version
end
end

def _meta
meta = super
meta[:view_count] = object.view_count
meta[:run_count] = object.run_count if object.respond_to?(:can_run?) && object.can_run?
meta[:download_count] = object.download_count if object.respond_to?(:contains_downloadable_items?) && object.contains_downloadable_items?
Comment thread
AbbyGavin marked this conversation as resolved.
Outdated
meta
end

private

def version_number
(@scope.try(:[], :requested_version) || object)&.version
end

end
12 changes: 12 additions & 0 deletions test/functional/workflows_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1411,6 +1411,18 @@ def bad_generator.write_graph(struct)
assert_equal Seek::BioSchema::Serializer.new(workflow.latest_version).json_representation, json
end

test 'json of workflow contains activity data' do
workflow = FactoryBot.create(:public_workflow)

get :show, params: { id: workflow.id, format: :json }
json = JSON.parse(response.body)
refute_nil json['data']
refute_nil json['data']['meta']
assert_equal 0, json['data']['meta']['view_count']
assert_equal 0, json['data']['meta']['download_count']
assert_nil json['data']['meta']['run_count']
Comment thread
AbbyGavin marked this conversation as resolved.
Outdated
end

test 'license should be overwritable by project default if not present' do
post :create_from_ro_crate, params: {
ro_crate: { data: fixture_file_upload('workflows/1-PreProcessing.crate.zip', 'application/zip') }
Expand Down
Loading