diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e99c74b56..880b697fc 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -35,7 +35,10 @@ def active_advanced_search_parameters? end def can_see_full_notice_version?(notice) - return true if can?(:view_full_version, notice) + whitelisted_notices = (ENV['WHITELISTED_NOTICES_FULL'] || []).split(',') + + return true if can?(:view_full_version, notice) || + whitelisted_notices.include?(notice.id.to_s) TokenUrl.valid?(params[:access_token], notice) end diff --git a/spec/integration/viewing_notices.spec.rb b/spec/integration/viewing_notices.spec.rb index 623917884..3ec05b806 100644 --- a/spec/integration/viewing_notices.spec.rb +++ b/spec/integration/viewing_notices.spec.rb @@ -56,6 +56,14 @@ check_full_works_urls end + scenario 'as an anonymous user viewing whitelisted notice' do + ENV['WHITELISTED_NOTICES_FULL'] = "1234,#{Notice.last.id}" + + visit notice_url(Notice.last) + + check_full_works_urls + end + def check_full_works_urls within('#works') do expect(page).to have_content 'http://www.example.com/original_work.pdf'