Skip to content

Commit

Permalink
As a Support User, I should be able to see all Claims made by a School
Browse files Browse the repository at this point in the history
  • Loading branch information
gms-gs committed Jan 27, 2024
1 parent f1f9713 commit 5b3aa21
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/controllers/claims/support/schools/claims_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
class Claims::Support::Schools::ClaimsController < Claims::Support::ApplicationController
include Claims::BelongsToSchool
include Claims::Support::ClaimsHelper

def index
@claims = @school.claims.order("created_at DESC")
end
end
8 changes: 8 additions & 0 deletions app/helpers/claims/support/claims_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module Claims::Support::ClaimsHelper
def claim_draft_state(claim)
css_class = claim.draft ? "govuk-tag--grey" : "govuk-tag--blue"
text = claim.draft ? "Draft" : "Submitted"

"<strong class='govuk-tag #{css_class}'>#{text}</strong>".html_safe
end
end
17 changes: 17 additions & 0 deletions app/views/claims/support/schools/claims/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h2 class="govuk-heading-m"><%= t(".heading") %></h2>

<table class="govuk-table">
<thead class="govuk-table__head">
<tr class="govuk-table__row">
<th scope="col" class="govuk-table__header"><%= t(".claim_id") %></th>
<th scope="col" class="govuk-table__header"></th>
</tr>
</thead>
<tbody class="govuk-table__body">
<% @claims.each do |claim| %>
<tr class="govuk-table__row">
<td class="govuk-table__cell"><%= govuk_link_to claim.id, claims_support_school_claim_path(id: claim) %></td>
<td class="govuk-table__cell"><%= claim_draft_state(claim) %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
11 changes: 11 additions & 0 deletions app/views/claims/support/schools/claims/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<div class="govuk-width-container">
<h1 class="govuk-heading-l"><%= @school.name %></h1>

<%= render "claims/support/schools/secondary_navigation", school: @school %>

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h2 class="govuk-heading-m"><%= t(".heading") %></h2>
</div>
</div>
</div>
1 change: 1 addition & 0 deletions config/locales/en/claims/support/schools/claims.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ en:
claims:
index:
heading: Claims
claim_id: ID
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
require "rails_helper"

RSpec.describe "View a schools claims", type: :system, service: :claims do
let!(:school) { create(:school, :claims).becomes(Claims::School) }
let!(:colin) { create(:persona, :colin, service: "claims") }
let!(:claim) { create(:claim, school_id: school.id) }

scenario "View a school's claims as a support user" do
given_i_sign_in_as_colin
when_i_visit_the_claims_support_school_claims_page
i_see_a_list_of_the_schools_claims
end

private

def given_i_sign_in_as_colin
and_i_visit_the_personas_page
and_i_click_sign_in_as("Colin")
end

def and_i_visit_the_personas_page
visit personas_path
end

def and_i_click_sign_in_as(persona_name)
click_on "Sign In as #{persona_name}"
end

def when_i_visit_the_claims_support_school_claims_page
visit claims_support_school_claims_path(school)
end

def i_see_a_list_of_the_schools_claims
expect(page).to have_content("Claims\nID #{claim.id} Submitted")
end
end

0 comments on commit 5b3aa21

Please sign in to comment.