diff --git a/spec/finders/crm/contacts_finder_spec.rb b/spec/finders/crm/contacts_finder_spec.rb index 0c10d6ab6a91a6184df5b1954489a08091a7333e..14f838812a6056600ab9cf153864379ee6112a3e 100644 --- a/spec/finders/crm/contacts_finder_spec.rb +++ b/spec/finders/crm/contacts_finder_spec.rb @@ -101,18 +101,18 @@ context 'when search term is empty' do it 'returns all group contacts alphabetically ordered' do finder = described_class.new(user, group: search_test_group, search: "") - expect(finder.execute).to match_array([search_test_a, search_test_b]) + expect(finder.execute).to eq([search_test_a, search_test_b]) end end context 'when search term is not empty' do - it 'searches for first name' do - finder = described_class.new(user, group: search_test_group, search: "abc") + it 'searches for first name ignoring casing' do + finder = described_class.new(user, group: search_test_group, search: "aBc") expect(finder.execute).to match_array([search_test_a]) end - it 'searches for last name' do - finder = described_class.new(user, group: search_test_group, search: "STU") + it 'searches for last name ignoring casing' do + finder = described_class.new(user, group: search_test_group, search: "StU") expect(finder.execute).to match_array([search_test_b]) end @@ -121,10 +121,15 @@ expect(finder.execute).to match_array([search_test_a]) end - it 'searches for description' do - finder = described_class.new(user, group: search_test_group, search: "YZ") + it 'searches for description ignoring casing' do + finder = described_class.new(user, group: search_test_group, search: "Yz") expect(finder.execute).to match_array([search_test_b]) end + + it 'fuzzy searches for email and last name' do + finder = described_class.new(user, group: search_test_group, search: "s") + expect(finder.execute).to match_array([search_test_a, search_test_b]) + end end context 'when searching for contacts state' do diff --git a/spec/finders/crm/organizations_finder_spec.rb b/spec/finders/crm/organizations_finder_spec.rb index 354fd216b89665f7ec28065ff871b46b5424122f..a4d76db37338a64f8640096330ecfae4ba317565 100644 --- a/spec/finders/crm/organizations_finder_spec.rb +++ b/spec/finders/crm/organizations_finder_spec.rb @@ -95,7 +95,7 @@ context 'when search term is empty' do it 'returns all group organizations alphabetically ordered' do finder = described_class.new(user, group: search_test_group, search: "") - expect(finder.execute).to match_array([search_test_b, search_test_a]) + expect(finder.execute).to eq([search_test_b, search_test_a]) end end diff --git a/spec/graphql/resolvers/crm/contacts_resolver_spec.rb b/spec/graphql/resolvers/crm/contacts_resolver_spec.rb index 337b25f501a0c61154328ed657307becf4945ac9..eba26c8c71fb8e585843a899658f328cd058810c 100644 --- a/spec/graphql/resolvers/crm/contacts_resolver_spec.rb +++ b/spec/graphql/resolvers/crm/contacts_resolver_spec.rb @@ -34,16 +34,18 @@ describe '#resolve' do context 'with unauthorized user' do - it 'returns no contacts' do + it 'does not rise an error and returns no contacts' do + expect { resolve_contacts(group) }.not_to raise_error expect(resolve_contacts(group)).to be_empty end end context 'with authorized user' do - it 'returns no contacts' do - group.add_guest(user) + it 'does not rise an error and returns all contacts' do + group.add_reporter(user) expect { resolve_contacts(group) }.not_to raise_error + expect(resolve_contacts(group)).to eq([contact_a, contact_b]) end end diff --git a/spec/graphql/resolvers/crm/organizations_resolver_spec.rb b/spec/graphql/resolvers/crm/organizations_resolver_spec.rb index 643c1156a5823c0728a5225c3b786fe926b19201..c80caf91f90ddb046cea28c53d0ac7549950c55a 100644 --- a/spec/graphql/resolvers/crm/organizations_resolver_spec.rb +++ b/spec/graphql/resolvers/crm/organizations_resolver_spec.rb @@ -28,16 +28,18 @@ describe '#resolve' do context 'with unauthorized user' do - it 'returns no organizations' do + it 'does not rise an error and returns no organizations' do + expect { resolve_organizations(group) }.not_to raise_error expect(resolve_organizations(group)).to be_empty end end context 'with authorized user' do - it 'returns no organizations' do - group.add_guest(user) + it 'does not rise an error and returns all organizations' do + group.add_reporter(user) expect { resolve_organizations(group) }.not_to raise_error + expect(resolve_organizations(group)).to eq([organization_a, organization_b]) end end