@@ -104,7 +104,7 @@ class Location |
||
104 | 104 |
end |
105 | 105 |
|
106 | 106 |
class LocationDrop |
107 |
- KEYS = Location.members.map(&:to_s).concat(%w[latitude longitude]) |
|
107 |
+ KEYS = Location.members.map(&:to_s).concat(%w[latitude longitude latlng]) |
|
108 | 108 |
|
109 | 109 |
def before_method(key) |
110 | 110 |
if KEYS.include?(key) |
@@ -30,6 +30,10 @@ describe Location do |
||
30 | 30 |
expect(location['lat']).to eq 2.0 |
31 | 31 |
end |
32 | 32 |
|
33 |
+ it "has a convencience accessor for combined latitude and longitude" do |
|
34 |
+ expect(location.latlng).to eq "2.0,3.0" |
|
35 |
+ end |
|
36 |
+ |
|
33 | 37 |
it "does not allow hash-style assignment" do |
34 | 38 |
expect { |
35 | 39 |
location[:lat] = 2.0 |
@@ -60,6 +64,7 @@ describe Location do |
||
60 | 64 |
'{{location.latitude}}' => '2.0', |
61 | 65 |
'{{location.lng}}' => '3.0', |
62 | 66 |
'{{location.longitude}}' => '3.0', |
67 |
+ '{{location.latlng}}' => '2.0,3.0', |
|
63 | 68 |
}.each { |template, result| |
64 | 69 |
expect(Liquid::Template.parse(template).render('location' => location.to_liquid)).to eq(result), |
65 | 70 |
"expected #{template.inspect} to expand to #{result.inspect}" |