Skip to content

Commit 8e92017

Browse files
committed
Fix bugs uncovered by v2 API test coverage
These changes resolve the following issues uncovered via the API v2 tests: - app/views/api/v2/_standard_response.json.jbuilder - Failure rendering json.client when @client is nil (undefined method `name` for nil) - app/views/api/v2/datasets/_show.json.jbuilder - Failure rendering output.doi_url when output is present (undefined method `doi_url`) - app/views/api/v2/templates/index.json.jbuilder - Failure in mapping template_ids when some nested keys are nil (undefined method `[]` for nil) - config/routes.rb - Spec failures due to undefined route helpers in test context (e.g., `api_v2_templates_path`)
1 parent b2bcc3f commit 8e92017

File tree

4 files changed

+3
-3
lines changed

4 files changed

+3
-3
lines changed

app/views/api/v2/_standard_response.json.jbuilder

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ json.ignore_nil!
1515
json.server @server
1616
json.source "#{request.method} #{request.path}"
1717
json.time Time.now.to_formatted_s(:iso8601)
18-
json.client @client.name
18+
json.client @client&.name
1919
json.code response.status
2020
json.message Rack::Utils::HTTP_STATUS_CODES[response.status]
2121

app/views/api/v2/datasets/_show.json.jbuilder

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ if output.is_a?(ResearchOutput)
77

88
json.type output.output_type
99
json.title output.title
10-
json.doi_url output.doi_url
1110
json.description output.description
1211
json.personal_data Api::V2::ApiPresenter.boolean_to_yes_no_unknown(value: output.personal_data)
1312
json.sensitive_data Api::V2::ApiPresenter.boolean_to_yes_no_unknown(value: output.sensitive_data)

app/views/api/v2/templates/index.json.jbuilder

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ json.items @items do |template|
1717
end
1818

1919
json.template_id do
20-
identifier = Api::V2::ConversionService.to_identifier(context: @application,
20+
identifier = Api::V2::ConversionService.to_identifier(context: @server,
2121
value: template.id)
2222
json.partial! 'api/v2/identifiers/show', identifier: identifier
2323
end

config/routes.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@
210210
get :me, controller: :base_api
211211

212212
resources :plans, only: %i[index show]
213+
resources :templates, only: :index
213214
end
214215
end
215216

0 commit comments

Comments
 (0)