-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test that the users can download their CSV and that support users can…
… still upload the sampling CSV
- Loading branch information
Showing
5 changed files
with
143 additions
and
1 deletion.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
...em/claims/sampling/claims/provider_user_downloads_sampling_csv_with_expired_token_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,31 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe "Provider user downloads a sampling CSV with expired token", service: :claims, type: :system do | ||
scenario do | ||
given_one_of_my_claims_has_been_sampled | ||
and_the_token_has_expired | ||
|
||
when_i_visit_the_download_link_in_the_email | ||
then_i_see_the_error_page | ||
end | ||
|
||
private | ||
|
||
def given_one_of_my_claims_has_been_sampled | ||
@provider_sampling = create(:provider_sampling) | ||
end | ||
|
||
def and_the_token_has_expired | ||
@token = Rails.application.message_verifier(:sampling).generate(@provider_sampling.id, expires_at: 1.day.ago) | ||
end | ||
|
||
def when_i_visit_the_download_link_in_the_email | ||
visit claims_sampling_claims_path(token: @token) | ||
end | ||
|
||
def then_i_see_the_error_page | ||
expect(page).to have_h1("Sorry, there is a problem with the download link") | ||
expect(page).to have_element(:p, text: "You are seeing this page because the download link is not working. It may have timed out or contained an invalid security token.", class: "govuk-body") | ||
expect(page).to have_element(:p, text: "Email ittmentor.funding@education.gov.uk to request a new download link.", class: "govuk-body") | ||
end | ||
end |
31 changes: 31 additions & 0 deletions
31
...ms/sampling/claims/provider_user_downloads_sampling_csv_with_invalid_record_token_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,31 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe "Provider user downloads a sampling CSV with invalid record token", service: :claims, type: :system do | ||
scenario do | ||
given_one_of_my_claims_has_been_sampled | ||
and_the_token_has_expired | ||
|
||
when_i_visit_the_download_link_in_the_email | ||
then_i_see_the_error_page | ||
end | ||
|
||
private | ||
|
||
def given_one_of_my_claims_has_been_sampled | ||
@provider_sampling = create(:provider_sampling) | ||
end | ||
|
||
def and_the_token_has_expired | ||
@token = Rails.application.message_verifier(:sampling).generate("invalid_token", expires_in: 7.days) | ||
end | ||
|
||
def when_i_visit_the_download_link_in_the_email | ||
visit claims_sampling_claims_path(token: @token) | ||
end | ||
|
||
def then_i_see_the_error_page | ||
expect(page).to have_h1("Sorry, there is a problem with the download link") | ||
expect(page).to have_element(:p, text: "You are seeing this page because the download link is not working. It may have timed out or contained an invalid security token.", class: "govuk-body") | ||
expect(page).to have_element(:p, text: "Email ittmentor.funding@education.gov.uk to request a new download link.", class: "govuk-body") | ||
end | ||
end |
31 changes: 31 additions & 0 deletions
31
...em/claims/sampling/claims/provider_user_downloads_sampling_csv_with_invalid_token_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,31 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe "Provider user downloads a sampling CSV with invalid token", service: :claims, type: :system do | ||
scenario do | ||
given_one_of_my_claims_has_been_sampled | ||
and_the_token_is_invalid | ||
|
||
when_i_visit_the_download_link_in_the_email | ||
then_i_see_the_error_page | ||
end | ||
|
||
private | ||
|
||
def given_one_of_my_claims_has_been_sampled | ||
@provider_sampling = create(:provider_sampling) | ||
end | ||
|
||
def and_the_token_is_invalid | ||
@token = Rails.application.message_verifier(:bobs_burgers).generate(@provider_sampling.id, expires_in: 7.days) | ||
end | ||
|
||
def when_i_visit_the_download_link_in_the_email | ||
visit claims_sampling_claims_path(token: @token) | ||
end | ||
|
||
def then_i_see_the_error_page | ||
expect(page).to have_h1("Sorry, there is a problem with the download link") | ||
expect(page).to have_element(:p, text: "You are seeing this page because the download link is not working. It may have timed out or contained an invalid security token.", class: "govuk-body") | ||
expect(page).to have_element(:p, text: "Email ittmentor.funding@education.gov.uk to request a new download link.", class: "govuk-body") | ||
end | ||
end |
45 changes: 45 additions & 0 deletions
45
...stem/claims/sampling/claims/provider_user_downloads_sampling_csv_with_valid_token_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,45 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe "Provider user downloads sampling CSV with valid token", service: :claims, type: :system do | ||
scenario do | ||
given_one_of_my_claims_has_been_sampled | ||
and_the_token_is_valid | ||
|
||
when_i_visit_the_download_link_in_the_email | ||
then_i_see_the_download_page | ||
|
||
when_i_click_on_the_download_button | ||
then_the_csv_is_downloaded | ||
end | ||
|
||
private | ||
|
||
def given_one_of_my_claims_has_been_sampled | ||
@provider_sampling = create(:provider_sampling) | ||
end | ||
|
||
def and_the_token_is_valid | ||
@token = Rails.application.message_verifier(:sampling).generate(@provider_sampling.id, expires_in: 7.days) | ||
end | ||
|
||
def when_i_visit_the_download_link_in_the_email | ||
visit claims_sampling_claims_path(token: @token) | ||
end | ||
|
||
def then_i_see_the_download_page | ||
expect(page).to have_h1("Download the sampling CSV") | ||
expect(page).to have_element(:p, text: "Download the Claim funding for mentor training sampling CSV file.", class: "govuk-body") | ||
expect(page).to have_element(:p, text: "If you have any questions, email ittmentor.funding@education.gov.uk", class: "govuk-body") | ||
expect(page).to have_element(:a, text: "Download", class: "govuk-button") | ||
end | ||
|
||
def when_i_click_on_the_download_button | ||
click_on "Download" | ||
end | ||
|
||
def then_the_csv_is_downloaded | ||
current_time = Time.zone.now.utc.strftime("%Y-%m-%dT%H%%3A%M%%3A%SZ") | ||
expect(page.response_headers["Content-Type"]).to eq("text/csv") | ||
expect(page.response_headers["Content-Disposition"]).to eq("attachment; filename=\"sampling-claims-#{current_time}.csv\"; filename*=UTF-8''sampling-claims-#{current_time}.csv") | ||
end | ||
end |
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