Skip to content

Commit

Permalink
use valkyrie for setup in fixity_checks_controller_spec
Browse files Browse the repository at this point in the history
related to #6304.

this still leaves one of these tests failing, since this controller doesn't
actually support valkyrie, but the setup is correct at least.
  • Loading branch information
tamsin johnson authored and tamsin johnson committed Oct 26, 2023
1 parent b872466 commit e6378d4
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions spec/controllers/hyrax/fixity_checks_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
# frozen_string_literal: true
RSpec.describe Hyrax::FixityChecksController do
routes { Hyrax::Engine.routes }
let(:user) { create(:user) }
let(:file_set) { create(:file_set, user: user) }
let(:binary) { File.open(fixture_path + '/world.png') }
let(:file) { Hydra::Derivatives::IoDecorator.new(binary, 'image/png', 'world.png') }

before { Hydra::Works::UploadFileToFileSet.call(file_set, file) }

let(:user) { FactoryBot.create(:user) }
let(:file_set) { FactoryBot.valkyrie_create(:hyrax_file_set, :with_files, depositor: user.user_key) }
context "when signed in" do
describe "POST create" do
before do
sign_in user
post :create, params: { file_set_id: file_set }, xhr: true
end
before { sign_in user }

let(:json_response) { JSON.parse(response.body) }

it "returns json with the result" do
post :create, params: { file_set_id: file_set }, xhr: true

expect(response).to be_successful
# json is a structure like this:
# { file_id => [{ "checked_uri" => "...4-4d71-83ba-1bc52a5e4300/fcr:versions/version1", "passed" => true },
Expand All @@ -38,6 +33,7 @@
describe "POST create" do
it "returns json with the result" do
post :create, params: { file_set_id: file_set }, xhr: true

expect(response.code).to eq '401'
end
end
Expand Down

0 comments on commit e6378d4

Please sign in to comment.