Skip to content

Commit

Permalink
display full breadcrumb even when accessing the work/file/stat directly.
Browse files Browse the repository at this point in the history
  • Loading branch information
blancoj committed Aug 16, 2019
1 parent 3e26dc7 commit 57ea0d1
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 5 deletions.
2 changes: 2 additions & 0 deletions app/controllers/concerns/hyrax/breadcrumbs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ def build_breadcrumbs
trail_from_referer
else
default_trail
add_breadcrumb_for_controller if user_signed_in?
add_breadcrumb_for_action
end
end

Expand Down
42 changes: 40 additions & 2 deletions spec/controllers/hyrax/file_sets_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,24 @@
end

context "without a referer" do
let(:work) do
create(:generic_work, :public,
title: ['test title'],
user: user)
end

before do
work.ordered_members << file_set
work.save!
file_set.save!
end

it "shows me the file and set breadcrumbs" 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(I18n.t('hyrax.dashboard.title'), Hyrax::Engine.routes.url_helpers.dashboard_path(locale: 'en'))
expect(controller).to receive(:add_breadcrumb).with('Dashboard', Hyrax::Engine.routes.url_helpers.dashboard_path(locale: 'en'))
expect(controller).to receive(:add_breadcrumb).with('Works', Hyrax::Engine.routes.url_helpers.my_works_path(locale: 'en'))
expect(controller).to receive(:add_breadcrumb).with('test title', main_app.hyrax_generic_work_path(work.id, locale: 'en'))
expect(controller).to receive(:add_breadcrumb).with('test file', main_app.hyrax_file_set_path(file_set, locale: 'en'))
get :show, params: { id: file_set }
expect(response).to be_successful
expect(flash).to be_empty
Expand Down Expand Up @@ -275,7 +290,18 @@
let(:creator) { create(:user, email: 'archivist1@example.com') }
let(:public_file_set) { create(:file_set, user: creator, read_groups: ['public']) }

before { sign_in user }
let(:work) do
create(:generic_work, :public,
title: ['test title'],
user: user)
end

before do
sign_in user
work.ordered_members << public_file_set
work.save!
public_file_set.save!
end

describe '#edit' do
it 'gives me the unauthorized page' do
Expand All @@ -299,6 +325,18 @@
let(:private_file_set) { create(:file_set) }
let(:public_file_set) { create(:file_set, read_groups: ['public']) }

let(:work) do
create(:generic_work, :public,
title: ['test title'],
user: user)
end

before do
work.ordered_members << public_file_set
work.save!
public_file_set.save!
end

describe '#edit' do
it 'requires login' do
get :edit, params: { id: public_file_set }
Expand Down
16 changes: 13 additions & 3 deletions spec/controllers/hyrax/generic_works_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,14 @@
before { sign_out user }

context "without a referer" do
it "sets the default breadcrumbs" do
expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path(locale: 'en'))
it "sets breadcrumbs with complete path" do
expect(controller).to receive(:add_breadcrumb).with('Home', main_app.root_path(locale: 'en'))
expect(controller).not_to receive(:add_breadcrumb).with('Dashboard', hyrax.dashboard_path(locale: 'en'))
expect(controller).not_to receive(:add_breadcrumb).with('Your Works', hyrax.my_works_path(locale: 'en'))
expect(controller).to receive(:add_breadcrumb).with('public thing', main_app.hyrax_generic_work_path(work.id, locale: 'en'))
get :show, params: { id: work }
expect(response).to be_successful
expect(response).to render_template("layouts/hyrax/1_column")
end
end

Expand Down Expand Up @@ -91,7 +95,9 @@
context "without a referer" do
it "sets breadcrumbs" 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.dashboard_path(locale: 'en'))
expect(controller).to receive(:add_breadcrumb).with('Dashboard', hyrax.dashboard_path(locale: 'en'))
expect(controller).to receive(:add_breadcrumb).with('Works', hyrax.my_works_path(locale: 'en'))
expect(controller).to receive(:add_breadcrumb).with('test title', main_app.hyrax_generic_work_path(work.id, locale: 'en'))
get :show, params: { id: work }
expect(response).to be_successful
end
Expand Down Expand Up @@ -171,6 +177,7 @@
allow(controller).to receive(:presenter).and_return(presenter)
allow(presenter).to receive(:export_as_ttl).and_return("ttl graph")
allow(presenter).to receive(:editor?).and_return(true)
allow(presenter).to receive(:to_model).and_return(stub_model(GenericWork))
end

it 'renders a turtle file' do
Expand Down Expand Up @@ -231,6 +238,9 @@
end

context 'with a user granted workflow permission' do
before do
allow(document).to receive(:hydra_model).and_return(GenericWork)
end
let(:document_list) { [document] }
let(:document) { instance_double(SolrDocument) }

Expand Down

0 comments on commit 57ea0d1

Please sign in to comment.