Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
CuddlyBunion341 committed Nov 13, 2024
1 parent 25111bf commit aff9ada
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
10 changes: 2 additions & 8 deletions app/controllers/moirai/translation_files_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,10 @@ def handle_create
return
end

if translation_params[:value].blank?
if translation_params[:value].blank? && request.format.json?
respond_to do |format|
format.json do
render json: {
fallback_translation: get_fallback_translation
}
end
format.html do
flash.alert = "Value can't be blank"
redirect_back_or_to moirai_translation_file_path(Digest::SHA256.hexdigest(translation_params[:key]))
render json: {fallback_translation: get_fallback_translation}
end
end
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class TranslationFilesControllerTest < ActionDispatch::IntegrationTest
test "update translation with blank value json" do
post translation_files_url, params: {translation: {key: "locales.german", locale: "de", value: ""}}, as: :json
assert_response :ok
assert_equal "Deutsch", JSON.parse(response.body)["translation"]
assert_equal "Deutsch", JSON.parse(response.body)["fallback_translation"]
end

test "update translation with non-blank new value" do
Expand Down

0 comments on commit aff9ada

Please sign in to comment.