Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use valkyrie for setup in fixity_checks_controller_spec #6387

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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