aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuc Donnet2017-12-19 12:18:51 +0100
committerGitHub2017-12-19 12:18:51 +0100
commit0e375a231b8c83bd1dc6f1b1f27cc23cd0c3ddbf (patch)
tree0372582fa88706ac55188c55e5bb79b79f32f213
parentbb2713b33296c857ce807e0237bf8095b65070ad (diff)
parent1b690a6dbd7175eb29e543246a057e4a868974cd (diff)
downloadchouette-core-0e375a231b8c83bd1dc6f1b1f27cc23cd0c3ddbf.tar.bz2
Merge pull request #159 from af83/5317-add-flash-messages-to-inform-users-when-asynchronous-jo
5317 add flash messages to inform users when asynchronous jo
-rw-r--r--app/controllers/referentials_controller.rb4
-rw-r--r--config/locales/imports.en.yml4
-rw-r--r--config/locales/imports.fr.yml4
-rw-r--r--config/locales/referentials.en.yml3
-rw-r--r--config/locales/referentials.fr.yml3
-rw-r--r--spec/controllers/imports_controller_spec.rb14
-rw-r--r--spec/controllers/referentials_controller_spec.rb29
7 files changed, 58 insertions, 3 deletions
diff --git a/app/controllers/referentials_controller.rb b/app/controllers/referentials_controller.rb
index ee1236912..40e8264ce 100644
--- a/app/controllers/referentials_controller.rb
+++ b/app/controllers/referentials_controller.rb
@@ -17,6 +17,8 @@ class ReferentialsController < ChouetteController
build_referenial
if !!@referential.created_from_id
+ flash[:notice] = t('notice.referentials.duplicate')
+
format.html { redirect_to workbench_path(@referential.workbench) }
end
end
@@ -60,7 +62,7 @@ class ReferentialsController < ChouetteController
def validate
ComplianceControlSetCopyWorker.perform_async(params[:compliance_control_set], params[:id])
- flash[:notice] = I18n.t("referentials.operation_in_progress")
+ flash[:notice] = t('notice.referentials.validate')
redirect_to(referential_path)
end
diff --git a/config/locales/imports.en.yml b/config/locales/imports.en.yml
index 0bb54d90d..462b17196 100644
--- a/config/locales/imports.en.yml
+++ b/config/locales/imports.en.yml
@@ -74,3 +74,7 @@ en:
max_distance_for_connection_link: "Max distance for connection link"
ignore_last_word: "ignore last word"
ignore_end_chars: "ignore last chars"
+ flash:
+ imports:
+ create:
+ notice: "The import is in progress. Please wait and refresh the page in a few moments."
diff --git a/config/locales/imports.fr.yml b/config/locales/imports.fr.yml
index 207f5cc31..b545f90df 100644
--- a/config/locales/imports.fr.yml
+++ b/config/locales/imports.fr.yml
@@ -74,3 +74,7 @@ fr:
max_distance_for_connection_link: "Distance max pour créer les correspondances"
ignore_last_word: "ignorer le dernier mot"
ignore_end_chars: "ignorer les n derniers caractères"
+ flash:
+ imports:
+ create:
+ notice: "L'import est en cours, veuillez patienter. Actualiser votre page si vous voulez voir l'avancement de votre traitement."
diff --git a/config/locales/referentials.en.yml b/config/locales/referentials.en.yml
index 8420e9539..f41e35446 100644
--- a/config/locales/referentials.en.yml
+++ b/config/locales/referentials.en.yml
@@ -5,7 +5,6 @@ en:
name: 'Search by name'
line: 'Seach by associated lines'
search_no_results: 'No data space matching your query'
- operation_in_progress: The validation process is in progress
error_period_filter: "The period filter must have valid bounding dates"
index:
title: 'Data spaces'
@@ -126,6 +125,8 @@ en:
notice:
referentials:
deleted: "Datasets has been successfully destroyed"
+ duplicate: "The duplication is in progress. Please wait and refresh the page in a few moments."
+ validate: "The validation is in progress. Please wait and refresh the page in a few moments."
referential:
archived: "The data space has been successfully archived"
unarchived: "The data space has been successfully unarchived"
diff --git a/config/locales/referentials.fr.yml b/config/locales/referentials.fr.yml
index ec7ed776d..9250a033c 100644
--- a/config/locales/referentials.fr.yml
+++ b/config/locales/referentials.fr.yml
@@ -5,7 +5,6 @@ fr:
name: 'Indiquez un nom de jeu de données...'
line: 'Indiquez une ligne...'
search_no_results: 'Aucun jeu de données ne correspond à votre recherche'
- operation_in_progress: L'opération de validation est en cours
error_period_filter: "Le filtre par période doit contenir une date de début et de fin valides"
index:
title: 'Jeux de données'
@@ -124,6 +123,8 @@ fr:
notice:
referentials:
deleted: "Les jeux de données on été supprimés"
+ duplicate: "La duplication est en cours, veuillez patienter. Actualiser votre page si vous voulez voir l'avancement de votre traitement."
+ validate: "La validation est en cours, veuillez patienter. Actualiser votre page si vous voulez voir l'avancement de votre traitement."
referential:
archived: "Le jeu de données a été correctement conservé"
unarchived: "Le jeu de données a été correctement déconservé"
diff --git a/spec/controllers/imports_controller_spec.rb b/spec/controllers/imports_controller_spec.rb
index 22be9f6ed..08495ff47 100644
--- a/spec/controllers/imports_controller_spec.rb
+++ b/spec/controllers/imports_controller_spec.rb
@@ -17,6 +17,20 @@ RSpec.describe ImportsController, :type => :controller do
end
end
+ describe "POST #create" do
+ it "displays a flash message" do
+ post :create, workbench_id: workbench.id,
+ import: {
+ name: 'Offre',
+ file: fixture_file_upload('nozip.zip')
+ }
+
+ expect(controller).to set_flash[:notice].to(
+ I18n.t('flash.imports.create.notice')
+ )
+ end
+ end
+
describe 'GET #download' do
it 'should be successful' do
get :download, workbench_id: workbench.id, id: import.id, token: import.token_download
diff --git a/spec/controllers/referentials_controller_spec.rb b/spec/controllers/referentials_controller_spec.rb
index fba063085..4050a8812 100644
--- a/spec/controllers/referentials_controller_spec.rb
+++ b/spec/controllers/referentials_controller_spec.rb
@@ -30,4 +30,33 @@ describe ReferentialsController, :type => :controller do
expect(assigns[:compliance_control_sets]).to eq([compliance_control_set])
end
end
+
+ describe "POST #validate" do
+ it "displays a flash message" do
+ post :validate, id: referential.id, params: {
+ compliance_control_set: create(:compliance_control_set).id
+ }
+
+ expect(controller).to set_flash[:notice].to(
+ I18n.t('notice.referentials.validate')
+ )
+ end
+ end
+
+ describe "POST #create" do
+ context "when duplicating" do
+ it "displays a flash message" do
+ post :create,
+ from: referential.id,
+ current_workbench_id: referential.workbench_id,
+ referential: {
+ name: 'Duplicated'
+ }
+
+ expect(controller).to set_flash[:notice].to(
+ I18n.t('notice.referentials.duplicate')
+ )
+ end
+ end
+ end
end