Browse Source

more tests passing

pull/787/head
JG 3 years ago
parent
commit
987c44315d
  1. 13
      app/models/user.rb
  2. 9
      spec/models/form/setup/questions/created_by_id_spec.rb
  3. 4
      spec/models/user_spec.rb

13
app/models/user.rb

@ -122,19 +122,6 @@ class User < ApplicationRecord
ROLES.except(:support)
end
def assignable_roles_with_hints
roles_with_hints = {
data_provider: "Can view and submit logs for this this organisation",
data_coordinator: "data_coordinator",
support: "support",
}
return {} unless data_coordinator? || support?
return roles_with_hints if support?
roles_with_hints.except(:support)
end
def case_logs_filters(specific_org: false)
if support? && !specific_org
%w[status years user organisation]

9
spec/models/form/setup/questions/created_by_id_spec.rb

@ -8,9 +8,10 @@ RSpec.describe Form::Setup::Questions::CreatedById, type: :model do
let(:page) { instance_double(Form::Page) }
let(:subsection) { instance_double(Form::Subsection) }
let(:form) { instance_double(Form) }
let!(:user_1) { FactoryBot.build(:user, name: "first user") }
let!(:user_2) { FactoryBot.build(:user, name: "second user") }
let!(:user_3) { FactoryBot.build(:user, name: nil, email: "madeupmail@example.com") }
let!(:user_1) { FactoryBot.create(:user, name: "first user") }
let!(:user_2) { FactoryBot.create(:user, name: "second user") }
let(:user_3) { FactoryBot.build(:user, name: nil, email: "madeupmail@example.com") }
let(:users) { [user_1, user_2, user_3] }
let(:expected_answer_options) do
{
"" => "Select an option",
@ -21,7 +22,7 @@ RSpec.describe Form::Setup::Questions::CreatedById, type: :model do
end
before do
allow(User).to receive(:select).and_return [user_1, user_2, user_3]
allow(User).to receive(:select).and_return users
end
it "has correct page" do

4
spec/models/user_spec.rb

@ -195,8 +195,8 @@ RSpec.describe User, type: :model do
let!(:user_1) { FactoryBot.create(:user, name: "Joe Bloggs", email: "joe@example.com", organisation: organisation_1, role: "support") }
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_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") }
let!(:user_4) { FactoryBot.create(:user, name: "Greg Thomas", email: "greg@org2.com", organisation: organisation_2, role: "data_coordinator") }
let!(:user_5) { FactoryBot.create(:user, name: "Adam Thomas", email: "adam@org2.com", organisation: organisation_2, role: "data_coordinator") }
context "when searching by name" do
it "returns case insensitive matching records" do

Loading…
Cancel
Save