Skip to content

Commit

Permalink
Making sure the prefix has a slash in it (#1915)
Browse files Browse the repository at this point in the history
  • Loading branch information
carolyncole authored Aug 29, 2024
1 parent fe74c5e commit db35f5a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions spec/controllers/works_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
background_snapshot = BackgroundUploadSnapshot.last
expect(background_snapshot.work).to eq(work)
expect(background_snapshot.files.map { |file| file["user_id"] }.uniq).to eq([user.id])
expect(background_snapshot.files.first["filename"]).to eq "10.34770/123-abc/1us_covid_2019.csv"
expect(background_snapshot.files.first["filename"]).to eq "10.34770/123-abc/1/us_covid_2019.csv"
expect(background_snapshot.files.first["upload_status"]).to eq "complete"
end
end
Expand Down Expand Up @@ -245,9 +245,9 @@
expect(background_snapshot.work).to eq(work)
expect(background_snapshot.files.map { |file| file["user_id"] }.uniq).to eq([user.id])

file1 = background_snapshot.files.find { |file| file["filename"] == "10.34770/123-abc/1us_covid_2019.csv" }
file1 = background_snapshot.files.find { |file| file["filename"] == "10.34770/123-abc/1/us_covid_2019.csv" }
expect(file1["upload_status"]).to eq "complete"
file2 = background_snapshot.files.find { |file| file["filename"] == "10.34770/123-abc/1us_covid_2020.csv" }
file2 = background_snapshot.files.find { |file| file["filename"] == "10.34770/123-abc/1/us_covid_2020.csv" }
expect(file2["upload_status"]).to eq "complete"
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/requests/works_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@
background_snapshot = BackgroundUploadSnapshot.last
expect(background_snapshot.work).to eq(work)
expect(background_snapshot.files.map { |file| file["user_id"] }.uniq).to eq([user.id])
expect(background_snapshot.files.first["filename"]).to eq "10.34770/123-abc/1us_covid_2019.csv"
expect(background_snapshot.files.first["filename"]).to eq "10.34770/123-abc/1/us_covid_2019.csv"
expect(background_snapshot.files.first["upload_status"]).to eq "complete"
expect(background_snapshot.files.second["filename"]).to eq "10.34770/123-abc/1us_covid_2020.csv"
expect(background_snapshot.files.second["filename"]).to eq "10.34770/123-abc/1/us_covid_2020.csv"
expect(background_snapshot.files.second["upload_status"]).to eq "complete"
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/services/work_preservation_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
describe "preserve in S3" do
let(:approved_work) { FactoryBot.create :approved_work, doi: "10.34770/pe9w-x904" }
let(:path) { approved_work.s3_query_service.prefix }
let(:preservation_directory) { path + "/princeton_data_commons/" }
let(:preservation_directory) { path + "princeton_data_commons/" }
let(:file1) { FactoryBot.build :s3_file, filename: "#{approved_work.doi}/#{approved_work.id}/anyfile1.txt", last_modified: Time.parse("2022-04-21T18:29:40.000Z") }
let(:file2) { FactoryBot.build :s3_file, filename: "#{approved_work.doi}/#{approved_work.id}/folder1/anyfile2.txt", last_modified: Time.parse("2022-04-21T18:29:40.000Z") }
let(:preservation_file1) do
Expand Down Expand Up @@ -48,7 +48,7 @@
subject = described_class.new(work_id: approved_work.id, path: local_path, localhost: true)
location = subject.preserve!
expect(location.start_with?("file:///")).to be true
expect(location.end_with?("#{local_path}/princeton_data_commons/")).to be true
expect(location.end_with?("#{local_path}princeton_data_commons/")).to be true
end
end
end
2 changes: 1 addition & 1 deletion spec/support/s3_query_service_specs.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

def stub_s3(data: [], bucket_url: nil, prefix: "10.34770/123-abc/1", bucket_name: "example-bucket")
def stub_s3(data: [], bucket_url: nil, prefix: "10.34770/123-abc/1/", bucket_name: "example-bucket")
@s3_client = instance_double(Aws::S3::Client)
allow(@s3_client).to receive(:head_object)
allow(@s3_client).to receive(:delete_object)
Expand Down

0 comments on commit db35f5a

Please sign in to comment.