Skip to content

Commit

Permalink
Add organisations controller and view
Browse files Browse the repository at this point in the history
  • Loading branch information
elceebee committed Dec 19, 2023
1 parent a428792 commit c3c07e3
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 22 deletions.
6 changes: 1 addition & 5 deletions app/controllers/personas_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

class PersonasController < ApplicationController
def index
if current_service.present?
@personas = Persona.public_send(current_service).decorate
else
redirect_to :not_found
end
@personas = Persona.public_send(current_service).decorate
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Placements::Support::ApplicationController < ApplicationController

def authenticate_support_user!
authenticate_user!

if support_user.blank?
redirect_to placements_root_path, alert: "You cannot perform this action"
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Placements::Support::OrganisationsController < Placements::Support::ApplicationController
def index
@schools = Placements::School.includes(:gias_school)
# TODO: when we have more from the provider API....
@providers = Provider.all
end
end
9 changes: 0 additions & 9 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,4 @@ def current_service
:placements
end
end

def root_path
case current_service
when :claims
claims_root_path
when :placements
placements_root_path
end
end
end
2 changes: 2 additions & 0 deletions app/models/school.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class School < ApplicationRecord
validates :urn, presence: true
validates :urn, uniqueness: { case_sensitive: false }

delegate :name, to: :gias_school

scope :placements, -> { where placements: true }
scope :claims, -> { where claims: true }
end
23 changes: 23 additions & 0 deletions app/views/placements/support/organisations/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-xl"><%= t("organisations").capitalize %></h1>

<% if @schools.any? %>
<h2 class="govuk-heading-l"><%= t("schools").capitalize %></h2>
<ul class="govuk-list">
<% @schools.each do |school| %>
<li><%= school.name %></li>
<% end %>
</ul>
<% end %>

<% if @providers.any? %>
<h2 class="govuk-heading-l"><%= t("providers").capitalize %></h2>
<ul class="govuk-list">
<% @providers.each do |provider| %>
<li><%= provider.provider_code %></li>
<% end %>
</ul>
<% end %>
</div>
</div>
3 changes: 3 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
en:
organisations: organisations
schools: schools
providers: providers
account:
index:
email_address: Email address
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ def when_i_visit_the_personas_page
end

def and_there_are_placement_organisations
create(:gias_school, name: "Placement School")
create(:school, :placements)
create(:provider, id: 123_456_789)
gias_school = create(:gias_school, name: "Placement School")
create(:school, :placements, urn: gias_school.urn)
create(:provider, provider_code: "PROVIDER_CODE")
end

def then_i_see_the_persona_for(persona_name)
Expand All @@ -78,10 +78,9 @@ def and_i_visit_my_account_page
end

def then_i_see_a_list_of_organisations
expect(path).to eq dashboard_path
expect(page).to have_content("Placements School")
# We won't have a name or data for the providers until after the Provider API integration is done
expect(page).to have_content("123456789")
expect(current_path).to eq placements_support_organisations_path
expect(page).to have_content("Placement School")
expect(page).to have_content("PROVIDER_CODE")
end

def then_i_see_persona_details_for_anne
Expand Down

0 comments on commit c3c07e3

Please sign in to comment.