Commit ba577a75a0db1486e3e7a38291e5da4303510e4e

Authored by Braulio Bhavamitra
2 parents 7c0e23cb ff2e07fc

Merge branch 'fix_work_assignment' into 'master'

Fix work assignment plugin issues on rails 4

- Fixed submissions not being displayed on work assignment page
- Fixed email notifications not being sent

See merge request !967
plugins/work_assignment/lib/work_assignment_plugin/email_contact.rb
... ... @@ -50,13 +50,13 @@ class WorkAssignmentPlugin::EmailContact
50 50 mail(options)
51 51 end
52 52  
53   - def build_mail_message(email_contact, uploaded_files)
  53 + def self.build_mail_message(email_contact, uploaded_files)
54 54 message = ""
55 55 if uploaded_files && uploaded_files.first && uploaded_files.first.parent && uploaded_files.first.parent.parent
56 56 article = uploaded_files.first.parent.parent
57 57 message = article.default_email + "<br>"
58 58 uploaded_files.each do |file|
59   - url = url_for(file.url)
  59 + url = Rails.application.routes.url_helpers.url_for(file.url)
60 60 message += "<br><a href='#{url}'>#{url}</a>"
61 61 end
62 62 end
... ...
plugins/work_assignment/lib/work_assignment_plugin/helper.rb
... ... @@ -16,7 +16,7 @@ module WorkAssignmentPlugin::Helper
16 16 end
17 17  
18 18 def display_author_folder(author_folder, user)
19   - return if author_folder.children.empty?
  19 + return if author_folder.children(true).empty?
20 20 content_tag('tr',
21 21 content_tag('td', link_to_last_submission(author_folder, user)) +
22 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 35 assert_response :success
36 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 46 should "display 'Upload files' when create children of image gallery" do
39 47 login_as(profile.identifier)
40 48 f = Gallery.create!(:name => 'gallery', :profile => profile)
... ...