add specs
This commit is contained in:
@@ -50,7 +50,7 @@
|
|||||||
<%= link_to fa_icon("tags fw", text: "Tags"), [:new, medical_release, :acts_as_taggable_on_tag], class: "dropdown-item", remote: true %>
|
<%= link_to fa_icon("tags fw", text: "Tags"), [:new, medical_release, :acts_as_taggable_on_tag], class: "dropdown-item", remote: true %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if policy(MedicalRelease).review? %>
|
<% if policy(MedicalRelease).review? %>
|
||||||
<%= link_to fa_icon("search fw", text: "Review"), review_medical_release_path(medical_release), class: "dropdown-item" %>
|
<%= link_to fa_icon("search fw", text: t('.actions.review')), review_medical_release_path(medical_release), class: "dropdown-item" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if policy(MedicalRelease).download_single? && policy(Contract).show? && (medical_release.contract.attached? || medical_release.contract_template.present?) %>
|
<% if policy(MedicalRelease).download_single? && policy(Contract).show? && (medical_release.contract.attached? || medical_release.contract_template.present?) %>
|
||||||
<%= link_to fa_icon("download fw", text: "Download"), [medical_release, :contracts, format: "pdf"], class: "dropdown-item", target: "_blank" %>
|
<%= link_to fa_icon("download fw", text: "Download"), [medical_release, :contracts, format: "pdf"], class: "dropdown-item", target: "_blank" %>
|
||||||
|
|||||||
@@ -799,6 +799,7 @@ en:
|
|||||||
medical_release:
|
medical_release:
|
||||||
actions:
|
actions:
|
||||||
manage: Manage
|
manage: Manage
|
||||||
|
review: Review
|
||||||
messages:
|
messages:
|
||||||
approved_tooltip: Approved by %{user} on %{timestamp}
|
approved_tooltip: Approved by %{user} on %{timestamp}
|
||||||
review:
|
review:
|
||||||
|
|||||||
@@ -302,6 +302,8 @@ es:
|
|||||||
table_headers:
|
table_headers:
|
||||||
approved: Approved (ES)
|
approved: Approved (ES)
|
||||||
medical_release:
|
medical_release:
|
||||||
|
actions:
|
||||||
|
review: Review (ES)
|
||||||
messages:
|
messages:
|
||||||
approved_tooltip: ""
|
approved_tooltip: ""
|
||||||
review:
|
review:
|
||||||
|
|||||||
@@ -88,4 +88,27 @@ RSpec.describe MedicalReleasesController, type: :controller do
|
|||||||
}.to change(MedicalRelease, :count).by(-1)
|
}.to change(MedicalRelease, :count).by(-1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#review" do
|
||||||
|
let!(:medical_release) { create(:medical_release, project: project) }
|
||||||
|
|
||||||
|
it "responds successfully" do
|
||||||
|
get :review, params: { project_id: project, id: medical_release }
|
||||||
|
|
||||||
|
expect(response).to be_successful
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "#approve" do
|
||||||
|
it "changes approval status successfully" do
|
||||||
|
medical_release = create(:medical_release, project: project)
|
||||||
|
|
||||||
|
expect(MedicalRelease.last.approved?).to eq false
|
||||||
|
|
||||||
|
patch :approve, params: { project_id: project, id: medical_release }
|
||||||
|
|
||||||
|
expect(response).to redirect_to [project, :medical_releases]
|
||||||
|
expect(MedicalRelease.last.approved?).to eq true
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -182,6 +182,18 @@ feature "User managing medical releases" do
|
|||||||
sign_in current_user
|
sign_in current_user
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scenario "Approved releases have checkmark and non-approved releases don't have checkmarks" do
|
||||||
|
create(:medical_release_with_contract_template, :native, project: project)
|
||||||
|
|
||||||
|
visit project_medical_releases_path(project)
|
||||||
|
expect(page).to have_css('i.fa.fa-check-circle.fa-2x', count: 0)
|
||||||
|
|
||||||
|
create(:medical_release_with_contract_template, :native, project: project, approved_by_user_email: "some@email.com", approved_at: DateTime.now)
|
||||||
|
visit project_medical_releases_path(project)
|
||||||
|
|
||||||
|
expect(page).to have_css('i.fa.fa-check-circle.fa-2x', count: 1)
|
||||||
|
end
|
||||||
|
|
||||||
scenario "Download All is visible" do
|
scenario "Download All is visible" do
|
||||||
create(:medical_release_with_contract_template, :native, project: project)
|
create(:medical_release_with_contract_template, :native, project: project)
|
||||||
create(:medical_release_with_contract_template, :non_native, project: project)
|
create(:medical_release_with_contract_template, :non_native, project: project)
|
||||||
@@ -200,6 +212,15 @@ feature "User managing medical releases" do
|
|||||||
expect(page).to have_link("Download", exact: true, count: 2)
|
expect(page).to have_link("Download", exact: true, count: 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scenario "Review action in Manage menu is visible" do
|
||||||
|
create(:medical_release_with_contract_template, :native, project: project)
|
||||||
|
create(:medical_release_with_contract_template, :non_native, project: project)
|
||||||
|
|
||||||
|
visit project_medical_releases_path(project)
|
||||||
|
|
||||||
|
expect(page).to have_link(review_action, exact: true)
|
||||||
|
end
|
||||||
|
|
||||||
scenario "Downloading PDF of native medical release is possible" do
|
scenario "Downloading PDF of native medical release is possible" do
|
||||||
native_release = create(:medical_release_with_contract_template, :native, project: project)
|
native_release = create(:medical_release_with_contract_template, :native, project: project)
|
||||||
|
|
||||||
@@ -208,6 +229,64 @@ feature "User managing medical releases" do
|
|||||||
click_link *view_release_pdf_link_for(native_release)
|
click_link *view_release_pdf_link_for(native_release)
|
||||||
expect(content_type).to eq('application/pdf')
|
expect(content_type).to eq('application/pdf')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scenario "Reviewing release" do
|
||||||
|
create(:medical_release_with_contract_template, :native, project: project)
|
||||||
|
|
||||||
|
visit project_medical_releases_path(project)
|
||||||
|
|
||||||
|
click_link review_action
|
||||||
|
|
||||||
|
expect(page).to have_content review_page_heading
|
||||||
|
expect(page).to have_content approve_button
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'When viewing the contract PDF of approved release there is page for office use only' do
|
||||||
|
medical_release = create(:medical_release_with_contract_template,
|
||||||
|
:native,
|
||||||
|
project: project,
|
||||||
|
person_first_name: 'Jane',
|
||||||
|
person_last_name: 'Doe',
|
||||||
|
approved_by_user_name: "Big Joe",
|
||||||
|
approved_by_user_email: "some@email.com",
|
||||||
|
approved_at: DateTime.now)
|
||||||
|
|
||||||
|
sign_in(current_user)
|
||||||
|
visit project_medical_releases_path(project)
|
||||||
|
click_link *view_release_pdf_link_for(medical_release)
|
||||||
|
|
||||||
|
expect(content_type).to eq('application/pdf')
|
||||||
|
expect(content_disposition).to include('inline')
|
||||||
|
expect(pdf_body).to have_content for_office_use_only.upcase
|
||||||
|
expect(pdf_body).to have_content producer_label
|
||||||
|
expect(pdf_body).to have_content production_label
|
||||||
|
expect(pdf_body).to have_content employee_issued_to_label
|
||||||
|
expect(pdf_body).to have_content issued_by_label
|
||||||
|
expect(pdf_body).to have_content date_issued
|
||||||
|
expect(pdf_body).to have_content 'Big Joe'
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'When viewing the contract PDF of not approved release there is no page for office use only' do
|
||||||
|
medical_release = create(:medical_release_with_contract_template,
|
||||||
|
:native,
|
||||||
|
project: project,
|
||||||
|
person_first_name: 'Jane',
|
||||||
|
person_last_name: 'Doe')
|
||||||
|
|
||||||
|
sign_in(current_user)
|
||||||
|
visit project_medical_releases_path(project)
|
||||||
|
click_link *view_release_pdf_link_for(medical_release)
|
||||||
|
|
||||||
|
expect(content_type).to eq('application/pdf')
|
||||||
|
expect(content_disposition).to include('inline')
|
||||||
|
expect(pdf_body).not_to have_content for_office_use_only.upcase
|
||||||
|
expect(pdf_body).not_to have_content producer_label
|
||||||
|
expect(pdf_body).not_to have_content production_label
|
||||||
|
expect(pdf_body).not_to have_content employee_issued_to_label
|
||||||
|
expect(pdf_body).not_to have_content issued_by_label
|
||||||
|
expect(pdf_body).not_to have_content date_issued
|
||||||
|
expect(pdf_body).not_to have_content 'Big Joe'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when the user is manager(project manager)" do
|
context "when the user is manager(project manager)" do
|
||||||
@@ -235,6 +314,15 @@ feature "User managing medical releases" do
|
|||||||
expect(page).to have_link("Download", exact: true, count: 0)
|
expect(page).to have_link("Download", exact: true, count: 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scenario "Review action in Manage menu is not visible" do
|
||||||
|
create(:medical_release_with_contract_template, :native, project: project)
|
||||||
|
create(:medical_release_with_contract_template, :non_native, project: project)
|
||||||
|
|
||||||
|
visit project_medical_releases_path(project)
|
||||||
|
|
||||||
|
expect(page).not_to have_link(review_action, exact: true)
|
||||||
|
end
|
||||||
|
|
||||||
scenario "Downloading PDF of native medical release is not possible" do
|
scenario "Downloading PDF of native medical release is not possible" do
|
||||||
native_release = create(:medical_release_with_contract_template, :native, project: project)
|
native_release = create(:medical_release_with_contract_template, :native, project: project)
|
||||||
|
|
||||||
@@ -279,6 +367,15 @@ feature "User managing medical releases" do
|
|||||||
expect(page).to have_link("Download", exact: true, count: 0)
|
expect(page).to have_link("Download", exact: true, count: 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scenario "Review action in Manage menu is not visible" do
|
||||||
|
create(:medical_release_with_contract_template, :native, project: project)
|
||||||
|
create(:medical_release_with_contract_template, :non_native, project: project)
|
||||||
|
|
||||||
|
visit project_medical_releases_path(project)
|
||||||
|
|
||||||
|
expect(page).not_to have_link(review_action, exact: true)
|
||||||
|
end
|
||||||
|
|
||||||
scenario "Downloading PDF of native medical release is not possible" do
|
scenario "Downloading PDF of native medical release is not possible" do
|
||||||
native_release = create(:medical_release_with_contract_template, :native, project: project)
|
native_release = create(:medical_release_with_contract_template, :native, project: project)
|
||||||
|
|
||||||
@@ -458,4 +555,40 @@ feature "User managing medical releases" do
|
|||||||
def dummy_signature_legal_text
|
def dummy_signature_legal_text
|
||||||
'Some signature legal language'
|
'Some signature legal language'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def review_action
|
||||||
|
t 'medical_releases.medical_release.actions.review'
|
||||||
|
end
|
||||||
|
|
||||||
|
def review_page_heading
|
||||||
|
t 'medical_releases.review.heading'
|
||||||
|
end
|
||||||
|
|
||||||
|
def approve_button
|
||||||
|
t 'medical_releases.review.actions.approve'
|
||||||
|
end
|
||||||
|
|
||||||
|
def for_office_use_only
|
||||||
|
t 'contracts.for_office_use_only.heading'
|
||||||
|
end
|
||||||
|
|
||||||
|
def producer_label
|
||||||
|
t 'contracts.for_office_use_only.description_labels.producer'
|
||||||
|
end
|
||||||
|
|
||||||
|
def production_label
|
||||||
|
t 'contracts.for_office_use_only.description_labels.production'
|
||||||
|
end
|
||||||
|
|
||||||
|
def employee_issued_to_label
|
||||||
|
t 'contracts.for_office_use_only.description_labels.employee_issued_to'
|
||||||
|
end
|
||||||
|
|
||||||
|
def issued_by_label
|
||||||
|
t 'contracts.for_office_use_only.description_labels.issued_by'
|
||||||
|
end
|
||||||
|
|
||||||
|
def date_issued
|
||||||
|
t 'contracts.for_office_use_only.description_labels.date_issued'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user