Merge pull request #2213 from consul/map-edit

Fix map location update
This commit is contained in:
BertoCQ
2017-12-20 14:13:33 +01:00
committed by GitHub
2 changed files with 15 additions and 3 deletions

View File

@@ -1,7 +1,7 @@
class MapLocation < ActiveRecord::Base class MapLocation < ActiveRecord::Base
belongs_to :proposal belongs_to :proposal, touch: true
belongs_to :investment, class_name: Budget::Investment belongs_to :investment, class_name: Budget::Investment, touch: true
def available? def available?
latitude.present? && longitude.present? && zoom.present? latitude.present? && longitude.present? && zoom.present?

View File

@@ -2,7 +2,7 @@ shared_examples "map validations" do
let(:mappable) { build(model_name(described_class)) } let(:mappable) { build(model_name(described_class)) }
describe "map" do describe "validations" do
before(:each) do before(:each) do
Setting["feature.map"] = true Setting["feature.map"] = true
@@ -49,5 +49,17 @@ shared_examples "map validations" do
end end
end end
describe "cache" do
it "should expire cache when the map is updated" do
map_location = create(:map_location)
mappable.map_location = map_location
mappable.save
expect { map_location.update(latitude: 12.34) }
.to change { mappable.reload.updated_at }
end
end
end end