fix for rails3 refactoring of TestUploadedFile
in rails 3, ActionController::TestUploadedFile has been moved to Rack::Test::UploadedFile. This commit simply updates uses of TestUploadedFile to work with this new structure Change-Id: Ib31159c635f033a13908608dffeea88c8f719086 Reviewed-on: https://gerrit.instructure.com/28234 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Jacob Fugal <jacob@instructure.com> Product-Review: Anthus Williams <awilliams@instructure.com> QA-Review: Anthus Williams <awilliams@instructure.com>
This commit is contained in:
parent
4fc14530ce
commit
40c5c1f5f7
2
Gemfile
2
Gemfile
|
@ -103,7 +103,7 @@ gem 'multi_json', '1.8.2'
|
|||
gem 'netaddr', '1.5.0'
|
||||
gem 'nokogiri', '1.5.6'
|
||||
# oauth gem, with rails3 fixes rolled in
|
||||
gem 'oauth-instructure', '0.4.9', :require => 'oauth'
|
||||
gem 'oauth-instructure', '0.4.10', :require => 'oauth'
|
||||
gem 'rack', CANVAS_RAILS2 ? '1.1.3' : '1.4.5'
|
||||
gem 'rake', '10.1.1'
|
||||
gem 'rdoc', '3.12'
|
||||
|
|
|
@ -438,7 +438,7 @@ class SubmissionsController < ApplicationController
|
|||
end
|
||||
|
||||
@attachment = @assignment.attachments.new(
|
||||
uploaded_data: ActionController::TestUploadedFile.new(path, document_response.content_type, true),
|
||||
uploaded_data: Rack::Test::UploadedFile.new(path, document_response.content_type, true),
|
||||
display_name: display_name, user: @current_user
|
||||
)
|
||||
@attachment.save!
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
# once off RAILS2, inline the action_dispatch version and remove this file
|
||||
require 'action_controller'
|
||||
|
||||
if CANVAS_RAILS2
|
||||
require 'action_controller/test_process'
|
||||
module Rack
|
||||
module Test
|
||||
class UploadedFile < ActionController::TestUploadedFile; end
|
||||
end
|
||||
end
|
||||
else
|
||||
# XXX: Rails3 doesn't have ActionController::TestUploadedFile, which is
|
||||
# usually why this is required. time to fix this
|
||||
require 'action_dispatch/testing/test_process'
|
||||
require 'rack/test/uploaded_file'
|
||||
end
|
||||
|
|
|
@ -17,8 +17,10 @@
|
|||
#
|
||||
|
||||
require 'zip'
|
||||
require 'action_controller_test_process'
|
||||
|
||||
module Canvas::AccountReports
|
||||
|
||||
REPORTS = {}
|
||||
|
||||
# account id is ignored; use PluginSetting to enable a subset of reports
|
||||
|
@ -79,7 +81,6 @@ module Canvas::AccountReports
|
|||
end
|
||||
filetype = 'application/zip'
|
||||
elsif csv
|
||||
require 'action_controller_test_process'
|
||||
ext = csv !~ /\n/ && File.extname(csv)
|
||||
case ext
|
||||
when ".csv"
|
||||
|
@ -103,12 +104,12 @@ module Canvas::AccountReports
|
|||
end
|
||||
if filename
|
||||
attachment = account_report.account.attachments.create!(
|
||||
:uploaded_data => ActionController::TestUploadedFile.new(filepath, filetype, true),
|
||||
:uploaded_data => Rack::Test::UploadedFile.new(filepath, filetype, true),
|
||||
:display_name => filename,
|
||||
:user => account_report.user
|
||||
)
|
||||
end
|
||||
attachment.uploaded_data = ActionController::TestUploadedFile.new(filepath, filetype, true)
|
||||
attachment.uploaded_data = Rack::Test::UploadedFile.new(filepath, filetype, true)
|
||||
attachment.save
|
||||
attachment
|
||||
end
|
||||
|
|
|
@ -19,12 +19,13 @@
|
|||
require 'action_controller_test_process'
|
||||
|
||||
module Canvas::Migration::Worker
|
||||
|
||||
def self.get_converter(settings)
|
||||
Canvas::Migration::PackageIdentifier.new(settings).get_converter
|
||||
end
|
||||
|
||||
def self.upload_overview_file(file, content_migration)
|
||||
uploaded_data = ActionController::TestUploadedFile.new(file.path, Attachment.mimetype(file.path))
|
||||
uploaded_data = Rack::Test::UploadedFile.new(file.path, Attachment.mimetype(file.path))
|
||||
|
||||
att = Attachment.new
|
||||
att.context = content_migration
|
||||
|
@ -54,7 +55,7 @@ module Canvas::Migration::Worker
|
|||
end
|
||||
end
|
||||
|
||||
upload_file = ActionController::TestUploadedFile.new(zip_file, "application/zip")
|
||||
upload_file = Rack::Test::UploadedFile.new(zip_file, "application/zip")
|
||||
att = Attachment.new
|
||||
att.context = content_migration
|
||||
att.uploaded_data = upload_file
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
# You should have received a copy of the GNU Affero General Public License along
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
require 'action_controller_test_process'
|
||||
|
||||
module CC
|
||||
class CCExporter
|
||||
include TextHelper
|
||||
|
@ -62,8 +64,7 @@ module CC
|
|||
att = Attachment.new
|
||||
att.context = @content_export
|
||||
att.user = @content_export.user
|
||||
up_data = ActionController::TestUploadedFile.new(@zip_path, Attachment.mimetype(@zip_path))
|
||||
att.uploaded_data = up_data
|
||||
att.uploaded_data = Rack::Test::UploadedFile.new(@zip_path, Attachment.mimetype(@zip_path))
|
||||
if att.save
|
||||
@content_export.attachment = att
|
||||
@content_export.save
|
||||
|
|
|
@ -344,7 +344,7 @@ class ContentZipper
|
|||
def complete_attachment!(zip_attachment, zip_name)
|
||||
if zipped_successfully?
|
||||
@logger.debug("data zipped! uploading to s3...")
|
||||
uploaded_data = ActionController::TestUploadedFile.new(zip_name, 'application/zip')
|
||||
uploaded_data = Rack::Test::UploadedFile.new(zip_name, 'application/zip')
|
||||
zip_attachment.uploaded_data = uploaded_data
|
||||
zip_attachment.workflow_state = 'zipped'
|
||||
zip_attachment.file_state = 'available'
|
||||
|
|
|
@ -31,8 +31,10 @@
|
|||
|
||||
require 'resolv'
|
||||
require 'netaddr'
|
||||
require 'action_controller_test_process'
|
||||
|
||||
class CutyCapt
|
||||
|
||||
CUTYCAPT_DEFAULTS = {
|
||||
:delay => 3000,
|
||||
:timeout => 60000,
|
||||
|
@ -152,7 +154,7 @@ class CutyCapt
|
|||
self.snapshot_url(url, "png") do |file_path|
|
||||
# this is a really odd way to get Attachment the data it needs, which
|
||||
# should probably be remedied at some point
|
||||
attachment = Attachment.new(:uploaded_data => ActionController::TestUploadedFile.new(file_path, "image/png"))
|
||||
attachment = Attachment.new(:uploaded_data => Rack::Test::UploadedFile.new(file_path, "image/png"))
|
||||
end
|
||||
return attachment
|
||||
end
|
||||
|
|
|
@ -21,6 +21,7 @@ require 'action_controller_test_process'
|
|||
# Attaches a file generally to another file, using the attachment_fu gateway.
|
||||
class FileInContext
|
||||
class << self
|
||||
|
||||
def queue_files_to_delete(queue=true)
|
||||
@queue_files_to_delete = queue
|
||||
end
|
||||
|
@ -43,7 +44,7 @@ class FileInContext
|
|||
|
||||
def attach(context, filename, display_name=nil, folder=nil, explicit_filename=nil, allow_rename = false)
|
||||
display_name ||= File.split(filename).last
|
||||
uploaded_data = ActionController::TestUploadedFile.new(filename, Attachment.mimetype(filename))
|
||||
uploaded_data = Rack::Test::UploadedFile.new(filename, Attachment.mimetype(filename))
|
||||
|
||||
@attachment = context.attachments.build(:uploaded_data => uploaded_data, :display_name => display_name, :folder => folder)
|
||||
@attachment.filename = explicit_filename if explicit_filename
|
||||
|
@ -53,8 +54,6 @@ class FileInContext
|
|||
destroy_files(@attachment.handle_duplicates(allow_rename ? :rename : :overwrite, :caller_will_destroy => true))
|
||||
|
||||
@attachment
|
||||
ensure
|
||||
uploaded_data.close if uploaded_data
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -17,10 +17,12 @@
|
|||
#
|
||||
|
||||
require 'zip'
|
||||
require 'action_controller_test_process'
|
||||
|
||||
module SIS
|
||||
module CSV
|
||||
class Import
|
||||
|
||||
attr_accessor :root_account, :batch, :errors, :warnings, :finished, :counts, :updates_every,
|
||||
:override_sis_stickiness, :add_sis_stickiness, :clear_sis_stickiness
|
||||
|
||||
|
@ -344,7 +346,7 @@ module SIS
|
|||
out_csv = nil
|
||||
att = Attachment.new
|
||||
att.context = @batch
|
||||
att.uploaded_data = ActionController::TestUploadedFile.new(path, Attachment.mimetype(path))
|
||||
att.uploaded_data = Rack::Test::UploadedFile.new(path, Attachment.mimetype(path))
|
||||
att.display_name = new_csvs.last[:file]
|
||||
att.save!
|
||||
new_csvs.last.delete(:fullpath)
|
||||
|
@ -366,7 +368,7 @@ module SIS
|
|||
out_csv = nil
|
||||
att = Attachment.new
|
||||
att.context = @batch
|
||||
att.uploaded_data = ActionController::TestUploadedFile.new(path, Attachment.mimetype(path))
|
||||
att.uploaded_data = Rack::Test::UploadedFile.new(path, Attachment.mimetype(path))
|
||||
att.display_name = new_csvs.last[:file]
|
||||
att.save!
|
||||
new_csvs.last.delete(:fullpath)
|
||||
|
|
|
@ -987,8 +987,7 @@ describe DiscussionTopicsController, :type => :integration do
|
|||
end
|
||||
|
||||
it "should allow including attachments on top-level entries" do
|
||||
data = ActionController::TestUploadedFile.new(File.join(File.dirname(__FILE__), "/../../fixtures/scribd_docs/txt.txt"), "text/plain", true)
|
||||
require 'action_controller_test_process'
|
||||
data = fixture_file_upload("scribd_docs/txt.txt", "text/plain", true)
|
||||
json = api_call(
|
||||
:post, "/api/v1/courses/#{@course.id}/discussion_topics/#{@topic.id}/entries.json",
|
||||
{ :controller => 'discussion_topics_api', :action => 'add_entry', :format => 'json',
|
||||
|
@ -1001,8 +1000,7 @@ describe DiscussionTopicsController, :type => :integration do
|
|||
|
||||
it "should include attachments on replies to top-level entries" do
|
||||
top_entry = create_entry(@topic, :message => 'top-level message')
|
||||
require 'action_controller_test_process'
|
||||
data = ActionController::TestUploadedFile.new(File.join(File.dirname(__FILE__), "/../../fixtures/scribd_docs/txt.txt"), "text/plain", true)
|
||||
data = fixture_file_upload("scribd_docs/txt.txt", "text/plain", true)
|
||||
json = api_call(
|
||||
:post, "/api/v1/courses/#{@course.id}/discussion_topics/#{@topic.id}/entries/#{top_entry.id}/replies.json",
|
||||
{ :controller => 'discussion_topics_api', :action => 'add_reply', :format => 'json',
|
||||
|
@ -1014,8 +1012,7 @@ describe DiscussionTopicsController, :type => :integration do
|
|||
end
|
||||
|
||||
it "should include attachment info in the json response" do
|
||||
data = ActionController::TestUploadedFile.new(File.join(File.dirname(__FILE__), "/../../fixtures/scribd_docs/txt.txt"), "text/plain", true)
|
||||
require 'action_controller_test_process'
|
||||
data = fixture_file_upload("scribd_docs/txt.txt", "text/plain", true)
|
||||
json = api_call(
|
||||
:post, "/api/v1/courses/#{@course.id}/discussion_topics/#{@topic.id}/entries.json",
|
||||
{ :controller => 'discussion_topics_api', :action => 'add_entry', :format => 'json',
|
||||
|
|
|
@ -46,7 +46,7 @@ describe SisImportsApiController, :type => :integration do
|
|||
{ :controller => "sis_imports_api", :action => "create",
|
||||
:format => "json", :account_id => @account.id.to_s },
|
||||
opts.merge({ :import_type => "instructure_csv",
|
||||
:attachment => ActionController::TestUploadedFile.new(path)}))
|
||||
:attachment => Rack::Test::UploadedFile.new(path)}))
|
||||
json.has_key?("created_at").should be_true
|
||||
json.delete("created_at")
|
||||
json.has_key?("updated_at").should be_true
|
||||
|
|
|
@ -17,14 +17,14 @@
|
|||
#
|
||||
|
||||
require File.expand_path(File.dirname(__FILE__) + '/../sharding_spec_helper.rb')
|
||||
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
||||
|
||||
describe FilesController do
|
||||
def course_folder
|
||||
@folder = @course.folders.create!(:name => "a folder", :workflow_state => "visible")
|
||||
end
|
||||
def io
|
||||
require 'action_controller_test_process'
|
||||
ActionController::TestUploadedFile.new(File.expand_path(File.dirname(__FILE__) + '/../fixtures/scribd_docs/doc.doc'), 'application/msword', true)
|
||||
fixture_file_upload('scribd_docs/doc.doc', 'application/msword', true)
|
||||
end
|
||||
def course_file
|
||||
@file = factory_with_protected_attributes(@course.attachments, :uploaded_data => io)
|
||||
|
|
|
@ -20,8 +20,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|||
|
||||
describe FoldersController do
|
||||
def io
|
||||
require 'action_controller_test_process'
|
||||
ActionController::TestUploadedFile.new(File.expand_path(File.dirname(__FILE__) + '/../fixtures/scribd_docs/doc.doc'), 'application/msword', true)
|
||||
fixture_file_upload('scribd_docs/doc.doc', 'application/msword', true)
|
||||
end
|
||||
|
||||
def course_folder
|
||||
|
|
|
@ -32,8 +32,7 @@ describe GradebookUploadsController do
|
|||
file = Tempfile.new("csv.csv")
|
||||
file.puts("not a good csv")
|
||||
file.close
|
||||
require 'action_controller_test_process'
|
||||
data = ActionController::TestUploadedFile.new(file.path, 'text/csv', true)
|
||||
data = Rack::Test::UploadedFile.new(file.path, 'text/csv', true)
|
||||
post 'create', :course_id => @course.id, :gradebook_upload => {:uploaded_data => data}
|
||||
response.should be_redirect
|
||||
end
|
||||
|
@ -135,8 +134,7 @@ describe GradebookUploadsController do
|
|||
file = Tempfile.new("csv.csv")
|
||||
file.puts(@course.gradebook_to_csv(:include_sis_id => include_sis_id))
|
||||
file.close
|
||||
require 'action_controller_test_process'
|
||||
data = ActionController::TestUploadedFile.new(file.path, 'text/csv', true)
|
||||
data = Rack::Test::UploadedFile.new(file.path, 'text/csv', true)
|
||||
post 'create', :course_id => @course.id, :gradebook_upload => {:uploaded_data => data}
|
||||
response.should be_success
|
||||
upload = assigns[:uploaded_gradebook]
|
||||
|
|
|
@ -480,8 +480,7 @@ describe GradebooksController do
|
|||
course_with_teacher_logged_in(:active_all => true)
|
||||
@assignment = @course.assignments.create!(:title => "some assignment")
|
||||
@student = @course.enroll_user(User.create!(:name => "some user"))
|
||||
require 'action_controller_test_process'
|
||||
data = ActionController::TestUploadedFile.new(File.join(File.dirname(__FILE__), "/../fixtures/scribd_docs/doc.doc"), "application/msword", true)
|
||||
data = fixture_file_upload("scribd_docs/doc.doc", "application/msword", true)
|
||||
post 'update_submission', :course_id => @course.id, :attachments => {"0" => {:uploaded_data => data}}, :submission => {:comment => "some comment", :assignment_id => @assignment.id, :user_id => @student.user_id}
|
||||
response.should be_redirect
|
||||
assigns[:assignment].should eql(@assignment)
|
||||
|
|
|
@ -67,9 +67,8 @@ describe SubmissionsController do
|
|||
it "should allow attaching multiple files to the submission" do
|
||||
course_with_student_logged_in(:active_all => true)
|
||||
@assignment = @course.assignments.create!(:title => "some assignment", :submission_types => "online_url,online_upload")
|
||||
require 'action_controller_test_process'
|
||||
data1 = ActionController::TestUploadedFile.new(File.join(File.dirname(__FILE__), "/../fixtures/scribd_docs/doc.doc"), "application/msword", true)
|
||||
data2 = ActionController::TestUploadedFile.new(File.join(File.dirname(__FILE__), "/../fixtures/scribd_docs/xls.xls"), "application/vnd.ms-excel", true)
|
||||
data1 = fixture_file_upload("scribd_docs/doc.doc", "application/msword", true)
|
||||
data2 = fixture_file_upload("scribd_docs/xls.xls", "application/vnd.ms-excel", true)
|
||||
post 'create', :course_id => @course.id, :assignment_id => @assignment.id, :submission => {:submission_type => "online_upload"}, :attachments => {"0" => {:uploaded_data => data1}, "1" => {:uploaded_data => data2}}
|
||||
response.should be_redirect
|
||||
assigns[:submission].should_not be_nil
|
||||
|
@ -279,9 +278,8 @@ describe SubmissionsController do
|
|||
course_with_student_logged_in(:active_all => true)
|
||||
@assignment = @course.assignments.create!(:title => "some assignment", :submission_types => "online_url,online_upload")
|
||||
@submission = @assignment.submit_homework(@user)
|
||||
require 'action_controller_test_process'
|
||||
data1 = ActionController::TestUploadedFile.new(File.join(File.dirname(__FILE__), "/../fixtures/scribd_docs/doc.doc"), "application/msword", true)
|
||||
data2 = ActionController::TestUploadedFile.new(File.join(File.dirname(__FILE__), "/../fixtures/scribd_docs/xls.xls"), "application/vnd.ms-excel", true)
|
||||
data1 = fixture_file_upload("scribd_docs/doc.doc", "application/msword", true)
|
||||
data2 = fixture_file_upload("scribd_docs/xls.xls", "application/vnd.ms-excel", true)
|
||||
put 'update', :course_id => @course.id, :assignment_id => @assignment.id, :id => @user.id, :submission => {:comment => "some comment"}, :attachments => {"0" => {:uploaded_data => data1}, "1" => {:uploaded_data => data2}}
|
||||
response.should be_redirect
|
||||
assigns[:submission].should eql(@submission)
|
||||
|
|
|
@ -59,8 +59,8 @@ def stub_png_data(filename = 'test my file? hai!&.png', data = nil)
|
|||
end
|
||||
|
||||
def jpeg_data_frd
|
||||
fixture_path = File.expand_path(File.dirname(__FILE__) + '/../fixtures/test_image.jpg')
|
||||
ActionController::TestUploadedFile.new(fixture_path, 'image/jpeg', true)
|
||||
fixture_path = '/test_image.jpg'
|
||||
fixture_file_upload(fixture_path, 'image/jpeg', true)
|
||||
end
|
||||
|
||||
# Makes sure we have a value in scribd_mime_types and that the attachment model points to that.
|
||||
|
|
|
@ -24,7 +24,7 @@ describe 'ruby_version_compat' do
|
|||
|
||||
describe "force_utf8_params" do
|
||||
it "should allow null filenames through" do
|
||||
testfile = ActionController::TestUploadedFile.new(File.join(File.dirname(__FILE__), "/../fixtures/scribd_docs/txt.txt"), "text/plain", true)
|
||||
testfile = fixture_file_upload("scribd_docs/txt.txt", "text/plain", true)
|
||||
testfile.instance_variable_set(:@original_filename, nil)
|
||||
controller = ApplicationController.new
|
||||
controller.stubs(:params).returns({ :upload => { :file1 => testfile } })
|
||||
|
|
|
@ -312,13 +312,13 @@ describe ContentZipper do
|
|||
it "creates uploaded data for the assignment and marks it as available" do
|
||||
@attachment.expects(:save!).once
|
||||
zip_name = "submissions.zip"
|
||||
zip_path = File.join(ActionController::TestCase.fixture_path, zip_name)
|
||||
data = "just some stub data"
|
||||
ActionController::TestUploadedFile.expects(:new).
|
||||
with(zip_name, 'application/zip').returns data
|
||||
Rack::Test::UploadedFile.expects(:new).with(zip_path, 'application/zip').returns data
|
||||
@attachment.expects(:uploaded_data=).with data
|
||||
zipper = ContentZipper.new
|
||||
zipper.mark_successful!
|
||||
zipper.complete_attachment!(@attachment,zip_name)
|
||||
zipper.complete_attachment!(@attachment,zip_path)
|
||||
@attachment.should be_zipped
|
||||
@attachment.file_state.should == 'available'
|
||||
end
|
||||
|
|
|
@ -42,15 +42,5 @@ describe FileInContext do
|
|||
attachment.filename.should == 'escaping_test%5B0%5D.txt'
|
||||
Attachment.send(:define_method, :filename=, unbound_method)
|
||||
end
|
||||
|
||||
it "should close the temp file" do
|
||||
# If more than one thread is processing these specs another IO object could
|
||||
# be opened. We don't think that should happen so hopefully this won't
|
||||
# give any false-fails
|
||||
before_count = ObjectSpace.each_object(IO).count {|io| !io.closed?}
|
||||
filename = File.expand_path(File.join(File.dirname(__FILE__), %w(.. fixtures files escaping_test[0].txt)))
|
||||
attachment = FileInContext.attach(@course, filename, nil, @folder)
|
||||
ObjectSpace.each_object(IO).count {|io| !io.closed?}.should == before_count
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,10 +9,6 @@ describe "shared files tests" do
|
|||
return "#{path}#{file}"
|
||||
end
|
||||
|
||||
def fixture_file_upload(file, mimetype)
|
||||
ActionController::TestUploadedFile.new(fixture_file_path(file), mimetype)
|
||||
end
|
||||
|
||||
def add_file(fixture, context, name)
|
||||
context.attachments.create! do |attachment|
|
||||
attachment.uploaded_data = fixture
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
require File.expand_path(File.dirname(__FILE__) + '/../common')
|
||||
|
||||
def io
|
||||
require 'action_controller_test_process'
|
||||
ActionController::TestUploadedFile.new(File.expand_path(File.dirname(__FILE__) + '/../fixtures/scribd_docs/txt.txt'), 'text/plain', true)
|
||||
fixture_file_upload('scribd_docs/txt.txt', 'text/plain', true)
|
||||
end
|
||||
|
||||
def add_existing_module_item(item_select_selector, module_name, item_name)
|
||||
|
|
|
@ -30,7 +30,7 @@ end
|
|||
|
||||
def add_attachment_student_assignment(file, student, path)
|
||||
attachment = student.attachments.new
|
||||
attachment.uploaded_data = ActionController::TestUploadedFile.new(path, Attachment.mimetype(path))
|
||||
attachment.uploaded_data = Rack::Test::UploadedFile.new(path, Attachment.mimetype(path))
|
||||
attachment.save!
|
||||
@assignment.submit_homework(student, :submission_type => :online_upload, :attachments => [attachment])
|
||||
end
|
||||
|
|
|
@ -22,11 +22,11 @@ require File.expand_path(File.dirname(__FILE__) + '/../common')
|
|||
@text_file = @root_folder.attachments.create!(:filename => 'text_file.txt', :context => @course) { |a| a.content_type = 'text/plain' }
|
||||
@image1 = @root_folder.attachments.build(:context => @course)
|
||||
path = File.expand_path(File.dirname(__FILE__) + '/../../../public/images/email.png')
|
||||
@image1.uploaded_data = ActionController::TestUploadedFile.new(path, Attachment.mimetype(path))
|
||||
@image1.uploaded_data = Rack::Test::UploadedFile.new(path, Attachment.mimetype(path))
|
||||
@image1.save!
|
||||
@image2 = @root_folder.attachments.build(:context => @course)
|
||||
path = File.expand_path(File.dirname(__FILE__) + '/../../../public/images/graded.png')
|
||||
@image2.uploaded_data = ActionController::TestUploadedFile.new(path, Attachment.mimetype(path))
|
||||
@image2.uploaded_data = Rack::Test::UploadedFile.new(path, Attachment.mimetype(path))
|
||||
@image2.save!
|
||||
get "/courses/#{@course.id}/wiki"
|
||||
|
||||
|
|
|
@ -233,10 +233,6 @@ describe "submissions" do
|
|||
return "#{path}#{file}"
|
||||
end
|
||||
|
||||
def fixture_file_upload(file, mimetype)
|
||||
ActionController::TestUploadedFile.new(fixture_file_path(file), mimetype)
|
||||
end
|
||||
|
||||
def add_file(fixture, context, name)
|
||||
context.attachments.create! do |attachment|
|
||||
attachment.uploaded_data = fixture
|
||||
|
|
|
@ -70,7 +70,7 @@ describe "Wiki pages and Tiny WYSIWYG editor Images" do
|
|||
image = @root_folder.attachments.build(:context => @course)
|
||||
path = File.expand_path(File.dirname(__FILE__) + '/../../public/images/graded.png')
|
||||
image.display_name = "image #{i}"
|
||||
image.uploaded_data = ActionController::TestUploadedFile.new(path, Attachment.mimetype(path))
|
||||
image.uploaded_data = Rack::Test::UploadedFile.new(path, Attachment.mimetype(path))
|
||||
image.save!
|
||||
end
|
||||
@image_list.should_not have_class('initialized')
|
||||
|
|
|
@ -30,6 +30,7 @@ else
|
|||
end
|
||||
require 'webrat'
|
||||
require 'mocha/api'
|
||||
require 'action_controller_test_process'
|
||||
require File.expand_path(File.dirname(__FILE__) + '/mocha_rspec_adapter')
|
||||
require File.expand_path(File.dirname(__FILE__) + '/mocha_extensions')
|
||||
require File.expand_path(File.dirname(__FILE__) + '/ams_spec_helper')
|
||||
|
@ -799,9 +800,12 @@ end
|
|||
flash[:warning].should eql("You must be logged in to access this page")
|
||||
end
|
||||
|
||||
def fixture_file_upload(path, mime_type=nil, binary=false)
|
||||
Rack::Test::UploadedFile.new(File.join(ActionController::TestCase.fixture_path, path), mime_type, binary)
|
||||
end
|
||||
|
||||
def default_uploaded_data
|
||||
require 'action_controller_test_process'
|
||||
ActionController::TestUploadedFile.new(File.expand_path(File.dirname(__FILE__) + '/fixtures/scribd_docs/doc.doc'), 'application/msword', true)
|
||||
fixture_file_upload('scribd_docs/doc.doc', 'application/msword', true)
|
||||
end
|
||||
|
||||
def valid_gradebook_csv_content
|
||||
|
@ -1160,10 +1164,7 @@ end
|
|||
end
|
||||
|
||||
def dummy_io
|
||||
ActionController::TestUploadedFile.new(
|
||||
File.expand_path(File.dirname(__FILE__) +
|
||||
'/./fixtures/scribd_docs/doc.doc'),
|
||||
'application/msword', true)
|
||||
fixture_file_upload('scribd_docs/doc.doc', 'application/msword', true)
|
||||
end
|
||||
|
||||
def create_attachment_for_file_upload_submission!(submission, opts={})
|
||||
|
|
Loading…
Reference in New Issue