Simplify checking map longitude and latitude
We were doing a `mappable.map_location` call in an `expect` which might result in a database queries. Doing database queries in a test after the process running the browser has started might result in exceptions while running our test suite.
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
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user