Skip to content

Commit

Permalink
We now only allow consistent concepts and collections to be sent for …
Browse files Browse the repository at this point in the history
…review.
  • Loading branch information
pschijven committed Oct 13, 2023
1 parent 7dd1c7c commit e8bb682
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 8 deletions.
15 changes: 11 additions & 4 deletions app/controllers/collections/versions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 11 additions & 4 deletions app/controllers/concepts/versions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 15 additions & 0 deletions test/integration/create_concept_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e8bb682

Please sign in to comment.