Browse Source

CLDC-3063: Sort alphabetically stock owners and managing agents lists (#2687)

* Sort alphabetically stock owners and managing agents lists
pull/2696/head
Manny Dinssa 3 months ago committed by GitHub
parent
commit
320d9689fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      app/controllers/organisation_relationships_controller.rb
  2. 37
      spec/features/organisation_relationships.html.erb_spec.rb

4
app/controllers/organisation_relationships_controller.rb

@ -14,7 +14,7 @@ class OrganisationRelationshipsController < ApplicationController
]
def stock_owners
stock_owners = organisation.stock_owners.filter_by_active
stock_owners = organisation.stock_owners.filter_by_active.order("LOWER(name)")
unpaginated_filtered_stock_owners = filtered_collection(stock_owners, search_term)
@pagy, @stock_owners = pagy(unpaginated_filtered_stock_owners)
@ -23,7 +23,7 @@ class OrganisationRelationshipsController < ApplicationController
end
def managing_agents
managing_agents = organisation.managing_agents.filter_by_active
managing_agents = organisation.managing_agents.filter_by_active.order("LOWER(name)")
unpaginated_filtered_managing_agents = filtered_collection(managing_agents, search_term)
@pagy, @managing_agents = pagy(unpaginated_filtered_managing_agents)

37
spec/features/organisation_relationships.html.erb_spec.rb

@ -0,0 +1,37 @@
require "rails_helper"
RSpec.describe "OrganisationRelationships", type: :feature do
context "when viewing the stock owners page" do
let(:user) { create(:user) }
before do
sign_in user
create(:organisation_relationship, parent_organisation: create(:organisation, name: "Zeta"), child_organisation: user.organisation)
create(:organisation_relationship, parent_organisation: create(:organisation, name: "Alpha"), child_organisation: user.organisation)
create(:organisation_relationship, parent_organisation: create(:organisation, name: "Gamma"), child_organisation: user.organisation)
create(:organisation_relationship, parent_organisation: create(:organisation, name: "ABACUS"), child_organisation: user.organisation)
visit("organisations/#{user.organisation.id}/stock-owners")
end
it "displays stock owners in alphabetical order" do
expect(page).to have_content(/ABACUS.*Alpha.*Gamma.*Zeta/m)
end
end
context "when viewing the managing agents page" do
let(:user) { create(:user) }
before do
sign_in user
create(:organisation_relationship, parent_organisation: user.organisation, child_organisation: create(:organisation, name: "Zeta"))
create(:organisation_relationship, parent_organisation: user.organisation, child_organisation: create(:organisation, name: "Alpha"))
create(:organisation_relationship, parent_organisation: user.organisation, child_organisation: create(:organisation, name: "Gamma"))
create(:organisation_relationship, parent_organisation: user.organisation, child_organisation: create(:organisation, name: "ABACUS"))
visit("organisations/#{user.organisation.id}/managing-agents")
end
it "displays stock owners in alphabetical order" do
expect(page).to have_content(/ABACUS.*Alpha.*Gamma.*Zeta/m)
end
end
end
Loading…
Cancel
Save