diff --git a/app/controllers/activities_controller.rb b/app/controllers/activities_controller.rb index 7ebea3b434..cfd88b491a 100644 --- a/app/controllers/activities_controller.rb +++ b/app/controllers/activities_controller.rb @@ -116,12 +116,13 @@ def description def info @title = @activity.name @repository = @activity.repository - @config = @activity.merged_config - @config_locations = @activity.merged_config_locations + @config = @activity.ok? ? @activity.merged_config : {} + @config_locations = @activity.ok? ? @activity.merged_config_locations : {} @crumbs << [@activity.name, helpers.activity_scoped_path(activity: @activity, series: @series, course: @course)] << [I18n.t('crumbs.info'), '#'] @courses_series = policy_scope(@activity.series).group_by(&:course).sort do |a, b| [b.first.year, a.first.name] <=> [a.first.year, b.first.name] end + flash[:alert] = I18n.t('activities.info.activity_invalid') if @activity.not_valid? end def edit diff --git a/config/locales/views/activities/en.yml b/config/locales/views/activities/en.yml index 0ea6f62070..589e93b85c 100644 --- a/config/locales/views/activities/en.yml +++ b/config/locales/views/activities/en.yml @@ -116,3 +116,4 @@ en: description_files: "We found files for these languages in the descriptions folder %{path}" config_info: 'Take a look at the %{doc_site} for more information about configuring exercises.' doc_site: 'documentation site' + activity_invalid: This exercise's configuration is invalid. diff --git a/config/locales/views/activities/nl.yml b/config/locales/views/activities/nl.yml index 28086671ca..ecb9bd1126 100644 --- a/config/locales/views/activities/nl.yml +++ b/config/locales/views/activities/nl.yml @@ -117,3 +117,4 @@ nl: description_files: "We hebben bestanden gevonden met een beschrijving voor deze talen in de beschrijvingsmap %{path}" config_info: 'Neem een kijkje op de %{doc_site} voor meer informatie over het configureren van oefeningen.' doc_site: 'documentatiesite' + activity_invalid: Deze oefening heeft geen geldige configuratie. diff --git a/test/controllers/activities_controller_test.rb b/test/controllers/activities_controller_test.rb index 13ecc74872..6fb8302242 100644 --- a/test/controllers/activities_controller_test.rb +++ b/test/controllers/activities_controller_test.rb @@ -91,6 +91,14 @@ def setup assert_response :success end + test 'should show activity info when config is invalid' do + stub_all_activities! + Exercise.any_instance.stubs(:merged_config).raises(StandardError.new('ALL CAPS')) + @instance.update(status: :not_valid) + get info_activity_url(@instance) + assert_response :success + end + test 'should rescue from exercise not found' do not_id = Random.rand(10_000) begin