Merge pull request #4849 from consul/more_browser_tests_database
Reduce conflicting queries/requests in system tests
This commit is contained in:
@@ -175,12 +175,14 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name,
|
||||
|
||||
describe "At #{mappable_edit_path}", if: mappable_edit_path.present? do
|
||||
scenario "Should edit map on #{mappable_factory_name} and contain default values" do
|
||||
mappable.map_location.update!(latitude: 51.48, longitude: 0.0)
|
||||
do_login_for mappable.author, management: management
|
||||
|
||||
visit send(mappable_edit_path, id: mappable.id)
|
||||
|
||||
expect(page).to have_content "Navigate the map to the location and place the marker."
|
||||
validate_latitude_longitude(mappable, mappable_factory_name)
|
||||
expect(page).to have_field "#{mappable_factory_name}_map_location_attributes_latitude", type: :hidden, with: "51.48"
|
||||
expect(page).to have_field "#{mappable_factory_name}_map_location_attributes_longitude", type: :hidden, with: "0.0"
|
||||
end
|
||||
|
||||
scenario "Should edit default values from map on #{mappable_factory_name} edit page" do
|
||||
|
||||
@@ -210,6 +210,8 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na
|
||||
documentable_attach_new_file(file_fixture("empty.pdf"))
|
||||
click_on submit_button
|
||||
|
||||
expect(page).to have_content documentable_success_notice
|
||||
|
||||
documentable_redirected_to_resource_show_or_navigate_to
|
||||
|
||||
expect(page).to have_content "Documents"
|
||||
@@ -232,6 +234,9 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na
|
||||
end
|
||||
|
||||
click_on submit_button
|
||||
|
||||
expect(page).to have_content documentable_success_notice
|
||||
|
||||
documentable_redirected_to_resource_show_or_navigate_to
|
||||
|
||||
expect(page).to have_content "Documents (#{documentable.class.max_documents_allowed})"
|
||||
|
||||
@@ -184,6 +184,9 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p
|
||||
expect(page).to have_selector ".loading-bar.complete"
|
||||
|
||||
click_on submit_button
|
||||
|
||||
expect(page).to have_content imageable_success_notice
|
||||
|
||||
imageable_redirected_to_resource_show_or_navigate_to(imageable)
|
||||
|
||||
expect(page).to have_selector "figure img"
|
||||
|
||||
@@ -13,15 +13,6 @@ module Maps
|
||||
end
|
||||
end
|
||||
|
||||
def validate_latitude_longitude(mappable, mappable_factory_name)
|
||||
latitude_attribute = "##{mappable_factory_name}_map_location_attributes_latitude"
|
||||
longitude_attribute = "##{mappable_factory_name}_map_location_attributes_longitude"
|
||||
expect(find(latitude_attribute, visible: false).value).to eq "51.48"
|
||||
expect(find(longitude_attribute, visible: false).value).to eq "0.0"
|
||||
expect(mappable.map_location.latitude).to eq 51.48
|
||||
expect(mappable.map_location.longitude).to eq 0.0
|
||||
end
|
||||
|
||||
def fill_in_budget_investment_form
|
||||
fill_in_new_investment_title with: "Budget investment title"
|
||||
fill_in_ckeditor "Description", with: "Budget investment description"
|
||||
|
||||
@@ -13,7 +13,7 @@ describe "Admin booths", :admin do
|
||||
end
|
||||
|
||||
scenario "Index" do
|
||||
3.times { create(:poll_booth) }
|
||||
booths = 3.times.map { create(:poll_booth) }
|
||||
|
||||
visit admin_root_path
|
||||
|
||||
@@ -22,7 +22,6 @@ describe "Admin booths", :admin do
|
||||
click_link "Booths location"
|
||||
end
|
||||
|
||||
booths = Poll::Booth.all
|
||||
booths.each do |booth|
|
||||
within("#booth_#{booth.id}") do
|
||||
expect(page).to have_content booth.name
|
||||
|
||||
@@ -21,13 +21,6 @@ describe "Admin polls", :admin do
|
||||
expect(page).to have_content "List of polls"
|
||||
expect(page).to have_css ".poll", count: 3
|
||||
|
||||
polls = Poll.all
|
||||
polls.each do |poll|
|
||||
within("#poll_#{poll.id}") do
|
||||
expect(page).to have_content poll.name
|
||||
end
|
||||
end
|
||||
|
||||
expect(poll_3.name).to appear_before(poll_1.name)
|
||||
expect(poll_1.name).to appear_before(poll_2.name)
|
||||
expect(page).not_to have_content "There are no polls"
|
||||
@@ -219,6 +212,7 @@ describe "Admin polls", :admin do
|
||||
booth.booth_assignments.each do |booth_assignment|
|
||||
3.times { create(:poll_officer_assignment, booth_assignment: booth_assignment) }
|
||||
end
|
||||
officers = Poll::Officer.all
|
||||
|
||||
visit admin_poll_path(poll)
|
||||
|
||||
@@ -226,7 +220,6 @@ describe "Admin polls", :admin do
|
||||
|
||||
expect(page).to have_css ".officer", count: 3
|
||||
|
||||
officers = Poll::Officer.all
|
||||
officers.each do |officer|
|
||||
within("#officer_#{officer.id}") do
|
||||
expect(page).to have_content officer.name
|
||||
|
||||
@@ -38,7 +38,9 @@ describe "Moderate users" do
|
||||
|
||||
expect(page).not_to have_content(comment3.body)
|
||||
|
||||
click_link("Sign out")
|
||||
click_link "Sign out"
|
||||
|
||||
expect(page).to have_content "You have been signed out successfully"
|
||||
|
||||
visit root_path
|
||||
|
||||
|
||||
Reference in New Issue
Block a user