diff --git a/app/controllers/collections/versions_controller.rb b/app/controllers/collections/versions_controller.rb index 5d462983..4f0769d3 100644 --- a/app/controllers/collections/versions_controller.rb +++ b/app/controllers/collections/versions_controller.rb @@ -95,10 +95,17 @@ def to_review last! authorize! :send_to_review, collection - collection.to_review - collection.save! - flash[:success] = t('txt.controllers.versioning.to_review_success') - redirect_to collection_path(collection, published: 0) + # Only send the concept to review if it is publishable (e.g. consistency check is OK) + if collection.publishable? + collection.to_review + + collection.save! + flash[:success] = t('txt.controllers.versioning.to_review_success') + redirect_to collection_path(collection, published: 0) + else + flash[:error] = t('txt.controllers.versioning.consistency_check_error') + redirect_to edit_collection_path(collection, published: 0, full_consistency_check: '1') + end end end diff --git a/app/controllers/concepts/versions_controller.rb b/app/controllers/concepts/versions_controller.rb index f3f17bb0..4641a95d 100644 --- a/app/controllers/concepts/versions_controller.rb +++ b/app/controllers/concepts/versions_controller.rb @@ -109,10 +109,17 @@ def to_review last! authorize! :send_to_review, concept - concept.to_review - concept.save! - flash[:success] = t('txt.controllers.versioning.to_review_success') - redirect_to concept_path(published: 0, id: concept) + # Only send the concept to review if it is publishable (e.g. consistency check is OK) + if concept.publishable? + concept.to_review + concept.save! + + flash[:success] = t('txt.controllers.versioning.to_review_success') + redirect_to concept_path(published: 0, id: concept) + else + flash[:error] = t('txt.controllers.versioning.consistency_check_error') + redirect_to concept_path(published: 0, id: concept, full_consistency_check: '1') + end end end diff --git a/test/integration/create_concept_test.rb b/test/integration/create_concept_test.rb index 96222120..5802f899 100644 --- a/test/integration/create_concept_test.rb +++ b/test/integration/create_concept_test.rb @@ -30,6 +30,21 @@ class CreateConceptTest < ActionDispatch::IntegrationTest save_check_and_publish end + test 'send to review with inconsistent concept' do + login('administrator') + visit dashboard_path(lang: 'en') + click_link_or_button 'New Concept' + + # Create invalid preflabel + fill_in 'concept_labelings_by_text_labeling_skos_pref_labels_en', with: 'Foo,Foo' + click_link_or_button 'Save' + + # Consistency check should run when sending the concept to review. + click_link_or_button 'Send to review' + assert page.has_content? 'Instance is inconsistent.' + assert page.has_content? 'There must be only one preferred Label per language.' + end + private def save_check_and_publish