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

Hide add new program for admin without access #318

Merged
merged 1 commit into from
Apr 12, 2015
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion app/views/admin/programs/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
= link_to program.second, edit_admin_program_path(program.first)
= paginate @programs

= link_to 'Add a new program', new_admin_program_path, class: 'btn btn-primary'
- if Pundit.policy_scope!(current_admin, Organization).present?
= link_to 'Add a new program', new_admin_program_path, class: 'btn btn-primary'
18 changes: 18 additions & 0 deletions spec/features/admin/programs/visit_programs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,20 @@
expect(page).not_to have_link 'Nearby Program'
expect(page).to have_link 'Collection of Services'
end

it 'does not show add new program button if admin has no organizations' do
create(:nearby_loc)
visit '/admin/programs'

expect(page).not_to have_content 'Add a new program'
end

it 'shows add new program button if admin has an organization' do
create(:location_for_org_admin)
visit '/admin/programs'

expect(page).to have_link 'Add a new program'
end
end

context 'when signed in as super admin' do
Expand Down Expand Up @@ -80,5 +94,9 @@
expect(page.all('a')[9][:href]).
to eq "/admin/programs/#{@program.id}/edit"
end

it 'shows the add new program button' do
expect(page).to have_link 'Add a new program'
end
end
end