Skip to content

Commit

Permalink
add missing test for search bar
Browse files Browse the repository at this point in the history
  • Loading branch information
nstrelow committed Jan 11, 2017
1 parent a3d6c68 commit 8bd3a98
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions spec/features/user_spec.rb
Expand Up @@ -82,6 +82,27 @@
first('input[value="%s"]' % I18n.t("users.index.save") ).click
end

it "can search for users" do
max1 = FactoryGirl.create(:user)
max1.profile = FactoryGirl.create(:profile, first_name: "Max")
max2 = FactoryGirl.create(:user)
max2.profile = FactoryGirl.create(:profile, first_name: "Max")
user3 = FactoryGirl.create(:user_with_profile)
login(:admin)
visit users_path

expect(page).to have_text(max1.profile.last_name)
expect(page).to have_text(max2.profile.last_name)
expect(page).to have_text(user3.profile.last_name)

fill_in :search, with: "Max"
click_button I18n.t('users.index.search')

expect(page).to have_text(max1.profile.last_name)
expect(page).to have_text(max2.profile.last_name)
expect(page).to_not have_text(user3.profile.last_name)
end

def login(role)
@profile = FactoryGirl.create(:profile)
@profile.user.role = role
Expand Down

0 comments on commit 8bd3a98

Please sign in to comment.