diff options
| author | Alban Peignier | 2012-05-29 08:57:01 +0200 |
|---|---|---|
| committer | Alban Peignier | 2012-05-29 08:57:01 +0200 |
| commit | 244de985c6c00b6385e9af47f9dec08de1eec6c5 (patch) | |
| tree | ba555108ea422d3e981b9b1a98c215d38a8cc831 | |
| parent | ae65f9661b288b367d5f1f3e5fd8797852127110 (diff) | |
| download | chouette-core-244de985c6c00b6385e9af47f9dec08de1eec6c5.tar.bz2 | |
Include html_safe an ready? in ApplicationMap#to_html
| -rw-r--r-- | app/maps/application_map.rb | 4 | ||||
| -rw-r--r-- | app/maps/line_map.rb | 4 | ||||
| -rw-r--r-- | app/maps/network_map.rb | 4 | ||||
| -rw-r--r-- | app/views/lines/show.html.erb | 2 | ||||
| -rw-r--r-- | app/views/networks/show.html.erb | 2 | ||||
| -rw-r--r-- | spec/views/lines/show.html.erb_spec.rb | 2 | ||||
| -rw-r--r-- | spec/views/networks/show.html.erb_spec.rb | 3 |
7 files changed, 16 insertions, 5 deletions
diff --git a/app/maps/application_map.rb b/app/maps/application_map.rb index a4d8a84ab..dffb2501c 100644 --- a/app/maps/application_map.rb +++ b/app/maps/application_map.rb @@ -34,7 +34,9 @@ class ApplicationMap end def to_html(options = {}) - "<div id=\"#{id}\" class=\"#{default_class}\"></div> #{map.to_html(options)}" + if not respond_to?(:ready?) or ready? + "<div id=\"#{id}\" class=\"#{default_class}\"></div> #{map.to_html(options)}".html_safe + end end def kml diff --git a/app/maps/line_map.rb b/app/maps/line_map.rb index 128b98dd2..a7a9f892d 100644 --- a/app/maps/line_map.rb +++ b/app/maps/line_map.rb @@ -29,4 +29,8 @@ class LineMap < ApplicationMap end + def ready? + Chouette::StopArea.bounds.present? + end + end diff --git a/app/maps/network_map.rb b/app/maps/network_map.rb index cedabdf6e..35283a48f 100644 --- a/app/maps/network_map.rb +++ b/app/maps/network_map.rb @@ -28,4 +28,8 @@ class NetworkMap < ApplicationMap end + def ready? + Chouette::StopArea.bounds.present? + end + end diff --git a/app/views/lines/show.html.erb b/app/views/lines/show.html.erb index 4e7217384..c487f8616 100644 --- a/app/views/lines/show.html.erb +++ b/app/views/lines/show.html.erb @@ -1,7 +1,7 @@ <%= title_tag t('lines.show.title', :line => @line.name ) %> <div class="line_show"> - <%= @map.to_html.html_safe %> + <%= @map.to_html %> <div class="summary"> <p> diff --git a/app/views/networks/show.html.erb b/app/views/networks/show.html.erb index b03347ccf..112fb5769 100644 --- a/app/views/networks/show.html.erb +++ b/app/views/networks/show.html.erb @@ -1,7 +1,7 @@ <%= title_tag t('networks.show.title', :network => @network.name )%> <div class="network_show"> - <%= @map.to_html.html_safe %> + <%= @map.to_html %> <div class="summary"> <p> <label><%= Chouette::Network.human_attribute_name("name") %>: </label> diff --git a/spec/views/lines/show.html.erb_spec.rb b/spec/views/lines/show.html.erb_spec.rb index 42261005a..f77722672 100644 --- a/spec/views/lines/show.html.erb_spec.rb +++ b/spec/views/lines/show.html.erb_spec.rb @@ -5,7 +5,7 @@ describe "/lines/show" do let!(:referential) { assign :referential, create(:referential) } let!(:line) { assign :line, create(:line) } let!(:routes) { assign :routes, Array.new(2) { create(:route, :line => line) }.paginate } - let!(:map) { assign(:map, mock(:to_html => '<div id="map"/>')) } + let!(:map) { assign(:map, mock(:to_html => '<div id="map"/>'.html_safe)) } it "should render h2 with the line name" do render diff --git a/spec/views/networks/show.html.erb_spec.rb b/spec/views/networks/show.html.erb_spec.rb index 9c05fe4aa..9c4f34f96 100644 --- a/spec/views/networks/show.html.erb_spec.rb +++ b/spec/views/networks/show.html.erb_spec.rb @@ -4,7 +4,7 @@ describe "/networks/show" do let!(:referential) { assign(:referential, create(:referential)) } let!(:network) { assign(:network, create(:network)) } - let!(:map) { assign(:map, mock(:to_html => '<div id="map"/>')) } + let!(:map) { assign(:map, mock(:to_html => '<div id="map"/>'.html_safe)) } it "should render h2 with the network name" do render @@ -13,6 +13,7 @@ describe "/networks/show" do it "should display a map with class 'network'" do render + puts rendered rendered.should have_selector("#map") end |
