diff --git a/app/views/crops/_approval_status_message.html.haml b/app/views/crops/_approval_status_message.html.haml index 54ae162db..1d67b7ea6 100644 --- a/app/views/crops/_approval_status_message.html.haml +++ b/app/views/crops/_approval_status_message.html.haml @@ -1,11 +1,10 @@ - if crop.pending? .alert.alert-danger - %b This crop is currently pending approval. - %p This crop was requested by #{crop.requester} #{time_ago_in_words(crop.created_at)} ago. + %b= t('.pending_title') + %p= t('.requested_by', requester: crop.requester, time_ago: time_ago_in_words(crop.created_at)) - unless crop.request_notes.blank? - %p - Request notes: #{crop.request_notes} + %p= t('.request_notes', notes: crop.request_notes) - if crop.rejected? .alert.alert-danger - %b This crop was rejected for the following reason: #{crop.rejection_explanation} + %b= t('.rejected_message', reason: crop.rejection_explanation) diff --git a/config/locales/de.yml b/config/locales/de.yml index ae2305a2a..30af0f665 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -208,6 +208,11 @@ de: published: Veröffentlicht saved: Jobvorlage gespeichert. crops: + approval_status_message: + pending_title: "Diese Kultur wartet derzeit auf Genehmigung." + rejected_message: "Diese Kultur wurde aus folgendem Grund abgelehnt: %{reason}" + request_notes: "Hinweise zur Anfrage: %{notes}" + requested_by: "Diese Kultur wurde vor %{time_ago} von %{requester} beantragt." alternate_name_modal: add_title: Weiteren Namen für %{crop} hinzufügen cancel: Abbrechen diff --git a/config/locales/en.yml b/config/locales/en.yml index 9092fd05e..dad1eb14f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -216,6 +216,11 @@ en: published: Published saved: Job template saved. crops: + approval_status_message: + pending_title: "This crop is currently pending approval." + rejected_message: "This crop was rejected for the following reason: %{reason}" + request_notes: "Request notes: %{notes}" + requested_by: "This crop was requested by %{requester} %{time_ago} ago." alternate_name_modal: add_title: Add another name for %{crop} cancel: Cancel diff --git a/config/locales/es.yml b/config/locales/es.yml index 6700b1294..ebdeb8013 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -208,6 +208,11 @@ es: published: Publicado saved: Plantilla de trabajo guardada. crops: + approval_status_message: + pending_title: "Este cultivo está pendiente de aprobación." + rejected_message: "Este cultivo fue rechazado por la siguiente razón: %{reason}" + request_notes: "Notas de la solicitud: %{notes}" + requested_by: "Este cultivo fue solicitado por %{requester} hace %{time_ago}." alternate_name_modal: add_title: Añadir otro nombre para %{crop} cancel: Cancelar diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 58eeba217..5b89b7c40 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -208,6 +208,11 @@ fr: published: Publié saved: Modèle sauvegardé. crops: + approval_status_message: + pending_title: "Cette culture est actuellement en attente d'approbation." + rejected_message: "Cette culture a été rejetée pour la raison suivante : %{reason}" + request_notes: "Notes de la demande : %{notes}" + requested_by: "Cette culture a été demandée par %{requester} il y a %{time_ago}." alternate_name_modal: add_title: Ajouter un autre nom pour %{crop} cancel: Annuler diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 22e7b235f..57392368f 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -1,6 +1,11 @@ --- ja: crops: + approval_status_message: + pending_title: "この作物は現在承認待ちです。" + rejected_message: "この作物は次の理由で却下されました: %{reason}" + request_notes: "リクエストのメモ: %{notes}" + requested_by: "この作物は %{time_ago}前に %{requester} によってリクエストされました。" alternate_name_modal: add_title: '%{crop}の別名を追加' cancel: キャンセル diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 5db0c9680..2fba1ab38 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -208,6 +208,11 @@ zh: published: 已发表 saved: 作业模板已保存。 crops: + approval_status_message: + pending_title: "该作物目前正在等待审核。" + rejected_message: "该作物因以下原因被拒绝:%{reason}" + request_notes: "请求备注:%{notes}" + requested_by: "该作物由 %{requester} 在 %{time_ago}前请求添加。" alternate_name_modal: add_title: 为%{crop}添加别名 cancel: 取消 diff --git a/spec/views/crops/_approval_status_message.html.haml_spec.rb b/spec/views/crops/_approval_status_message.html.haml_spec.rb new file mode 100644 index 000000000..33e94ef59 --- /dev/null +++ b/spec/views/crops/_approval_status_message.html.haml_spec.rb @@ -0,0 +1,64 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe 'crops/_approval_status_message' do + subject { rendered } + + context 'when crop is pending without request notes' do + let(:crop) { build_stubbed(:crop_request, request_notes: nil) } + + before do + render partial: 'crops/approval_status_message', locals: { crop: } + end + + it 'renders the localized pending title' do + expect(rendered).to have_content(I18n.t('crops.approval_status_message.pending_title')) + end + + it 'renders the localized requester message' do + expected_text = I18n.t( + 'crops.approval_status_message.requested_by', + requester: crop.requester, + time_ago: time_ago_in_words(crop.created_at) + ) + expect(rendered).to have_content(expected_text) + end + end + + context 'when crop is pending with request notes' do + let(:crop) { build_stubbed(:crop_request, request_notes: 'Need this for my garden.') } + + before do + render partial: 'crops/approval_status_message', locals: { crop: } + end + + it 'renders the localized pending title' do + expect(rendered).to have_content(I18n.t('crops.approval_status_message.pending_title')) + end + + it 'renders the localized request notes' do + expected_text = I18n.t( + 'crops.approval_status_message.request_notes', + notes: crop.request_notes + ) + expect(rendered).to have_content(expected_text) + end + end + + context 'when crop is rejected' do + let(:crop) { build_stubbed(:rejected_crop, reason_for_rejection: 'not edible') } + + before do + render partial: 'crops/approval_status_message', locals: { crop: } + end + + it 'renders the localized rejection message' do + expected_text = I18n.t( + 'crops.approval_status_message.rejected_message', + reason: crop.rejection_explanation + ) + expect(rendered).to have_content(expected_text) + end + end +end