Skip to content

Commit

Permalink
Merge pull request #5554 from samvera/5452-citaions
Browse files Browse the repository at this point in the history
Remove SingularSubresourceController concern from CitationsController to enable citations for Valkyrie resources
  • Loading branch information
elrayle authored Mar 18, 2022
2 parents f050d8f + 549b1f0 commit ad00b23
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
1 change: 1 addition & 0 deletions .dassie/config/initializers/hyrax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

config.iiif_image_server = true
config.work_requires_files = false
config.citations = true

# Returns a URL that resolves to an image provided by a IIIF image server
config.iiif_image_url_builder = lambda do |file_id, base_url, size, format|
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/hyrax/citations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
module Hyrax
class CitationsController < ApplicationController
include WorksControllerBehavior
include DenyAccessOverrideBehavior
include Breadcrumbs
include SingularSubresourceController

# Overrides decide_layout from WorksControllerBehavior
with_themed_layout '1_column'
Expand Down
32 changes: 31 additions & 1 deletion spec/controllers/hyrax/citations_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,43 @@
end

context "with an unauthenticated user" do
it "is not successful" do
let(:second_user) { FactoryBot.create(:user) }

before do
sign_in second_user
end

it "redirects to the home page" do
get :work, params: { id: work }
expect(response).to redirect_to main_app.root_path(locale: 'en')
expect(flash[:alert]).to eq "You are not authorized to access this page."
end
end

context "when a user is not logged in" do
it "redirects to the user login page" do
get :work, params: { id: work }
expect(response).to redirect_to main_app.new_user_session_path(locale: 'en')
expect(flash[:alert]).to eq "You are not authorized to access this page."
expect(session['user_return_to']).to eq request.url
end
end

context "with a Valkyrie resource" do
let(:work) { FactoryBot.valkyrie_create(:monograph, edit_users: [user]) }
before do
sign_in user
end

it "is successful" do
expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path(locale: 'en'))
expect(controller).to receive(:add_breadcrumb).with('Dashboard', Hyrax::Engine.routes.url_helpers.dashboard_path(locale: 'en'))
get :work, params: { id: work }
expect(response).to be_successful
expect(response).to render_template('layouts/hyrax/1_column')
expect(assigns(:presenter)).to be_kind_of Hyrax::WorkShowPresenter
end
end
end
describe "#file" do
let(:user) { create(:user) }
Expand Down

0 comments on commit ad00b23

Please sign in to comment.