From 5efdd47f62ee6a4d989d67a8d90333aaa1052199 Mon Sep 17 00:00:00 2001 From: Martin Lensment Date: Wed, 19 Aug 2015 17:13:52 +0300 Subject: [PATCH] Add contact search test #2866 --- spec/features/admin/contact_spec.rb | 35 +++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/spec/features/admin/contact_spec.rb b/spec/features/admin/contact_spec.rb index 2d5936266..64ef6cc41 100644 --- a/spec/features/admin/contact_spec.rb +++ b/spec/features/admin/contact_spec.rb @@ -22,4 +22,39 @@ feature 'Admin contact', type: :feature do # indivitually running it's created by autotest page.should have_content(/by [unknown|autotest]/) end + + it 'should search contacts by name' do + d1 = Fabricate(:contact, name: 'first name') + Fabricate(:contact, name: 'second name') + Fabricate(:contact, name: 'third name') + sign_in @user + visit admin_contacts_url + + page.should have_content('first name') + page.should have_content('second name') + page.should have_content('third name') + + fill_in 'q_name_matches', with: 'first name' + find('.btn.btn-primary').click + + current_path.should == "/admin/contacts" + + page.should have_content('first name') + page.should_not have_content('second name') + page.should_not have_content('third name') + + fill_in 'q_name_matches', with: '%name' + find('.btn.btn-primary').click + + page.should have_content('first name') + page.should have_content('second name') + page.should have_content('third name') + + fill_in 'q_name_matches', with: 'sec___ name' + find('.btn.btn-primary').click + + page.should_not have_content('first name') + page.should have_content('second name') + page.should_not have_content('third name') + end end