-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
182 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
module ProviderInterface | ||
class ReportsController < ProviderInterfaceController | ||
def index | ||
@providers = current_user.providers | ||
@providers = current_user.providers.preload(:performance_reports) | ||
@performance_reports = current_user.providers.any? { _1.performance_reports.present? } | ||
end | ||
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
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
40 changes: 40 additions & 0 deletions
40
spec/system/provider_interface/reports/index_provider_user_one_provider_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,40 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.feature 'Provider reports index' do | ||
include DfESignInHelpers | ||
scenario 'when' do | ||
given_a_provider_and_provider_user_exists | ||
and_i_am_signed_in_as_provider_user | ||
expect(page).to have_current_path('/provider/applications', ignore_query: true) | ||
when_i_visit_the_reports_index | ||
expect(page).to have_current_path('/provider/reports', ignore_query: true) | ||
then_the_page_has_the_right_content | ||
end | ||
|
||
def when_i_visit_the_reports_index | ||
visit provider_interface_reports_path | ||
end | ||
|
||
def given_a_provider_and_provider_user_exists | ||
@provider_user = create(:provider_user, :with_dfe_sign_in, email_address: '[email protected]') | ||
@provider = @provider_user.providers.first | ||
end | ||
|
||
def then_the_page_has_the_right_content | ||
expect(page).to have_css('h1', text: 'Reports') | ||
expect(page).to have_css('a', text: 'Export data for Higher Education Statistics Agency (HESA)') | ||
expect(page).to have_css('h2', text: 'Application data for this recruitment cycle') | ||
expect(page).to have_css('a', text: 'Status of active applications').once | ||
expect(page).to have_css('a', text: 'Sex, disability, ethnicity and age of candidates').once | ||
expect(page).to have_css('h2', text: 'Download and export') | ||
expect(page).to have_css('a', text: 'Export application data') | ||
expect(page).to have_css('a', text: 'Withdrawals').once | ||
expect(page).to have_css('a', text: 'Export data for Higher Education Statistics Agency (HESA)').once | ||
end | ||
|
||
def and_i_am_signed_in_as_provider_user | ||
provider_exists_in_dfe_sign_in | ||
provider_signs_in_using_dfe_sign_in | ||
end | ||
alias_method :given_i_am_signed_in_as_provider_user, :and_i_am_signed_in_as_provider_user | ||
end |
48 changes: 48 additions & 0 deletions
48
spec/system/provider_interface/reports/index_provider_user_two_providers_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,48 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.feature 'Provider with two providers reports index' do | ||
include DfESignInHelpers | ||
scenario 'when a provider user has more than one provider' do | ||
given_a_provider_user_with_two_providers_exists | ||
and_i_am_signed_in_as_provider_user | ||
when_i_visit_the_reports_index | ||
and_the_page_has_all_the_right_elements | ||
end | ||
|
||
def when_i_visit_the_reports_index | ||
visit provider_interface_reports_path | ||
expect(page).to have_current_path('/provider/reports') | ||
end | ||
|
||
def given_a_provider_user_with_two_providers_exists | ||
@provider_user = create(:provider_user, :with_dfe_sign_in, email_address: '[email protected]') | ||
@provider = @provider_user.providers.first | ||
@second_provider = create(:provider) | ||
# add a second provider to the users account | ||
@provider_user.providers << @second_provider | ||
end | ||
|
||
def and_the_page_has_all_the_right_elements | ||
expect(page).to have_css('h1', text: 'Reports') | ||
expect(page).to have_css('h2', text: 'Application data for this recruitment cycle') | ||
expect(page).to have_css('a', text: 'Export application data') | ||
expect(page).to have_css('a', text: 'Export data for Higher Education Statistics Agency (HESA)') | ||
expect(page).to have_css('h3', text: @provider.name) | ||
expect(page).to have_css('a', text: 'Status of active applications') | ||
expect(page).to have_css('a', text: 'Sex, disability, ethnicity and age of candidates') | ||
expect(page).to have_css('a', text: 'Withdrawals') | ||
expect(page).to have_css('h3', text: @second_provider.name) | ||
expect(page).to have_css('a', text: 'Status of active applications') | ||
expect(page).to have_css('a', text: 'Sex, disability, ethnicity and age of candidates') | ||
expect(page).to have_css('a', text: 'Withdrawals') | ||
expect(page).to have_css('h2', text: 'Download and export') | ||
expect(page).to have_css('a', text: 'Export application data') | ||
expect(page).to have_css('a', text: 'Export data for Higher Education Statistics Agency (HESA)') | ||
end | ||
|
||
def and_i_am_signed_in_as_provider_user | ||
provider_exists_in_dfe_sign_in | ||
provider_signs_in_using_dfe_sign_in | ||
expect(page).to have_current_path('/provider/applications') | ||
end | ||
end |
56 changes: 56 additions & 0 deletions
56
...vider_interface/reports/index_provider_user_two_providers_with_performance_report_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,56 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.feature 'Provider with two providers reports index' do | ||
include DfESignInHelpers | ||
before { FeatureFlag.activate(:recruitment_performance_report) } | ||
|
||
scenario 'when' do | ||
given_a_provider_user_with_two_providers_exists | ||
and_a_provider_has_a_recruitment_peroformance_report | ||
and_i_am_signed_in_as_provider_user | ||
when_i_visit_the_reports_index | ||
then_the_page_has_the_right_content | ||
end | ||
|
||
def when_i_visit_the_reports_index | ||
visit provider_interface_reports_path | ||
expect(page).to have_current_path('/provider/reports', ignore_query: true) | ||
end | ||
|
||
def and_a_provider_has_a_recruitment_peroformance_report | ||
create(:provider_recruitment_performance_report, provider: @provider) | ||
end | ||
|
||
def given_a_provider_user_with_two_providers_exists | ||
@provider_user = create(:provider_user, :with_dfe_sign_in, email_address: '[email protected]') | ||
@provider = @provider_user.providers.first | ||
@second_provider = create(:provider) | ||
@provider_user.providers << @second_provider | ||
end | ||
|
||
def then_the_page_has_the_right_content | ||
expect(page).to have_css('h1', text: 'Reports') | ||
expect(page).to have_css('h2', text: 'Weekly recruitment performance report') | ||
expect(page).to have_css('a', text: 'Weekly report for week ending 2024-06-25') | ||
expect(page).to have_css('h2', text: 'Application data for this recruitment cycle') | ||
expect(page).to have_css('a', text: 'Export application data') | ||
expect(page).to have_css('a', text: 'Export data for Higher Education Statistics Agency (HESA)') | ||
expect(page).to have_css('h3', text: @provider.name) | ||
expect(page).to have_css('a', text: 'Status of active applications') | ||
expect(page).to have_css('a', text: 'Sex, disability, ethnicity and age of candidates') | ||
expect(page).to have_css('a', text: 'Withdrawals') | ||
expect(page).to have_css('h3', text: @second_provider.name) | ||
expect(page).to have_css('a', text: 'Status of active applications') | ||
expect(page).to have_css('a', text: 'Sex, disability, ethnicity and age of candidates') | ||
expect(page).to have_css('a', text: 'Withdrawals') | ||
expect(page).to have_css('h2', text: 'Download and export') | ||
expect(page).to have_css('a', text: 'Export application data') | ||
expect(page).to have_css('a', text: 'Export data for Higher Education Statistics Agency (HESA)') | ||
end | ||
|
||
def and_i_am_signed_in_as_provider_user | ||
provider_exists_in_dfe_sign_in | ||
provider_signs_in_using_dfe_sign_in | ||
expect(page).to have_current_path('/provider/applications', ignore_query: true) | ||
end | ||
end |