From ff2e07fcf1f4535ed6956b347ced8dbc915e2194 Mon Sep 17 00:00:00 2001 From: Tallys Martins Date: Fri, 17 Jun 2016 15:26:33 -0300 Subject: [PATCH] Fix work assignment plugin issues on rails 4 --- plugins/work_assignment/lib/work_assignment_plugin/email_contact.rb | 4 ++-- plugins/work_assignment/lib/work_assignment_plugin/helper.rb | 2 +- plugins/work_assignment/test/functional/content_viewer_controller_test.rb | 8 ++++++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/plugins/work_assignment/lib/work_assignment_plugin/email_contact.rb b/plugins/work_assignment/lib/work_assignment_plugin/email_contact.rb index 7f8bb9e..93454e0 100644 --- a/plugins/work_assignment/lib/work_assignment_plugin/email_contact.rb +++ b/plugins/work_assignment/lib/work_assignment_plugin/email_contact.rb @@ -50,13 +50,13 @@ class WorkAssignmentPlugin::EmailContact mail(options) end - def build_mail_message(email_contact, uploaded_files) + def self.build_mail_message(email_contact, uploaded_files) message = "" if uploaded_files && uploaded_files.first && uploaded_files.first.parent && uploaded_files.first.parent.parent article = uploaded_files.first.parent.parent message = article.default_email + "
" uploaded_files.each do |file| - url = url_for(file.url) + url = Rails.application.routes.url_helpers.url_for(file.url) message += "
#{url}" end end diff --git a/plugins/work_assignment/lib/work_assignment_plugin/helper.rb b/plugins/work_assignment/lib/work_assignment_plugin/helper.rb index 8292b42..f8acb8b 100644 --- a/plugins/work_assignment/lib/work_assignment_plugin/helper.rb +++ b/plugins/work_assignment/lib/work_assignment_plugin/helper.rb @@ -16,7 +16,7 @@ module WorkAssignmentPlugin::Helper end def display_author_folder(author_folder, user) - return if author_folder.children.empty? + return if author_folder.children(true).empty? content_tag('tr', content_tag('td', link_to_last_submission(author_folder, user)) + content_tag('td', time_format(author_folder.children.last.created_at)) + diff --git a/plugins/work_assignment/test/functional/content_viewer_controller_test.rb b/plugins/work_assignment/test/functional/content_viewer_controller_test.rb index e249497..872e7ce 100644 --- a/plugins/work_assignment/test/functional/content_viewer_controller_test.rb +++ b/plugins/work_assignment/test/functional/content_viewer_controller_test.rb @@ -35,6 +35,14 @@ class ContentViewerControllerTest < ActionController::TestCase assert_response :success end + should 'display users submissions' do + folder = work_assignment.find_or_create_author_folder(@person) + submission = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :profile => organization, :parent => folder) + get :view_page, :profile => @organization.identifier, :page => work_assignment.path + assert_response :success + assert_match /rails.png/, @response.body + end + should "display 'Upload files' when create children of image gallery" do login_as(profile.identifier) f = Gallery.create!(:name => 'gallery', :profile => profile) -- libgit2 0.21.2