-
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.
We want an organisation index for each service. This index page will be shown to the user after he sigin in as a persona only if the user has multiple organisations. An organisation can be a school or a provider, the Membership polymorphic table handles this. The Placements service will show both schools and providers, the claims only schools.
- Loading branch information
1 parent
ac4268f
commit 4e9d6b9
Showing
24 changed files
with
325 additions
and
1 deletion.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class Claims::OrganisationsController < ApplicationController | ||
def index | ||
@schools = current_user.schools | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class Placements::OrganisationsController < ApplicationController | ||
def index | ||
@schools = current_user.schools | ||
@providers = current_user.providers | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# == Schema Information | ||
# | ||
# Table name: memberships | ||
# | ||
# id :uuid not null, primary key | ||
# organisation_type :string not null | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# organisation_id :uuid not null | ||
# user_id :uuid not null | ||
# | ||
# Indexes | ||
# | ||
# index_memberships_on_organisation (organisation_type,organisation_id) | ||
# index_memberships_on_user_id (user_id) | ||
# | ||
# Foreign Keys | ||
# | ||
# fk_rails_... (user_id => users.id) | ||
# | ||
class Membership < ApplicationRecord | ||
belongs_to :user | ||
belongs_to :organisation, polymorphic: true | ||
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
<h1 class="govuk-heading-xl"><%= t("organisations") %></h1> | ||
|
||
<% if @schools.any? %> | ||
<ul class="govuk-list"> | ||
<% @schools.each do |school| %> | ||
<li> | ||
<%= govuk_link_to school.name, request.env["PATH_INFO"], class: "govuk-link--no-visited-state" %> | ||
</li> | ||
<% end %> | ||
</ul> | ||
<% end %> | ||
</div> | ||
</div> |
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,27 @@ | ||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
<h1 class="govuk-heading-xl"><%= t("organisations") %></h1> | ||
|
||
<% if @schools.any? %> | ||
<h2 class="govuk-heading-l"><%= t("schools") %></h2> | ||
<ul class="govuk-list"> | ||
<% @schools.each do |school| %> | ||
<li> | ||
<%= govuk_link_to school.name, request.env["PATH_INFO"], class: "govuk-link--no-visited-state" %> | ||
</li> | ||
<% end %> | ||
</ul> | ||
<% end %> | ||
|
||
<% if @providers.any? %> | ||
<h2 class="govuk-heading-l"><%= t("providers") %></h2> | ||
<ul class="govuk-list"> | ||
<% @providers.each do |provider| %> | ||
<li> | ||
<%= govuk_link_to provider.provider_code, request.env["PATH_INFO"], class: "govuk-link--no-visited-state" %> | ||
</li> | ||
<% end %> | ||
</ul> | ||
<% end %> | ||
</div> | ||
</div> |
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,6 @@ | ||
SCHOOLS = [ | ||
{ claims: true }, | ||
{ placements: true }, | ||
{ claims: true, placements: true }, | ||
{ claims: true, placements: true } | ||
].freeze |
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,3 +1,5 @@ | ||
scope module: :claims, as: :claims, constraints: { host: ENV["CLAIMS_HOST"] } do | ||
root to: "pages#index" | ||
|
||
resources :organisations, only: [:index] | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class CreateMemberships < ActiveRecord::Migration[7.1] | ||
def change | ||
create_table :memberships, id: :uuid do |t| | ||
t.references :user, null: false, foreign_key: true, type: :uuid | ||
t.references :organisation, polymorphic: true, null: false, type: :uuid | ||
|
||
t.timestamps | ||
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
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,26 @@ | ||
# == Schema Information | ||
# | ||
# Table name: memberships | ||
# | ||
# id :uuid not null, primary key | ||
# organisation_type :string not null | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# organisation_id :uuid not null | ||
# user_id :uuid not null | ||
# | ||
# Indexes | ||
# | ||
# index_memberships_on_organisation (organisation_type,organisation_id) | ||
# index_memberships_on_user_id (user_id) | ||
# | ||
# Foreign Keys | ||
# | ||
# fk_rails_... (user_id => users.id) | ||
# | ||
FactoryBot.define do | ||
factory :membership do | ||
association :user | ||
association :organisation, factory: :school | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# == Schema Information | ||
# | ||
# Table name: memberships | ||
# | ||
# id :uuid not null, primary key | ||
# organisation_type :string not null | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# organisation_id :uuid not null | ||
# user_id :uuid not null | ||
# | ||
# Indexes | ||
# | ||
# index_memberships_on_organisation (organisation_type,organisation_id) | ||
# index_memberships_on_user_id (user_id) | ||
# | ||
# Foreign Keys | ||
# | ||
# fk_rails_... (user_id => users.id) | ||
# | ||
require 'rails_helper' | ||
|
||
RSpec.describe Membership, type: :model do | ||
subject { create(:membership) } | ||
|
||
context "associations" do | ||
it do | ||
should belong_to(:user) | ||
should belong_to(:organisation) | ||
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
require "rails_helper" | ||
|
||
feature "View organisations as a multi org user" do | ||
around do |example| | ||
Capybara.app_host = "https://#{ENV["CLAIMS_HOST"]}" | ||
example.run | ||
Capybara.app_host = nil | ||
end | ||
|
||
scenario "I sign in as persona Marry" do | ||
persona = given_there_is_an_existing_claims_persona_for("Mary") | ||
and_persona_has_multiple_organisations(persona) | ||
when_i_visit_the_claims_personas_page | ||
when_i_click_sign_in_as(persona) | ||
i_can_see_a_list_marys_organisations(persona) | ||
end | ||
end | ||
|
||
private | ||
|
||
def given_there_is_an_existing_claims_persona_for(persona_name) | ||
create(:persona, persona_name.downcase.to_sym, service: "claims") | ||
end | ||
|
||
def and_persona_has_multiple_organisations(persona) | ||
school1 = create(:school) | ||
school2 = create(:school) | ||
create(:membership, user: persona, organisation: school1) | ||
create(:membership, user: persona, organisation: school2) | ||
end | ||
|
||
def when_i_visit_the_claims_personas_page | ||
visit personas_path | ||
end | ||
|
||
def when_i_click_sign_in_as(persona) | ||
click_on "Sign In as #{persona.first_name}" | ||
end | ||
|
||
def i_can_see_a_list_marys_organisations(persona) | ||
expect(page).to have_content("Organisations") | ||
expect(page).to have_content(persona.schools.first.name) | ||
expect(page).to have_content(persona.schools.last.name) | ||
end |
Oops, something went wrong.