From dd4a2d57cf0e5307469d11435517a89138ddb6b0 Mon Sep 17 00:00:00 2001 From: kikito Date: Fri, 4 Sep 2015 15:32:15 +0200 Subject: [PATCH] makes admin/organization specs more robust --- app/views/admin/organizations/index.html.erb | 2 +- spec/features/admin/organizations_spec.rb | 30 ++++++++++++-------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/app/views/admin/organizations/index.html.erb b/app/views/admin/organizations/index.html.erb index 464168746..7be6e7519 100644 --- a/app/views/admin/organizations/index.html.erb +++ b/app/views/admin/organizations/index.html.erb @@ -19,7 +19,7 @@ <% @organizations.each do |organization| %> - + diff --git a/spec/features/admin/organizations_spec.rb b/spec/features/admin/organizations_spec.rb index f43c5d4dc..576d26db3 100644 --- a/spec/features/admin/organizations_spec.rb +++ b/spec/features/admin/organizations_spec.rb @@ -13,7 +13,7 @@ feature 'Admin::Organizations' do background do @user = create(:user, email: "marley@humanrights.com", phone_number: "6764440002") - organization = create(:organization, user: @user, name: "Get up, Stand up") + create(:organization, user: @user, name: "Get up, Stand up") end scenario "returns no results if search term is empty" do @@ -70,11 +70,13 @@ feature 'Admin::Organizations' do organization = create(:organization) visit admin_organizations_path - expect(current_path).to eq(admin_organizations_path) - expect(page).to have_link('Verify') - expect(page).to have_link('Reject') + within("organization_#{organization.id}") do + expect(current_path).to eq(admin_organizations_path) + expect(page).to have_link('Verify') + expect(page).to have_link('Reject') - click_on 'Verify' + click_on 'Verify' + end expect(current_path).to eq(admin_organizations_path) expect(page).to have_content ('Verified') @@ -86,11 +88,13 @@ feature 'Admin::Organizations' do visit admin_organizations_path expect(current_path).to eq(admin_organizations_path) - expect(page).to have_content ('Verified') - expect(page).to_not have_link('Verify') - expect(page).to have_link('Reject') + within("organization_#{organization.id}") do + expect(page).to have_content ('Verified') + expect(page).to_not have_link('Verify') + expect(page).to have_link('Reject') - click_on 'Reject' + click_on 'Reject' + end expect(current_path).to eq(admin_organizations_path) expect(page).to have_content ('Rejected') @@ -102,10 +106,12 @@ feature 'Admin::Organizations' do visit admin_organizations_path expect(current_path).to eq(admin_organizations_path) - expect(page).to have_link('Verify') - expect(page).to_not have_link('Reject', exact: true) + within("organization_#{organization.id}") do + expect(page).to have_link('Verify') + expect(page).to_not have_link('Reject', exact: true) - click_on 'Verify' + click_on 'Verify' + end expect(current_path).to eq(admin_organizations_path) expect(page).to have_content ('Verified')
<%= organization.name %> <%= organization.email %> <%= organization.phone_number %>