rails 7.1: use fixture_file helper

to insulate from the change in singular vs. plural fixture paths

Change-Id: I6ea00f6ca2f20176839195bce22bd9a464ec7e57
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/340715
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
Cody Cutrer 2024-02-16 11:42:35 -07:00
parent 920dd72906
commit f71f4e54eb
7 changed files with 6 additions and 13 deletions

View File

@ -1434,7 +1434,7 @@ describe FilesController do
end
before do
@content = Rack::Test::UploadedFile.new(File.join(RSpec.configuration.fixture_path, "courses.yml"), "")
@content = Rack::Test::UploadedFile.new(file_fixture("a_file.txt"), "")
request.env["CONTENT_TYPE"] = "multipart/form-data"
enable_forgery_protection
end
@ -1447,7 +1447,7 @@ describe FilesController do
@attachment.reload
# the file is not available until the third api call is completed
expect(@attachment.file_state).to eq "deleted"
expect(@attachment.open.read).to eq File.read(File.join(RSpec.configuration.fixture_path, "courses.yml"))
expect(@attachment.open.read).to eq file_fixture("a_file.txt").read
end
it "opens up cors headers" do

View File

@ -614,7 +614,7 @@ describe ContentZipper do
it "creates uploaded data for the assignment and marks it as available" do
expect(@attachment).to receive(:save!).once
zip_name = "submissions.zip"
zip_path = File.join(RSpec.configuration.fixture_path, zip_name)
zip_path = file_fixture(zip_name)
data = "just some stub data"
expect(Canvas::UploadedFile).to receive(:new).with(zip_path, "application/zip").and_return data
expect(@attachment).to receive(:uploaded_data=).with data

View File

@ -83,7 +83,7 @@ describe CutyCapt do
describe ".snapshot_attachment_for_url" do
it "returns an attachment" do
path = File.join(self.class.fixture_path, "files/instructure.png")
path = file_fixture("instructure.png")
expect(CutyCapt).to receive(:snapshot_url).and_yield(path)
attachment = CutyCapt.snapshot_attachment_for_url("blah")
expect(attachment).not_to be_nil

View File

@ -2661,7 +2661,7 @@ describe Attachment do
describe "integrity_check" do
before do
allow(@attachment).to receive(:full_filename).and_return(File.join(RSpec.configuration.fixture_path, "good_data.txt"))
allow(@attachment).to receive(:full_filename).and_return(file_fixture("good_data.txt").to_s)
end
include_examples "non-streaming integrity_check"

View File

@ -461,10 +461,6 @@ describe "submissions" do
end
describe "uploaded files for submission" do
def fixture_file_path(file)
RSpec.configuration.fixture_path.join(file).to_s
end
def make_folder_actions_visible
driver.execute_script("$('.folder_item').addClass('folder_item_hover')")
end
@ -475,7 +471,6 @@ describe "submissions" do
add_file(fixture_file_upload("html-editing-test.html", "text/html"),
@student,
"html-editing-test.html")
File.read(fixture_file_path("files/html-editing-test.html"))
assignment = @course.assignments.create!(title: "assignment 1",
name: "assignment 1",
submission_types: "online_upload",
@ -498,14 +493,12 @@ describe "submissions" do
it "does not allow a user to submit a file-submission assignment from previously uploaded files with an illegal file extension", priority: "1" do
skip_if_safari(:alert)
filename = "hello-world.sh"
fixture_fn = "files/#{filename}"
local_storage!
add_file(fixture_file_upload(filename, "application/x-sh"),
@student,
filename)
File.read(fixture_file_path(fixture_fn))
assignment = @course.assignments.create!(title: "assignment 1",
name: "assignment 1",
submission_types: "online_upload",

View File

@ -639,7 +639,7 @@ RSpec.configure do |config|
end
def fixture_file_upload(path, mime_type = nil, binary = false)
Rack::Test::UploadedFile.new(File.join(RSpec.configuration.fixture_path, path), mime_type, binary)
Rack::Test::UploadedFile.new(file_fixture(path), mime_type, binary)
end
def default_uploaded_data