-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
67 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...nger_sequencing/app/views/sanger_sequencing/admin/shared/tabnav_product/_sanger.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
- if @product.sanger_sequencing_enabled? && can?(:manage, @facility) | ||
- if @product.sanger_sequencing_enabled? && can?(:manage, current_facility) | ||
= tab t("sanger_sequencing.tabnav_product"), | ||
facility_service_sanger_sequencing_sanger_product_path(current_facility, @product), | ||
(secondary_tab == "sanger") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
vendor/engines/sanger_sequencing/spec/system/sanger_product_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails_helper" | ||
|
||
RSpec.describe "Sanger Product" do | ||
let(:facility) { create(:setup_facility, sanger_sequencing_enabled: true) } | ||
let(:service) { create(:setup_service, sanger_sequencing_enabled: true) } | ||
let(:admin) { create(:user, :facility_administrator, facility:) } | ||
let(:user) { create(:user) } | ||
|
||
describe "admin tab" do | ||
context "when not logged in" do | ||
it "redirects to login" do | ||
visit facility_service_sanger_sequencing_sanger_product_path(facility, service) | ||
|
||
expect(page).to have_content("Login") | ||
expect(page).to_not have_content("Sanger") | ||
expect(page).to_not have_content(service.name) | ||
end | ||
end | ||
|
||
context "when logged in as normal user" do | ||
before { login_as user } | ||
|
||
it "renders permission denied" do | ||
visit facility_service_sanger_sequencing_sanger_product_path(facility, service) | ||
|
||
expect(page).to have_content("Permission Denied") | ||
end | ||
end | ||
|
||
context "when logged in as admin" do | ||
before { login_as admin } | ||
|
||
it "requires the facility to be sanger enabled" do | ||
facility.update(sanger_sequencing_enabled: false) | ||
|
||
visit facility_service_sanger_sequencing_sanger_product_path(facility, service) | ||
|
||
expect(page).to have_content("Not Found") | ||
end | ||
|
||
it "shows the tab if service is sanger enabled" do | ||
service.update(sanger_sequencing_enabled: true) | ||
|
||
visit facility_service_sanger_sequencing_sanger_product_path(facility, service) | ||
|
||
expect(page).to have_content("Sanger") | ||
end | ||
end | ||
end | ||
end |