Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update transformation response code #1

Merged
merged 5 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 4 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ Metrics/MethodLength:
Enabled: false

Metrics/PerceivedComplexity:
Enabled: false
Enabled: false

AllCops:
NewCops: disable
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
build: ## Build the app image
docker build -t datagov/mdtranslator .
docker build -t datagov/mdtranslator .

start:
rails server -b 0.0.0.0 -p 3000

lint:
bundle exec rubocop

.PHONY: test
test:
rails test
2 changes: 1 addition & 1 deletion app/controllers/translates_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@ def create
@response_info[:success] = false unless @md_return[:readerExecutionPass]
@response_info[:success] = false unless @md_return[:writerPass]

render json: @response_info
render json: @response_info, status: @response_info[:success] ? 200 : 422
end
end
16 changes: 11 additions & 5 deletions test/controllers/translates_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@
require 'test_helper'

class TranslatesControllerTest < ActionDispatch::IntegrationTest
test 'post transformation of fgdc to iso19115_3' do
btylerburton marked this conversation as resolved.
Show resolved Hide resolved
@translate = translates(:fgdc_to_iso)
@file = File.read(File.expand_path("../../fixtures/#{@translate.file}", __FILE__))
post '/translates', params: { translate: { file: @file,
reader: @translate.reader, writer: @translate.writer } }, as: :json
test 'post valid transformation of sbJson to mdJson' do
@translate = translates(:sbjson_to_mdjson)
@file = File.read(File.join(File.dirname(__FILE__), "../fixtures/#{@translate.file}"))
post '/translates', params: { file: @file, reader: @translate.reader, writer: @translate.writer }, as: :json
assert_response 200
end

test 'post invalid transformation of fgdc to iso19115_3' do
@translate = translates(:fgdc_to_iso)
@file = File.read(File.join(File.dirname(__FILE__), "../fixtures/#{@translate.file}"))
post '/translates', params: { file: @file, reader: @translate.reader, writer: @translate.writer }, as: :json
assert_response 422
end
end
Loading
Loading