Skip to content

Commit

Permalink
Merge pull request #1 from GSA/update-status-code
Browse files Browse the repository at this point in the history
Update transformation response code
  • Loading branch information
rshewitt authored Apr 24, 2024
2 parents 40d963b + af5343c commit 5b9e32a
Show file tree
Hide file tree
Showing 7 changed files with 1,696 additions and 8 deletions.
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
@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

0 comments on commit 5b9e32a

Please sign in to comment.