-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Add check for audit certificate deadline for controller actions
- Add before_action to check if it's before the financial statement deadline - Add before_action to check if the audit certificate can be viewed - Update show view to display appropriate links based on the deadline Signed-off-by: Louis Kirkham <[email protected]>
- Loading branch information
1 parent
ceceba6
commit 0871ff7
Showing
5 changed files
with
94 additions
and
6 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
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
59 changes: 59 additions & 0 deletions
59
spec/controllers/users/audit_certificates_controller_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,59 @@ | ||
require "rails_helper" | ||
|
||
describe Users::AuditCertificatesController, type: :controller do | ||
let!(:user) { create :user, :completed_profile, role: "account_admin" } | ||
let!(:award_year) { AwardYear.current } | ||
let!(:form_answer) { create(:form_answer, :innovation, user: user, award_year: award_year) } | ||
|
||
before do | ||
sign_in user | ||
end | ||
|
||
describe "GET show" do | ||
describe "before the financial statement deadline" do | ||
let!(:settings) { create(:settings) } | ||
|
||
it "should render the template" do | ||
get :show, params: { form_answer_id: form_answer.id } | ||
|
||
expect(response).to render_template(:show) | ||
end | ||
end | ||
|
||
describe "after the financial statement deadline" do | ||
let!(:settings) { create(:settings, :expired_audit_submission_deadline) } | ||
|
||
describe "without an audit certificate" do | ||
it "should redirect to the dashboard" do | ||
get :show, params: { form_answer_id: form_answer.id } | ||
|
||
expect(response).to redirect_to dashboard_url | ||
expect(flash[:alert]).to eq("You cannot upload the Verification of Commercial Figures after the deadline.") | ||
end | ||
end | ||
|
||
describe "with an audit certificate" do | ||
let!(:audit_certificate) { create(:audit_certificate, form_answer: form_answer) } | ||
it "should render the template" do | ||
get :show, params: { form_answer_id: form_answer.id } | ||
|
||
expect(response).to render_template(:show) | ||
end | ||
end | ||
end | ||
end | ||
|
||
describe "DELETE destroy" do | ||
describe "after the financial statement deadline" do | ||
let!(:settings) { create(:settings, :expired_audit_submission_deadline) } | ||
let!(:audit_certificate) { create(:audit_certificate, form_answer: form_answer) } | ||
|
||
it "should redirect to the dashboard" do | ||
delete :destroy, params: { form_answer_id: form_answer.id } | ||
|
||
expect(response).to redirect_to dashboard_url | ||
expect(flash[:alert]).to eq("You cannot amend the Verification of Commercial Figures after the deadline.") | ||
end | ||
end | ||
end | ||
end |