From a145fdb8a83ea87a0a4359245ea98a430e29bed3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Tue, 2 May 2023 15:47:14 +0200 Subject: [PATCH] Make map location HTML class names consistent We were using `map_location` in one place and `location-map-remove-marker` in another one. We usually use dashes in HTML class names, we don't say "location map" anywhere else. --- app/assets/stylesheets/map_location.scss | 2 +- .../shared/map_location_component.html.erb | 2 +- .../shared/map_location_component.rb | 2 +- spec/shared/system/mappable.rb | 52 +++++++++---------- spec/system/budgets/budgets_spec.rb | 8 +-- spec/system/budgets/investments_spec.rb | 14 ++--- 6 files changed, 40 insertions(+), 40 deletions(-) diff --git a/app/assets/stylesheets/map_location.scss b/app/assets/stylesheets/map_location.scss index 282744fe8..46e7a5ccd 100644 --- a/app/assets/stylesheets/map_location.scss +++ b/app/assets/stylesheets/map_location.scss @@ -1,4 +1,4 @@ -.location-map-remove-marker { +.map-location-remove-marker { border-bottom: 1px dotted #cf2a0e; color: $delete; display: inline-block; diff --git a/app/components/shared/map_location_component.html.erb b/app/components/shared/map_location_component.html.erb index 9283a2e3f..378bf1dda 100644 --- a/app/components/shared/map_location_component.html.erb +++ b/app/components/shared/map_location_component.html.erb @@ -1,4 +1,4 @@ -<%= tag.div(id: dom_id(map_location), class: "map_location map", data: data) %> +<%= tag.div(id: dom_id(map_location), class: "map-location map", data: data) %> <% if editable? %> <%= remove_marker %> diff --git a/app/components/shared/map_location_component.rb b/app/components/shared/map_location_component.rb index e21a7b371..1d9b2b47a 100644 --- a/app/components/shared/map_location_component.rb +++ b/app/components/shared/map_location_component.rb @@ -41,7 +41,7 @@ class Shared::MapLocationComponent < ApplicationComponent tag.div class: "margin-bottom" do link_to remove_marker_label, "#", id: remove_marker_link_id, - class: "location-map-remove-marker" + class: "map-location-remove-marker" end end diff --git a/spec/shared/system/mappable.rb b/spec/shared/system/mappable.rb index 0ce4f5cd5..4b49e7d07 100644 --- a/spec/shared/system/mappable.rb +++ b/spec/shared/system/mappable.rb @@ -18,7 +18,7 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name, send("fill_in_#{mappable_factory_name}_form") - within ".map_location" do + within ".map-location" do expect(page).not_to have_css(".map-icon") end end @@ -30,7 +30,7 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name, send("fill_in_#{mappable_factory_name}_form") find("#new_map_location").click - within ".map_location" do + within ".map-location" do expect(page).to have_css(".map-icon") end end @@ -43,7 +43,7 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name, find("#new_map_location").click send("submit_#{mappable_factory_name}_form") - within ".map_location" do + within ".map-location" do expect(page).to have_css(".map-icon") end end @@ -53,10 +53,10 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name, visit send(mappable_new_path, arguments) send("fill_in_#{mappable_factory_name}_form") - expect(page).to have_css ".map_location" + expect(page).to have_css ".map-location" send("submit_#{mappable_factory_name}_form") - expect(page).not_to have_css(".map_location") + expect(page).not_to have_css(".map-location") end scenario "Can not display map on #{mappable_factory_name} when feature.map is disabled" do @@ -65,10 +65,10 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name, visit send(mappable_new_path, arguments) send("fill_in_#{mappable_factory_name}_form") - expect(page).not_to have_css ".map_location" + expect(page).not_to have_css ".map-location" send("submit_#{mappable_factory_name}_form") - expect(page).not_to have_css(".map_location") + expect(page).not_to have_css(".map-location") end describe "When restoring the page from browser history" do @@ -90,7 +90,7 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name, go_back - within ".map_location" do + within ".map-location" do expect(page).to have_css(".leaflet-map-pane", count: 1) end end @@ -99,7 +99,7 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name, do_login_for user, management: management visit send(mappable_new_path, arguments) - within ".map_location" do + within ".map-location" do expect(page).not_to have_css(".map-icon") end expect(page.execute_script("return App.Map.maps[0].getZoom();")).to eq(10) @@ -107,7 +107,7 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name, map_zoom_in find("#new_map_location").click - within ".map_location" do + within ".map-location" do expect(page).to have_css(".map-icon") end @@ -123,7 +123,7 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name, go_back - within ".map_location" do + within ".map-location" do expect(page).to have_css(".map-icon") expect(page.execute_script("return App.Map.maps[0].getZoom();")).to eq(11) end @@ -133,14 +133,14 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name, do_login_for user, management: management visit send(mappable_new_path, arguments) - within ".map_location" do + within ".map-location" do expect(page).not_to have_css(".map-icon") end place_map_at(-68.592487, -62.391357) find("#new_map_location").click - within ".map_location" do + within ".map-location" do expect(page).to have_css(".map-icon") end @@ -156,7 +156,7 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name, go_back - within ".map_location" do + within ".map-location" do expect(page).to have_css(".map-icon") end end @@ -189,13 +189,13 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name, do_login_for mappable.author, management: management visit send(mappable_edit_path, id: mappable.id) - find(".map_location").click + find(".map-location").click click_on("Save changes") mappable.reload - expect(page).to have_css(".map_location") - expect(page).not_to have_selector(".map_location[data-marker-latitude='#{map_location.latitude}']") - expect(page).to have_selector(".map_location[data-marker-latitude='#{mappable.map_location.latitude}']") + expect(page).to have_css(".map-location") + expect(page).not_to have_selector(".map-location[data-marker-latitude='#{map_location.latitude}']") + expect(page).to have_selector(".map-location[data-marker-latitude='#{mappable.map_location.latitude}']") end scenario "Should edit mappable on #{mappable_factory_name} without change map" do @@ -206,9 +206,9 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name, click_on("Save changes") mappable.reload - expect(page).to have_css(".map_location") - expect(page).to have_selector(".map_location[data-marker-latitude='#{map_location.latitude}']") - expect(page).to have_selector(".map_location[data-marker-latitude='#{mappable.map_location.latitude}']") + expect(page).to have_css(".map-location") + expect(page).to have_selector(".map-location[data-marker-latitude='#{map_location.latitude}']") + expect(page).to have_selector(".map-location[data-marker-latitude='#{mappable.map_location.latitude}']") end scenario "Can not display map on #{mappable_factory_name} edit when remove map marker" do @@ -218,7 +218,7 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name, click_link "Remove map marker" click_on "Save changes" - expect(page).not_to have_css(".map_location") + expect(page).not_to have_css(".map-location") end scenario "Can not display map on #{mappable_factory_name} edit when feature.map is disabled" do @@ -229,7 +229,7 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name, fill_in "#{mappable_factory_name.camelize} title", with: "New title" click_on("Save changes") - expect(page).not_to have_css(".map_location") + expect(page).not_to have_css(".map-location") end scenario "No need to skip map on update" do @@ -254,7 +254,7 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name, do_login_for user, management: management if management visit send(mappable_show_path, arguments) - within ".map_location" do + within ".map-location" do expect(page).to have_css(".map-icon") end end @@ -267,7 +267,7 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name, do_login_for user, management: management if management visit send(mappable_show_path, arguments) - expect(page).not_to have_css(".map_location") + expect(page).not_to have_css(".map-location") end scenario "Should not display map on #{mappable_factory_name} show page when feature.map is disable" do @@ -277,7 +277,7 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name, do_login_for user, management: management if management visit send(mappable_show_path, arguments) - expect(page).not_to have_css(".map_location") + expect(page).not_to have_css(".map-location") end end end diff --git a/spec/system/budgets/budgets_spec.rb b/spec/system/budgets/budgets_spec.rb index b818e1ff6..155f86052 100644 --- a/spec/system/budgets/budgets_spec.rb +++ b/spec/system/budgets/budgets_spec.rb @@ -270,7 +270,7 @@ describe "Budgets" do visit budgets_path - within ".map_location" do + within ".map-location" do expect(page).to have_css(".map-icon", count: 3, visible: :all) end end @@ -290,7 +290,7 @@ describe "Budgets" do visit budgets_path - within ".map_location" do + within ".map-location" do expect(page).to have_css(".map-icon", count: 4, visible: :all) end end @@ -310,7 +310,7 @@ describe "Budgets" do visit budgets_path - within ".map_location" do + within ".map-location" do expect(page).to have_css(".map-icon", count: 2, visible: :all) end end @@ -338,7 +338,7 @@ describe "Budgets" do visit budgets_path - within ".map_location" do + within ".map-location" do expect(page).to have_css(".map-icon", count: 1, visible: :all) end end diff --git a/spec/system/budgets/investments_spec.rb b/spec/system/budgets/investments_spec.rb index 405f6e15b..ddb01b30d 100644 --- a/spec/system/budgets/investments_spec.rb +++ b/spec/system/budgets/investments_spec.rb @@ -122,7 +122,7 @@ describe "Budget Investments" do create(:budget_investment, heading: heading) visit budget_investments_path(budget, heading_id: heading.id) within("#sidebar") do - expect(page).to have_css(".map_location") + expect(page).to have_css(".map-location") end unlocated_heading = create(:budget_heading, name: "No Map", price: 500, group: group, @@ -130,7 +130,7 @@ describe "Budget Investments" do create(:budget_investment, heading: unlocated_heading) visit budget_investments_path(budget, heading_id: unlocated_heading.id) within("#sidebar") do - expect(page).not_to have_css(".map_location") + expect(page).not_to have_css(".map-location") end end @@ -1637,7 +1637,7 @@ describe "Budget Investments" do visit budget_investments_path(budget, heading_id: heading.id) - within ".map_location" do + within ".map-location" do expect(page).to have_css(".map-icon", count: 6, visible: :all) end end @@ -1651,7 +1651,7 @@ describe "Budget Investments" do visit budget_investments_path(budget, heading_id: heading.id) - within ".map_location" do + within ".map-location" do expect(page).to have_css(".map-icon", count: 2, visible: :all) end end @@ -1675,7 +1675,7 @@ describe "Budget Investments" do visit budget_investments_path(budget, heading_id: heading.id) - within ".map_location" do + within ".map-location" do expect(page).to have_css(".map-icon", count: 4, visible: :all) end end @@ -1693,7 +1693,7 @@ describe "Budget Investments" do visit budget_investments_path(budget, heading_id: heading.id) - within ".map_location" do + within ".map-location" do expect(page).to have_css(".map-icon", count: 0, visible: :all) end end @@ -1711,7 +1711,7 @@ describe "Budget Investments" do expect(page).to have_css(".budget-investment", count: 2) end - within(".map_location") do + within(".map-location") do expect(page).to have_css(".map-icon", count: 3, visible: :all) end end