Commit ff2e07fcf1f4535ed6956b347ced8dbc915e2194

Authored by Tallys Martins
1 parent 9db0c7d6

Fix work assignment plugin issues on rails 4

Signed-off-by: Gabriel Silva <gabriel93.silva@gmail.com>
Signed-off-by: Luan Guimarães <guimaraesluan@me.com>
Signed-off-by: Marcos Ronaldo <marcos.rpj2@gmail.com>
Signed-off-by: Omar Junior <omarroinuj@gmail.com>
Signed-off-by: Tallys Martins <tallysmartins@gmail.com>
plugins/work_assignment/lib/work_assignment_plugin/email_contact.rb
@@ -50,13 +50,13 @@ class WorkAssignmentPlugin::EmailContact @@ -50,13 +50,13 @@ class WorkAssignmentPlugin::EmailContact
50 mail(options) 50 mail(options)
51 end 51 end
52 52
53 - def build_mail_message(email_contact, uploaded_files) 53 + def self.build_mail_message(email_contact, uploaded_files)
54 message = "" 54 message = ""
55 if uploaded_files && uploaded_files.first && uploaded_files.first.parent && uploaded_files.first.parent.parent 55 if uploaded_files && uploaded_files.first && uploaded_files.first.parent && uploaded_files.first.parent.parent
56 article = uploaded_files.first.parent.parent 56 article = uploaded_files.first.parent.parent
57 message = article.default_email + "<br>" 57 message = article.default_email + "<br>"
58 uploaded_files.each do |file| 58 uploaded_files.each do |file|
59 - url = url_for(file.url) 59 + url = Rails.application.routes.url_helpers.url_for(file.url)
60 message += "<br><a href='#{url}'>#{url}</a>" 60 message += "<br><a href='#{url}'>#{url}</a>"
61 end 61 end
62 end 62 end
plugins/work_assignment/lib/work_assignment_plugin/helper.rb
@@ -16,7 +16,7 @@ module WorkAssignmentPlugin::Helper @@ -16,7 +16,7 @@ module WorkAssignmentPlugin::Helper
16 end 16 end
17 17
18 def display_author_folder(author_folder, user) 18 def display_author_folder(author_folder, user)
19 - return if author_folder.children.empty? 19 + return if author_folder.children(true).empty?
20 content_tag('tr', 20 content_tag('tr',
21 content_tag('td', link_to_last_submission(author_folder, user)) + 21 content_tag('td', link_to_last_submission(author_folder, user)) +
22 content_tag('td', time_format(author_folder.children.last.created_at)) + 22 content_tag('td', time_format(author_folder.children.last.created_at)) +
plugins/work_assignment/test/functional/content_viewer_controller_test.rb
@@ -35,6 +35,14 @@ class ContentViewerControllerTest &lt; ActionController::TestCase @@ -35,6 +35,14 @@ class ContentViewerControllerTest &lt; ActionController::TestCase
35 assert_response :success 35 assert_response :success
36 end 36 end
37 37
  38 + should 'display users submissions' do
  39 + folder = work_assignment.find_or_create_author_folder(@person)
  40 + submission = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :profile => organization, :parent => folder)
  41 + get :view_page, :profile => @organization.identifier, :page => work_assignment.path
  42 + assert_response :success
  43 + assert_match /rails.png/, @response.body
  44 + end
  45 +
38 should "display 'Upload files' when create children of image gallery" do 46 should "display 'Upload files' when create children of image gallery" do
39 login_as(profile.identifier) 47 login_as(profile.identifier)
40 f = Gallery.create!(:name => 'gallery', :profile => profile) 48 f = Gallery.create!(:name => 'gallery', :profile => profile)