Skip to content

Commit

Permalink
Add tests for new breadcrumbs
Browse files Browse the repository at this point in the history
  • Loading branch information
smithjp committed Mar 28, 2018
1 parent 9adb2eb commit f9fcbe5
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module EmbargoesControllerBehavior
def index
add_breadcrumb t(:'hyrax.controls.home'), root_path
add_breadcrumb t(:'hyrax.dashboard.breadcrumbs.admin'), hyrax.dashboard_path
add_breadcrumb t(:'hyrax.embargoes.index.manage_embargoes', hyrax.embargoes_path)
add_breadcrumb t(:'hyrax.embargoes.index.manage_embargoes'), hyrax.embargoes_path
authorize! :index, Hydra::AccessControls::Embargo
end

Expand Down Expand Up @@ -43,5 +43,12 @@ def update
def self.local_prefixes
['hyrax/base']
end

def edit
add_breadcrumb t(:'hyrax.controls.home'), root_path
add_breadcrumb t(:'hyrax.dashboard.breadcrumbs.admin'), hyrax.dashboard_path
add_breadcrumb t(:'hyrax.embargoes.index.manage_embargoes'), hyrax.embargoes_path
add_breadcrumb t(:'hyrax.embargoes.edit.embargo_update'), '#'
end
end
end
9 changes: 8 additions & 1 deletion app/controllers/concerns/hyrax/leases_controller_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module LeasesControllerBehavior
def index
add_breadcrumb t(:'hyrax.controls.home'), root_path
add_breadcrumb t(:'hyrax.dashboard.breadcrumbs.admin'), hyrax.dashboard_path
add_breadcrumb t(:'hyrax.leases.index.manage_leases', hyrax.leases_path)
add_breadcrumb t(:'hyrax.leases.index.manage_leases'), hyrax.leases_path
authorize! :index, Hydra::AccessControls::Lease
end

Expand Down Expand Up @@ -36,5 +36,12 @@ def update
def self.local_prefixes
['hyrax/base']
end

def edit
add_breadcrumb t(:'hyrax.controls.home'), root_path
add_breadcrumb t(:'hyrax.dashboard.breadcrumbs.admin'), hyrax.dashboard_path
add_breadcrumb t(:'hyrax.leases.index.manage_leases'), hyrax.leases_path
add_breadcrumb t(:'hyrax.leases.edit.lease_update'), '#'
end
end
end
5 changes: 1 addition & 4 deletions app/controllers/concerns/hyrax/manages_embargoes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ def deny_access(exception)
redirect_to root_path, alert: exception.message
end

def edit
add_breadcrumb t(:'hyrax.controls.home'), root_path
add_breadcrumb t(:'hyrax.dashboard.breadcrumbs.admin'), hyrax.dashboard_path
end
def edit; end
end
end
7 changes: 7 additions & 0 deletions spec/controllers/hyrax/embargoes_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
let(:user) { create(:user, groups: ['admin']) }

it 'shows me the page' do
expect(controller).to receive(:add_breadcrumb).with('Home', root_path)
expect(controller).to receive(:add_breadcrumb).with('Dashboard', dashboard_path)
expect(controller).to receive(:add_breadcrumb).with('Manage Embargoes', embargoes_path)
get :index
expect(response).to be_success
expect(response).to render_template('dashboard')
Expand All @@ -32,6 +35,10 @@
end
context 'when I have permission to edit the object' do
it 'shows me the page' do
expect(controller).to receive(:add_breadcrumb).with('Home', root_path)
expect(controller).to receive(:add_breadcrumb).with('Dashboard', dashboard_path)
expect(controller).to receive(:add_breadcrumb).with('Manage Embargoes', embargoes_path)
expect(controller).to receive(:add_breadcrumb).with('Update Embargo', '#')
get :edit, params: { id: a_work }
expect(response).to be_success
expect(response).to render_template('dashboard')
Expand Down
9 changes: 9 additions & 0 deletions spec/controllers/hyrax/leases_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
let(:user) { create(:user, groups: ['admin']) }

it 'shows me the page' do
expect(controller).to receive(:add_breadcrumb).with('Home', root_path)
expect(controller).to receive(:add_breadcrumb).with('Dashboard', dashboard_path)
expect(controller).to receive(:add_breadcrumb).with('Manage Leases', leases_path)

get :index
expect(response).to be_success
expect(response).to render_template('dashboard')
Expand All @@ -33,6 +37,11 @@
end
context 'when I have permission to edit the object' do
it 'shows me the page' do
expect(controller).to receive(:add_breadcrumb).with('Home', root_path)
expect(controller).to receive(:add_breadcrumb).with('Dashboard', dashboard_path)
expect(controller).to receive(:add_breadcrumb).with('Manage Leases', leases_path)
expect(controller).to receive(:add_breadcrumb).with('Update Lease', '#')

get :edit, params: { id: a_work }
expect(response).to be_success
expect(response).to render_template('dashboard')
Expand Down

0 comments on commit f9fcbe5

Please sign in to comment.