From 293cd2280ef5441369302e70c1e26d08998ada2b Mon Sep 17 00:00:00 2001 From: Tom Reis Date: Thu, 16 Apr 2020 13:55:02 -0600 Subject: [PATCH] Show parent text copies on imported course edit page --- .../forms/_additional_resource_fields.html.erb | 6 ++++-- .../courses/forms/_attachment_list.html.erb | 2 +- .../courses/forms/_text_copy_fields.html.erb | 2 +- app/views/errors/error404.html.erb | 1 - spec/features/admin/edit_course_spec.rb | 16 +++++++++++----- spec/services/course_import_service_spec.rb | 2 +- 6 files changed, 18 insertions(+), 11 deletions(-) diff --git a/app/views/admin/courses/forms/_additional_resource_fields.html.erb b/app/views/admin/courses/forms/_additional_resource_fields.html.erb index 6555059c..9f731054 100644 --- a/app/views/admin/courses/forms/_additional_resource_fields.html.erb +++ b/app/views/admin/courses/forms/_additional_resource_fields.html.erb @@ -7,8 +7,10 @@
- <%= render partial: 'admin/courses/forms/attachment_list', locals: { type: 'additional-resource', allow_delete: true } %> - <%= render partial: 'admin/courses/forms/attachment_upload', locals: { attachment_form: a, attachment_type: 'additional-resource', removable: false } %> + <%= render partial: 'admin/courses/forms/attachment_list', + locals: { attachments: @course.additional_resource_attachments, allow_delete: true } %> + <%= render partial: 'admin/courses/forms/attachment_upload', + locals: { attachment_form: a, attachment_type: 'additional-resource', removable: false } %> <%= link_to_add_fields "Add Attachment", f, :attachments, "additional-resource" %>
<% end %> diff --git a/app/views/admin/courses/forms/_attachment_list.html.erb b/app/views/admin/courses/forms/_attachment_list.html.erb index bce372dd..bd6a41ce 100644 --- a/app/views/admin/courses/forms/_attachment_list.html.erb +++ b/app/views/admin/courses/forms/_attachment_list.html.erb @@ -1,5 +1,5 @@
- <% @course.attachments.where(doc_type: type).each do |a| %> + <% attachments.each do |a| %>
<%= a.document_file_name %> diff --git a/app/views/admin/courses/forms/_text_copy_fields.html.erb b/app/views/admin/courses/forms/_text_copy_fields.html.erb index d8f9e3de..29afc8c1 100644 --- a/app/views/admin/courses/forms/_text_copy_fields.html.erb +++ b/app/views/admin/courses/forms/_text_copy_fields.html.erb @@ -6,7 +6,7 @@

- <%= render partial: 'admin/courses/forms/attachment_list', locals: { type: 'text-copy', allow_delete: !@imported_course } %> + <%= render partial: 'admin/courses/forms/attachment_list', locals: { attachments: @course.text_copy_attachments, allow_delete: !@imported_course } %> <% unless @imported_course %> <%= render partial: 'admin/courses/forms/attachment_upload', locals: { attachment_form: a, attachment_type: 'text-copy', removable: false } %> <%= link_to_add_fields "Add Attachment", f, :attachments, 'text-copy' %> diff --git a/app/views/errors/error404.html.erb b/app/views/errors/error404.html.erb index bfca9f5f..0029130a 100644 --- a/app/views/errors/error404.html.erb +++ b/app/views/errors/error404.html.erb @@ -1,4 +1,3 @@ -
diff --git a/spec/features/admin/edit_course_spec.rb b/spec/features/admin/edit_course_spec.rb index bec384c4..41d59a3b 100644 --- a/spec/features/admin/edit_course_spec.rb +++ b/spec/features/admin/edit_course_spec.rb @@ -7,20 +7,24 @@ fixture_file_upload(Rails.root.join('spec', 'fixtures', 'BasicSearch1.zip'), 'application/zip') end - let(:file_attachment) do + let(:additional_resource_file) do fixture_file_upload(Rails.root.join('spec', 'fixtures', 'testfile.pdf'), 'application/pdf') end + let(:text_copy_file) do + fixture_file_upload(Rails.root.join('spec', 'fixtures', 'Why_Use_a_Computer_1.pdf'), 'application/pdf') + end + let(:pla) { FactoryBot.create(:default_organization) } let(:user) { FactoryBot.create(:user, :admin) } let(:org) { user.organization } let(:pla_course) { FactoryBot.create(:course, organization: pla) } let(:subsite_course) { FactoryBot.create(:course, organization: org, parent: pla_course) } - let!(:course_attachment) do - FactoryBot.create(:attachment, document: file_attachment, doc_type: 'additional-resource', course: subsite_course) + let!(:additional_resource_attachment) do + FactoryBot.create(:attachment, document: additional_resource_file, doc_type: 'additional-resource', course: subsite_course) end let!(:text_copy_attachment) do - FactoryBot.create(:attachment, document: file_attachment, doc_type: 'text-copy', course: subsite_course) + FactoryBot.create(:attachment, document: text_copy_file, doc_type: 'text-copy', course: pla_course) end let!(:topic) { FactoryBot.create(:topic) } @@ -52,11 +56,13 @@ expect(page).to_not have_field('course_other_topic_text') expect(page).to have_link('Delete', count: 1) + + expect(page).to have_content('Upload any supplemental materials for further learning. These files are available to users after completing the course.') expect(page).to have_css('.attachment-upload-fields', count: 1) expect(page).to have_link('Add Attachment', count: 1) expect(page).to have_content('Text copies of the course to allow users to download content and view offline or follow along with the online course.') - expect(page).to have_content('Upload any supplemental materials for further learning. These files are available to users after completing the course.') + expect(page).to have_content(text_copy_attachment.document_file_name) expect(page).to have_button('Save Course') expect(page).to have_content('If you wish to edit additional details of this course and use the PLA-created Storyline files, please contact a PLA Administrator.') diff --git a/spec/services/course_import_service_spec.rb b/spec/services/course_import_service_spec.rb index 5d03ddb5..5cca21dd 100644 --- a/spec/services/course_import_service_spec.rb +++ b/spec/services/course_import_service_spec.rb @@ -10,7 +10,7 @@ let(:document) { fixture_file_upload(Rails.root.join('spec', 'fixtures', 'testfile.pdf'), 'application/pdf') } let!(:text_copy_attachment) { FactoryBot.create(:attachment, doc_type: 'text-copy', document: document, course: pla_course) } - let!(:additional_resource_attachment) { FactoryBot.create(:attachment, doc_type: 'additional-resource', document: document, course: pla_course) } + let!(:additional_resource_attachment) { FactoryBot.create(:attachment, doc_type: 'additional-resource', document: document, course: pla_course) } let(:subsite) { FactoryBot.create(:organization) }