Use consistent coordinates in tests
When we create a budget heading through factories it's placed at Puerta del Sol, Madrid. It seems reasonable that the `map_location` factory places the points near there. Before these changes sometimes the map center was placed in Madrid while map locations were placed in Greenwich, therefore markers were not visible in the map current pane.
This commit is contained in:
committed by
Javi Martín
parent
47bd201ada
commit
326a8a769b
@@ -74,9 +74,9 @@ FactoryBot.define do
|
||||
end
|
||||
|
||||
factory :map_location do
|
||||
latitude { 51.48 }
|
||||
longitude { 0.0 }
|
||||
zoom { 10 }
|
||||
latitude { Setting["map.latitude"] }
|
||||
longitude { Setting["map.longitude"] }
|
||||
zoom { Setting["map.zoom"] }
|
||||
|
||||
trait :proposal_map_location do
|
||||
proposal
|
||||
|
||||
@@ -91,8 +91,8 @@ FactoryBot.define do
|
||||
sequence(:name) { |n| "Heading #{n}" }
|
||||
price { 1000000 }
|
||||
population { 1234 }
|
||||
latitude { "40.416775" }
|
||||
longitude { "-3.703790" }
|
||||
latitude { Setting["map.latitude"] }
|
||||
longitude { Setting["map.longitude"] }
|
||||
|
||||
transient { budget { nil } }
|
||||
group { association :budget_group, budget: budget || association(:budget) }
|
||||
@@ -198,7 +198,11 @@ FactoryBot.define do
|
||||
end
|
||||
|
||||
trait :with_map_location do
|
||||
map_location
|
||||
map_location do
|
||||
association :map_location,
|
||||
longitude: heading.longitude.to_f + rand(-0.0001..0.0001),
|
||||
latitude: heading.latitude.to_f + rand(-0.0001..0.0001)
|
||||
end
|
||||
end
|
||||
|
||||
trait :flagged do
|
||||
|
||||
@@ -260,13 +260,7 @@ describe "Budgets" do
|
||||
end
|
||||
|
||||
scenario "Display investment's map location markers" do
|
||||
investment1 = create(:budget_investment, heading: heading)
|
||||
investment2 = create(:budget_investment, heading: heading)
|
||||
investment3 = create(:budget_investment, heading: heading)
|
||||
|
||||
create(:map_location, longitude: 40.1234, latitude: -3.634, investment: investment1)
|
||||
create(:map_location, longitude: 40.1235, latitude: -3.635, investment: investment2)
|
||||
create(:map_location, longitude: 40.1236, latitude: -3.636, investment: investment3)
|
||||
create_list(:budget_investment, 3, :with_map_location, heading: heading)
|
||||
|
||||
visit budgets_path
|
||||
|
||||
@@ -277,16 +271,7 @@ describe "Budgets" do
|
||||
|
||||
scenario "Display all investment's map location if there are no selected" do
|
||||
budget.update!(phase: :publishing_prices)
|
||||
|
||||
investment1 = create(:budget_investment, heading: heading)
|
||||
investment2 = create(:budget_investment, heading: heading)
|
||||
investment3 = create(:budget_investment, heading: heading)
|
||||
investment4 = create(:budget_investment, heading: heading)
|
||||
|
||||
investment1.create_map_location(longitude: 40.1234, latitude: 3.1234, zoom: 10)
|
||||
investment2.create_map_location(longitude: 40.1235, latitude: 3.1235, zoom: 10)
|
||||
investment3.create_map_location(longitude: 40.1236, latitude: 3.1236, zoom: 10)
|
||||
investment4.create_map_location(longitude: 40.1240, latitude: 3.1240, zoom: 10)
|
||||
create_list(:budget_investment, 4, :with_map_location, heading: heading)
|
||||
|
||||
visit budgets_path
|
||||
|
||||
@@ -297,16 +282,8 @@ describe "Budgets" do
|
||||
|
||||
scenario "Display only selected investment's map location from publishing prices phase" do
|
||||
budget.update!(phase: :publishing_prices)
|
||||
|
||||
investment1 = create(:budget_investment, :selected, heading: heading)
|
||||
investment2 = create(:budget_investment, :selected, heading: heading)
|
||||
investment3 = create(:budget_investment, heading: heading)
|
||||
investment4 = create(:budget_investment, heading: heading)
|
||||
|
||||
investment1.create_map_location(longitude: 40.1234, latitude: 3.1234, zoom: 10)
|
||||
investment2.create_map_location(longitude: 40.1235, latitude: 3.1235, zoom: 10)
|
||||
investment3.create_map_location(longitude: 40.1236, latitude: 3.1236, zoom: 10)
|
||||
investment4.create_map_location(longitude: 40.1240, latitude: 3.1240, zoom: 10)
|
||||
create_list(:budget_investment, 2, :selected, :with_map_location, heading: heading)
|
||||
create_list(:budget_investment, 2, :with_map_location, heading: heading)
|
||||
|
||||
visit budgets_path
|
||||
|
||||
@@ -320,9 +297,9 @@ describe "Budgets" do
|
||||
|
||||
investment = create(:budget_investment, heading: heading)
|
||||
|
||||
map_locations << { longitude: 40.123456789, latitude: 3.12345678 }
|
||||
map_locations << { longitude: 40.123456789, latitude: "********" }
|
||||
map_locations << { longitude: "**********", latitude: 3.12345678 }
|
||||
map_locations << { longitude: -3.703790, latitude: 40.416775 }
|
||||
map_locations << { longitude: -3.703791, latitude: "********" }
|
||||
map_locations << { longitude: "**********", latitude: 40.416776 }
|
||||
|
||||
coordinates = map_locations.map do |map_location|
|
||||
{
|
||||
|
||||
@@ -1643,20 +1643,7 @@ describe "Budget Investments" do
|
||||
|
||||
context "sidebar map" do
|
||||
scenario "Display 6 investment's markers on sidebar map" do
|
||||
investment1 = create(:budget_investment, heading: heading)
|
||||
investment2 = create(:budget_investment, heading: heading)
|
||||
investment3 = create(:budget_investment, heading: heading)
|
||||
investment4 = create(:budget_investment, heading: heading)
|
||||
investment5 = create(:budget_investment, heading: heading)
|
||||
investment6 = create(:budget_investment, heading: heading)
|
||||
|
||||
create(:map_location, longitude: 40.1231, latitude: -3.636, investment: investment1)
|
||||
create(:map_location, longitude: 40.1232, latitude: -3.635, investment: investment2)
|
||||
create(:map_location, longitude: 40.1233, latitude: -3.634, investment: investment3)
|
||||
create(:map_location, longitude: 40.1234, latitude: -3.633, investment: investment4)
|
||||
create(:map_location, longitude: 40.1235, latitude: -3.632, investment: investment5)
|
||||
create(:map_location, longitude: 40.1236, latitude: -3.631, investment: investment6)
|
||||
|
||||
create_list(:budget_investment, 6, :with_map_location, heading: heading)
|
||||
visit budget_investments_path(budget, heading_id: heading.id)
|
||||
|
||||
within ".map-location" do
|
||||
@@ -1666,20 +1653,8 @@ describe "Budget Investments" do
|
||||
|
||||
scenario "Display only investment's related to the current heading" do
|
||||
heading_2 = create(:budget_heading, name: "Madrid", group: group)
|
||||
|
||||
investment1 = create(:budget_investment, heading: heading)
|
||||
investment2 = create(:budget_investment, heading: heading)
|
||||
investment3 = create(:budget_investment, heading: heading)
|
||||
investment4 = create(:budget_investment, heading: heading)
|
||||
investment5 = create(:budget_investment, heading: heading_2)
|
||||
investment6 = create(:budget_investment, heading: heading_2)
|
||||
|
||||
create(:map_location, longitude: 40.1231, latitude: -3.636, investment: investment1)
|
||||
create(:map_location, longitude: 40.1232, latitude: -3.685, investment: investment2)
|
||||
create(:map_location, longitude: 40.1233, latitude: -3.664, investment: investment3)
|
||||
create(:map_location, longitude: 40.1234, latitude: -3.673, investment: investment4)
|
||||
create(:map_location, longitude: 40.1235, latitude: -3.672, investment: investment5)
|
||||
create(:map_location, longitude: 40.1236, latitude: -3.621, investment: investment6)
|
||||
create_list(:budget_investment, 4, :with_map_location, heading: heading)
|
||||
create_list(:budget_investment, 2, :with_map_location, heading: heading_2)
|
||||
|
||||
visit budget_investments_path(budget, heading_id: heading.id)
|
||||
|
||||
@@ -1690,14 +1665,7 @@ describe "Budget Investments" do
|
||||
|
||||
scenario "Do not display investment's, since they're all related to other heading" do
|
||||
heading_2 = create(:budget_heading, name: "Madrid", group: group)
|
||||
|
||||
investment1 = create(:budget_investment, heading: heading_2)
|
||||
investment2 = create(:budget_investment, heading: heading_2)
|
||||
investment3 = create(:budget_investment, heading: heading_2)
|
||||
|
||||
create(:map_location, longitude: 40.1255, latitude: -3.644, investment: investment1)
|
||||
create(:map_location, longitude: 40.1258, latitude: -3.637, investment: investment2)
|
||||
create(:map_location, longitude: 40.1251, latitude: -3.649, investment: investment3)
|
||||
create_list(:budget_investment, 3, :with_map_location, heading: heading_2)
|
||||
|
||||
visit budget_investments_path(budget, heading_id: heading.id)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user