Check table rows content instead of database
Checking the database with methods like Activity.last does not test that the record is present where it should be (first record of the table in this case). In these tests there's only one record, though, so the order doesn't matter that match. However, calling methods like Activity.last generates a database query after the process running the browser has been started, and this might lead to inconsistent data.
This commit is contained in:
@@ -20,7 +20,7 @@ describe "Admin activity" do
|
|||||||
|
|
||||||
visit admin_activity_path
|
visit admin_activity_path
|
||||||
|
|
||||||
within("#activity_#{Activity.last.id}") do
|
within first("tbody tr") do
|
||||||
expect(page).to have_content(proposal.title)
|
expect(page).to have_content(proposal.title)
|
||||||
expect(page).to have_content("Hidden")
|
expect(page).to have_content("Hidden")
|
||||||
expect(page).to have_content(admin.user.username)
|
expect(page).to have_content(admin.user.username)
|
||||||
@@ -66,7 +66,7 @@ describe "Admin activity" do
|
|||||||
|
|
||||||
visit admin_activity_path
|
visit admin_activity_path
|
||||||
|
|
||||||
within("#activity_#{Activity.last.id}") do
|
within first("tbody tr") do
|
||||||
expect(page).to have_content(proposal.title)
|
expect(page).to have_content(proposal.title)
|
||||||
expect(page).to have_content("Restored")
|
expect(page).to have_content("Restored")
|
||||||
expect(page).to have_content(admin.user.username)
|
expect(page).to have_content(admin.user.username)
|
||||||
@@ -87,7 +87,7 @@ describe "Admin activity" do
|
|||||||
|
|
||||||
visit admin_activity_path
|
visit admin_activity_path
|
||||||
|
|
||||||
within("#activity_#{Activity.last.id}") do
|
within first("tbody tr") do
|
||||||
expect(page).to have_content(debate.title)
|
expect(page).to have_content(debate.title)
|
||||||
expect(page).to have_content("Hidden")
|
expect(page).to have_content("Hidden")
|
||||||
expect(page).to have_content(admin.user.username)
|
expect(page).to have_content(admin.user.username)
|
||||||
@@ -133,7 +133,7 @@ describe "Admin activity" do
|
|||||||
|
|
||||||
visit admin_activity_path
|
visit admin_activity_path
|
||||||
|
|
||||||
within("#activity_#{Activity.last.id}") do
|
within first("tbody tr") do
|
||||||
expect(page).to have_content(debate.title)
|
expect(page).to have_content(debate.title)
|
||||||
expect(page).to have_content("Restored")
|
expect(page).to have_content("Restored")
|
||||||
expect(page).to have_content(admin.user.username)
|
expect(page).to have_content(admin.user.username)
|
||||||
@@ -155,7 +155,7 @@ describe "Admin activity" do
|
|||||||
|
|
||||||
visit admin_activity_path
|
visit admin_activity_path
|
||||||
|
|
||||||
within("#activity_#{Activity.last.id}") do
|
within first("tbody tr") do
|
||||||
expect(page).to have_content(comment.body)
|
expect(page).to have_content(comment.body)
|
||||||
expect(page).to have_content("Hidden")
|
expect(page).to have_content("Hidden")
|
||||||
expect(page).to have_content(admin.user.username)
|
expect(page).to have_content(admin.user.username)
|
||||||
@@ -201,7 +201,7 @@ describe "Admin activity" do
|
|||||||
|
|
||||||
visit admin_activity_path
|
visit admin_activity_path
|
||||||
|
|
||||||
within("#activity_#{Activity.last.id}") do
|
within first("tbody tr") do
|
||||||
expect(page).to have_content(comment.body)
|
expect(page).to have_content(comment.body)
|
||||||
expect(page).to have_content("Restored")
|
expect(page).to have_content("Restored")
|
||||||
expect(page).to have_content(admin.user.username)
|
expect(page).to have_content(admin.user.username)
|
||||||
@@ -223,7 +223,7 @@ describe "Admin activity" do
|
|||||||
|
|
||||||
visit admin_activity_path
|
visit admin_activity_path
|
||||||
|
|
||||||
within("#activity_#{Activity.last.id}") do
|
within first("tbody tr") do
|
||||||
expect(page).to have_content("Blocked")
|
expect(page).to have_content("Blocked")
|
||||||
expect(page).to have_content(proposal.author.username)
|
expect(page).to have_content(proposal.author.username)
|
||||||
expect(page).to have_content(proposal.author.email)
|
expect(page).to have_content(proposal.author.email)
|
||||||
@@ -243,7 +243,7 @@ describe "Admin activity" do
|
|||||||
|
|
||||||
visit admin_activity_path
|
visit admin_activity_path
|
||||||
|
|
||||||
within("#activity_#{Activity.last.id}") do
|
within first("tbody tr") do
|
||||||
expect(page).to have_content(user.username)
|
expect(page).to have_content(user.username)
|
||||||
expect(page).to have_content(user.email)
|
expect(page).to have_content(user.email)
|
||||||
expect(page).to have_content(admin.user.username)
|
expect(page).to have_content(admin.user.username)
|
||||||
@@ -347,7 +347,7 @@ describe "Admin activity" do
|
|||||||
|
|
||||||
visit admin_activity_path
|
visit admin_activity_path
|
||||||
|
|
||||||
within("#activity_#{Activity.last.id}") do
|
within first("tbody tr") do
|
||||||
expect(page).to have_content(user.username)
|
expect(page).to have_content(user.username)
|
||||||
expect(page).to have_content(user.email)
|
expect(page).to have_content(user.email)
|
||||||
expect(page).to have_content("Restored")
|
expect(page).to have_content("Restored")
|
||||||
@@ -366,7 +366,7 @@ describe "Admin activity" do
|
|||||||
|
|
||||||
visit admin_activity_path
|
visit admin_activity_path
|
||||||
|
|
||||||
within("#activity_#{Activity.last.id}") do
|
within first("tbody tr") do
|
||||||
expect(page).to have_content(proposal_notification.title)
|
expect(page).to have_content(proposal_notification.title)
|
||||||
expect(page).to have_content("Hidden")
|
expect(page).to have_content("Hidden")
|
||||||
expect(page).to have_content(admin.user.username)
|
expect(page).to have_content(admin.user.username)
|
||||||
|
|||||||
@@ -97,7 +97,14 @@ describe "Admin budget groups", :admin do
|
|||||||
click_button "Create new group"
|
click_button "Create new group"
|
||||||
|
|
||||||
expect(page).to have_content "Group created successfully!"
|
expect(page).to have_content "Group created successfully!"
|
||||||
expect(Budget::Group.first.max_votable_headings).to be 1
|
|
||||||
|
within all("thead th")[1] do
|
||||||
|
expect(page).to have_content("Maximum number of headings in which a user can select projects")
|
||||||
|
end
|
||||||
|
|
||||||
|
within "tbody tr" do
|
||||||
|
within all("td")[1] { expect(page.text).to eq "1" }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Group name is mandatory" do
|
scenario "Group name is mandatory" do
|
||||||
|
|||||||
@@ -94,9 +94,12 @@ describe "Admin::Organizations" do
|
|||||||
click_on "Verify"
|
click_on "Verify"
|
||||||
end
|
end
|
||||||
expect(page).to have_current_path(admin_organizations_path, ignore_query: true)
|
expect(page).to have_current_path(admin_organizations_path, ignore_query: true)
|
||||||
expect(page).to have_content "Verified"
|
|
||||||
|
|
||||||
expect(organization.reload.verified?).to eq(true)
|
click_link "Verified"
|
||||||
|
|
||||||
|
within "tr", text: organization.name do
|
||||||
|
expect(page).to have_content "Verified"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Verified organizations have link to reject" do
|
scenario "Verified organizations have link to reject" do
|
||||||
@@ -117,10 +120,10 @@ describe "Admin::Organizations" do
|
|||||||
expect(page).not_to have_content organization.name
|
expect(page).not_to have_content organization.name
|
||||||
|
|
||||||
click_on "Rejected"
|
click_on "Rejected"
|
||||||
expect(page).to have_content "Rejected"
|
|
||||||
expect(page).to have_content organization.name
|
|
||||||
|
|
||||||
expect(organization.reload.rejected?).to eq(true)
|
within "tr", text: organization.name do
|
||||||
|
expect(page).to have_content "Rejected"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Rejected organizations have link to verify" do
|
scenario "Rejected organizations have link to verify" do
|
||||||
@@ -139,9 +142,9 @@ describe "Admin::Organizations" do
|
|||||||
expect(page).not_to have_content organization.name
|
expect(page).not_to have_content organization.name
|
||||||
click_on("Verified")
|
click_on("Verified")
|
||||||
|
|
||||||
expect(page).to have_content organization.name
|
within "tr", text: organization.name do
|
||||||
|
expect(page).to have_content "Verified"
|
||||||
expect(organization.reload.verified?).to eq(true)
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Current filter is properly highlighted" do
|
scenario "Current filter is properly highlighted" do
|
||||||
|
|||||||
@@ -303,9 +303,16 @@ describe "System Emails" do
|
|||||||
|
|
||||||
visit admin_system_email_preview_pending_path("proposal_notification_digest")
|
visit admin_system_email_preview_pending_path("proposal_notification_digest")
|
||||||
|
|
||||||
expect(Notification.count).to equal(1)
|
expect(page).to have_content("Proposal B")
|
||||||
expect(Activity.last.actionable_type).to eq("ProposalNotification")
|
|
||||||
expect(page).not_to have_content("Proposal A Title")
|
expect(page).not_to have_content("Proposal A Title")
|
||||||
|
|
||||||
|
visit admin_activity_path
|
||||||
|
|
||||||
|
within first("tbody tr") do
|
||||||
|
expect(page).to have_content "Proposal notification"
|
||||||
|
expect(page).to have_content "Proposal A Title"
|
||||||
|
expect(page).to have_content admin.user.username
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "#send_pending" do
|
scenario "#send_pending" do
|
||||||
|
|||||||
@@ -18,14 +18,15 @@ describe "Cards", :admin do
|
|||||||
expect(page).to have_content "Card created successfully!"
|
expect(page).to have_content "Card created successfully!"
|
||||||
expect(page).to have_css(".homepage-card", count: 1)
|
expect(page).to have_css(".homepage-card", count: 1)
|
||||||
|
|
||||||
card = Widget::Card.last
|
within "#cards" do
|
||||||
within("#widget_card_#{card.id}") do
|
within all("tbody tr").last do
|
||||||
expect(page).to have_content "Card label"
|
expect(page).to have_content "Card label"
|
||||||
expect(page).to have_content "Card text"
|
expect(page).to have_content "Card text"
|
||||||
expect(page).to have_content "Card description"
|
expect(page).to have_content "Card description"
|
||||||
expect(page).to have_content "Link text"
|
expect(page).to have_content "Link text"
|
||||||
expect(page).to have_content "consul.dev"
|
expect(page).to have_content "consul.dev"
|
||||||
expect(page).to have_link("Show image", href: card.image_url(:large))
|
expect(page).to have_link "Show image", href: Widget::Card.last.image_url(:large)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -91,7 +92,9 @@ describe "Cards", :admin do
|
|||||||
expect(page).to have_content "Card updated successfully"
|
expect(page).to have_content "Card updated successfully"
|
||||||
|
|
||||||
expect(page).to have_css(".homepage-card", count: 1)
|
expect(page).to have_css(".homepage-card", count: 1)
|
||||||
within("#widget_card_#{Widget::Card.last.id}") do
|
|
||||||
|
within "#cards" do
|
||||||
|
within all("tbody tr").last do
|
||||||
expect(page).to have_content "Card label updated"
|
expect(page).to have_content "Card label updated"
|
||||||
expect(page).to have_content "Card text updated"
|
expect(page).to have_content "Card text updated"
|
||||||
expect(page).to have_content "Card description updated"
|
expect(page).to have_content "Card description updated"
|
||||||
@@ -99,6 +102,7 @@ describe "Cards", :admin do
|
|||||||
expect(page).to have_content "consul.dev updated"
|
expect(page).to have_content "consul.dev updated"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
scenario "Remove" do
|
scenario "Remove" do
|
||||||
card = create(:widget_card)
|
card = create(:widget_card)
|
||||||
|
|||||||
@@ -107,11 +107,13 @@ describe "Poll budget ballot sheets" do
|
|||||||
fill_in "data", with: "1234;5678"
|
fill_in "data", with: "1234;5678"
|
||||||
click_button "Save"
|
click_button "Save"
|
||||||
|
|
||||||
expect(Poll::BallotSheet.count).to be 1
|
expect(page).to have_content(/Ballot sheet \d+/)
|
||||||
|
|
||||||
expect(page).to have_content("Ballot sheet #{Poll::BallotSheet.last.id}")
|
|
||||||
expect(page).to have_content(poll_officer.user.name)
|
expect(page).to have_content(poll_officer.user.name)
|
||||||
expect(page).to have_content("1234;5678")
|
expect(page).to have_content("1234;5678")
|
||||||
|
|
||||||
|
visit officing_poll_ballot_sheets_path(poll)
|
||||||
|
|
||||||
|
expect(page).to have_css "tbody tr", count: 1
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Ballot sheet is not saved" do
|
scenario "Ballot sheet is not saved" do
|
||||||
@@ -120,9 +122,11 @@ describe "Poll budget ballot sheets" do
|
|||||||
select "#{booth.name}", from: "officer_assignment_id"
|
select "#{booth.name}", from: "officer_assignment_id"
|
||||||
click_button "Save"
|
click_button "Save"
|
||||||
|
|
||||||
expect(Poll::BallotSheet.count).to be 0
|
|
||||||
|
|
||||||
expect(page).to have_content("CSV data can't be blank")
|
expect(page).to have_content("CSV data can't be blank")
|
||||||
|
|
||||||
|
visit officing_poll_ballot_sheets_path(poll)
|
||||||
|
|
||||||
|
expect(page).not_to have_css "tbody tr"
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Shift booth has to be selected" do
|
scenario "Shift booth has to be selected" do
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ describe "BudgetPolls", :with_frozen_time do
|
|||||||
expect(page).to have_content "1"
|
expect(page).to have_content "1"
|
||||||
end
|
end
|
||||||
|
|
||||||
within("#poll_booth_assignment_#{Poll::BoothAssignment.find_by(poll: poll, booth: booth).id}_recounts") do
|
within "tr", text: booth.name do
|
||||||
expect(page).to have_content "1"
|
expect(page).to have_content "1"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ describe "Officing Results", :with_frozen_time do
|
|||||||
|
|
||||||
expect(page).to have_content("Your results")
|
expect(page).to have_content("Your results")
|
||||||
|
|
||||||
within("#results_#{poll_officer.officer_assignments.first.booth_assignment_id}_#{Date.current.strftime("%Y%m%d")}") do
|
within "tbody tr" do
|
||||||
expect(page).to have_content(I18n.l(Date.current, format: :long))
|
expect(page).to have_content(I18n.l(Date.current, format: :long))
|
||||||
expect(page).to have_content(booth.name)
|
expect(page).to have_content(booth.name)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ describe "Voter" do
|
|||||||
expect(page).to have_content "1"
|
expect(page).to have_content "1"
|
||||||
end
|
end
|
||||||
|
|
||||||
within("#poll_booth_assignment_#{Poll::BoothAssignment.find_by(poll: poll, booth: booth).id}_recounts") do
|
within "tr", text: booth.name do
|
||||||
expect(page).to have_content "1"
|
expect(page).to have_content "1"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -159,7 +159,7 @@ describe "Voter" do
|
|||||||
expect(page).to have_content "1"
|
expect(page).to have_content "1"
|
||||||
end
|
end
|
||||||
|
|
||||||
within("#poll_booth_assignment_#{Poll::BoothAssignment.find_by(poll: poll, booth: booth).id}_recounts") do
|
within "tr", text: booth.name do
|
||||||
expect(page).to have_content "1"
|
expect(page).to have_content "1"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -224,7 +224,7 @@ describe "Voter" do
|
|||||||
expect(page).to have_content "1"
|
expect(page).to have_content "1"
|
||||||
end
|
end
|
||||||
|
|
||||||
within("#poll_booth_assignment_#{Poll::BoothAssignment.find_by(poll: poll, booth: booth).id}_recounts") do
|
within "tr", text: booth.name do
|
||||||
expect(page).to have_content "1"
|
expect(page).to have_content "1"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user