|
|
@ -196,6 +196,7 @@ RSpec.describe User, type: :model do |
|
|
|
let!(:user_3) { FactoryBot.create(:user, name: "Tom Smith", email: "tom@example.com", organisation: organisation_1, role: "data_provider") } |
|
|
|
let!(:user_3) { FactoryBot.create(:user, name: "Tom Smith", email: "tom@example.com", organisation: organisation_1, role: "data_provider") } |
|
|
|
let!(:user_2) { FactoryBot.create(:user, name: "Jenny Ford", email: "jenny@smith.com", organisation: organisation_1, role: "data_coordinator") } |
|
|
|
let!(:user_2) { FactoryBot.create(:user, name: "Jenny Ford", email: "jenny@smith.com", organisation: organisation_1, role: "data_coordinator") } |
|
|
|
let!(:user_4) { FactoryBot.create(:user, name: "Greg Thomas", email: "greg@org_2.com", organisation: organisation_2, role: "data_coordinator") } |
|
|
|
let!(:user_4) { FactoryBot.create(:user, name: "Greg Thomas", email: "greg@org_2.com", organisation: organisation_2, role: "data_coordinator") } |
|
|
|
|
|
|
|
let!(:user_5) { FactoryBot.create(:user, name: "Adam Thomas", email: "adam@org_2.com", organisation: organisation_2, role: "data_coordinator") } |
|
|
|
|
|
|
|
|
|
|
|
context "when searching by name" do |
|
|
|
context "when searching by name" do |
|
|
|
it "returns case insensitive matching records" do |
|
|
|
it "returns case insensitive matching records" do |
|
|
@ -219,8 +220,8 @@ RSpec.describe User, type: :model do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
context "when using sorted by organisation and role scope" do |
|
|
|
context "when using sorted by organisation and role scope" do |
|
|
|
it "returns all users sorted by organisation name and then by role" do |
|
|
|
it "returns all users sorted by organisation name, then by role, then alphabetically by name" do |
|
|
|
expect(described_class.sorted_by_organisation_and_role.to_a).to eq([user_1, user_2, user_3, user_4]) |
|
|
|
expect(described_class.sorted_by_organisation_and_role.to_a).to eq([user_1, user_2, user_3, user_5, user_4]) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|