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 29, 2024
1 parent f1f9713 commit e0cc016
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/components/state_tag_component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= state_tag %>
16 changes: 16 additions & 0 deletions app/components/state_tag_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class StateTagComponent < ApplicationComponent
attr_reader :claim

def initialize(claim:, classes: [], html_attributes: {})
super(classes:, html_attributes:)

@claim = claim
end
end

def state_tag
css_class = claim.draft ? "govuk-tag--grey" : "govuk-tag--blue"
text = claim.draft ? I18n.t("components.state_tag_component.draft") : I18n.t("components.state_tag_component.submitted")

content_tag(:p, text, class: "govuk-tag #{css_class}")
end
4 changes: 4 additions & 0 deletions app/controllers/claims/support/schools/claims_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
class Claims::Support::Schools::ClaimsController < Claims::Support::ApplicationController
include Claims::BelongsToSchool

def index
@claims = @school.claims.order("created_at DESC")
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"><%= render(StateTagComponent.new(claim:)) %>
</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
6 changes: 6 additions & 0 deletions config/locales/en/components/stage_tag_component.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
en:
components:
state_tag_component:
draft: Draft
submitted: Submitted

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
require "rails_helper"

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

let!(:colin) { create(:persona, :colin, service: "claims") }

let!(:submitted_claim) { create(:claim, school_id: school.id, draft: false) }
let!(:draft_claim) { create(:claim, school_id: school.id, draft: true) }
let!(:claim_from_another_school) { create(:claim, school_id: another_school.id, draft: true) }

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
i_dont_see_claims_from_other_schools
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("#{draft_claim.id}\nDraft\n#{submitted_claim.id}\nSubmitted")
end

def i_dont_see_claims_from_other_schools
expect(page).not_to have_content("#{claim_from_another_school.id}\nDraft")
end
end

0 comments on commit e0cc016

Please sign in to comment.