Commit c973fa96681025ce3a24723982fcf27436a0aa9a
1 parent
c73820bb
Exists in
master
and in
29 other branches
rails3: fix work_assignment plugins
Showing
6 changed files
with
13 additions
and
11 deletions
Show diff stats
plugins/work_assignment/lib/work_assignment_plugin.rb
@@ -36,8 +36,8 @@ class WorkAssignmentPlugin < Noosfero::Plugin | @@ -36,8 +36,8 @@ class WorkAssignmentPlugin < Noosfero::Plugin | ||
36 | end | 36 | end |
37 | 37 | ||
38 | def content_viewer_controller_filters | 38 | def content_viewer_controller_filters |
39 | - block = lambda do | ||
40 | - path = params[:page].join('/') | 39 | + block = proc do |
40 | + path = params[:page] | ||
41 | content = profile.articles.find_by_path(path) | 41 | content = profile.articles.find_by_path(path) |
42 | 42 | ||
43 | if WorkAssignmentPlugin.is_submission?(content) && !WorkAssignmentPlugin.can_download_submission?(user, content) | 43 | if WorkAssignmentPlugin.is_submission?(content) && !WorkAssignmentPlugin.can_download_submission?(user, content) |
plugins/work_assignment/lib/work_assignment_plugin/work_assignment.rb
@@ -2,6 +2,8 @@ class WorkAssignmentPlugin::WorkAssignment < Folder | @@ -2,6 +2,8 @@ class WorkAssignmentPlugin::WorkAssignment < Folder | ||
2 | 2 | ||
3 | settings_items :publish_submissions, :type => :boolean, :default => false | 3 | settings_items :publish_submissions, :type => :boolean, :default => false |
4 | 4 | ||
5 | + attr_accessible :publish_submissions | ||
6 | + | ||
5 | def self.icon_name(article = nil) | 7 | def self.icon_name(article = nil) |
6 | 'work-assignment' | 8 | 'work-assignment' |
7 | end | 9 | end |
@@ -27,7 +29,7 @@ class WorkAssignmentPlugin::WorkAssignment < Folder | @@ -27,7 +29,7 @@ class WorkAssignmentPlugin::WorkAssignment < Folder | ||
27 | end | 29 | end |
28 | 30 | ||
29 | def to_html(options = {}) | 31 | def to_html(options = {}) |
30 | - lambda do | 32 | + proc do |
31 | render :file => 'content_viewer/work_assignment.html.erb' | 33 | render :file => 'content_viewer/work_assignment.html.erb' |
32 | end | 34 | end |
33 | end | 35 | end |
plugins/work_assignment/test/functional/cms_controller_test.rb
@@ -22,7 +22,7 @@ class CmsControllerTest < ActionController::TestCase | @@ -22,7 +22,7 @@ class CmsControllerTest < ActionController::TestCase | ||
22 | 22 | ||
23 | get :upload_files, :profile => organization.identifier, :parent_id => work_assignment.id | 23 | get :upload_files, :profile => organization.identifier, :parent_id => work_assignment.id |
24 | assert_response :forbidden | 24 | assert_response :forbidden |
25 | - assert_template 'access_denied.rhtml' | 25 | + assert_template 'access_denied' |
26 | 26 | ||
27 | organization.add_member(person) | 27 | organization.add_member(person) |
28 | 28 |
plugins/work_assignment/test/functional/content_viewer_controller_test.rb
@@ -29,13 +29,13 @@ class ContentViewerControllerTest < ActionController::TestCase | @@ -29,13 +29,13 @@ class ContentViewerControllerTest < ActionController::TestCase | ||
29 | submission = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :profile => organization, :parent => folder) | 29 | submission = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :profile => organization, :parent => folder) |
30 | WorkAssignmentPlugin.stubs(:can_download_submission?).returns(false) | 30 | WorkAssignmentPlugin.stubs(:can_download_submission?).returns(false) |
31 | 31 | ||
32 | - get :view_page, :profile => organization.identifier, :page => submission.explode_path | 32 | + get :view_page, :profile => organization.identifier, :page => submission.path |
33 | assert_response :forbidden | 33 | assert_response :forbidden |
34 | - assert_template 'access_denied.rhtml' | 34 | + assert_template 'access_denied' |
35 | 35 | ||
36 | WorkAssignmentPlugin.stubs(:can_download_submission?).returns(true) | 36 | WorkAssignmentPlugin.stubs(:can_download_submission?).returns(true) |
37 | 37 | ||
38 | - get :view_page, :profile => organization.identifier, :page => submission.explode_path | 38 | + get :view_page, :profile => organization.identifier, :page => submission.path |
39 | assert_response :success | 39 | assert_response :success |
40 | end | 40 | end |
41 | 41 |
plugins/work_assignment/test/unit/work_assingment_plugin/work_assignment_test.rb
@@ -35,10 +35,10 @@ class WorkAssignmentTest < ActiveSupport::TestCase | @@ -35,10 +35,10 @@ class WorkAssignmentTest < ActiveSupport::TestCase | ||
35 | organization = fast_create(Organization) | 35 | organization = fast_create(Organization) |
36 | author = fast_create(Person) | 36 | author = fast_create(Person) |
37 | work_assignment = WorkAssignmentPlugin::WorkAssignment.create!(:name => 'Sample Work Assignment', :profile => organization) | 37 | work_assignment = WorkAssignmentPlugin::WorkAssignment.create!(:name => 'Sample Work Assignment', :profile => organization) |
38 | - submission = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :profile => organization, :parent => work_assignment, :last_changed_by => author) | 38 | + submission = create(UploadedFile, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :profile => organization, :parent => work_assignment, :last_changed_by => author) |
39 | 39 | ||
40 | author_folder = work_assignment.find_or_create_author_folder(author) | 40 | author_folder = work_assignment.find_or_create_author_folder(author) |
41 | - assert author_folder, submission.parent | 41 | + assert_equal author_folder, submission.parent |
42 | end | 42 | end |
43 | 43 | ||
44 | should 'add logged user on cache_key if is a member' do | 44 | should 'add logged user on cache_key if is a member' do |
plugins/work_assignment/test/unit/work_assingment_plugin_test.rb
@@ -3,7 +3,7 @@ require 'test_helper' | @@ -3,7 +3,7 @@ require 'test_helper' | ||
3 | class WorkAssignmentPluginTest < ActiveSupport::TestCase | 3 | class WorkAssignmentPluginTest < ActiveSupport::TestCase |
4 | should 'verify if a content is a work_assignment submission' do | 4 | should 'verify if a content is a work_assignment submission' do |
5 | organization = fast_create(Organization) | 5 | organization = fast_create(Organization) |
6 | - content = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :profile => organization, :last_changed_by => fast_create(Person)) | 6 | + content = create(UploadedFile, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :profile => organization, :last_changed_by => fast_create(Person)) |
7 | assert !WorkAssignmentPlugin.is_submission?(content) | 7 | assert !WorkAssignmentPlugin.is_submission?(content) |
8 | 8 | ||
9 | work_assignment = WorkAssignmentPlugin::WorkAssignment.create!(:name => 'Work Assignment', :profile => organization) | 9 | work_assignment = WorkAssignmentPlugin::WorkAssignment.create!(:name => 'Work Assignment', :profile => organization) |
@@ -49,6 +49,6 @@ class WorkAssignmentPluginTest < ActiveSupport::TestCase | @@ -49,6 +49,6 @@ class WorkAssignmentPluginTest < ActiveSupport::TestCase | ||
49 | organization = fast_create(Organization) | 49 | organization = fast_create(Organization) |
50 | work_assignment = WorkAssignmentPlugin::WorkAssignment.create!(:name => 'Work Assignment', :profile => organization) | 50 | work_assignment = WorkAssignmentPlugin::WorkAssignment.create!(:name => 'Work Assignment', :profile => organization) |
51 | author_folder = work_assignment.find_or_create_author_folder(fast_create(Person)) | 51 | author_folder = work_assignment.find_or_create_author_folder(fast_create(Person)) |
52 | - UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :profile => organization, :parent => author_folder, :last_changed_by => author) | 52 | + create(UploadedFile, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :profile => organization, :parent => author_folder, :last_changed_by => author) |
53 | end | 53 | end |
54 | end | 54 | end |