Tidy up some of the map bugs code
This commit is contained in:
parent
e7cd90f4b4
commit
fb4d003ebe
11 changed files with 149 additions and 154 deletions
|
@ -38,13 +38,15 @@
|
||||||
|
|
||||||
$("area_larger_map").href = '/?minlon='+minlon+'&minlat='+minlat+'&maxlon='+maxlon+'&maxlat='+maxlat+'&box=yes';
|
$("area_larger_map").href = '/?minlon='+minlon+'&minlat='+minlat+'&maxlon='+maxlon+'&maxlat='+maxlat+'&box=yes';
|
||||||
$("area_larger_map").innerHTML = "<%= t 'browse.map.larger.area' %>";
|
$("area_larger_map").innerHTML = "<%= t 'browse.map.larger.area' %>";
|
||||||
<% else if map.instance_of? MapBug %>
|
<% elsif map.instance_of? MapBug %>
|
||||||
$("loading").innerHTML = "";
|
var centre = new OpenLayers.LonLat(<%= map.lon %>, <%= map.lat %>);
|
||||||
var centre = new OpenLayers.LonLat(<%= map.lon %>, <%= map.lat %>);
|
|
||||||
var zoom = 16;
|
setMapCenter(centre, 16);
|
||||||
setMapCenter(centre, zoom);
|
addMarkerToMap(centre);
|
||||||
marker = addMarkerToMap(centre);
|
|
||||||
$("area_larger_map").href = '/?mlon=<%= map.lon %>&mlat=<%=map.lat %>';
|
$("loading").innerHTML = "";
|
||||||
|
|
||||||
|
$("area_larger_map").href = '/?mlon=<%= map.lon %>&mlat=<%=map.lat %>';
|
||||||
$("area_larger_map").innerHTML = "<%= t 'browse.map.larger.area' %>";
|
$("area_larger_map").innerHTML = "<%= t 'browse.map.larger.area' %>";
|
||||||
<% else %>
|
<% else %>
|
||||||
var obj_type = "<%= map.class.name.downcase %>";
|
var obj_type = "<%= map.class.name.downcase %>";
|
||||||
|
@ -77,7 +79,7 @@
|
||||||
$("small_map").style.display = "none";
|
$("small_map").style.display = "none";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
<% end end %>
|
<% end %>
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onload = init;
|
window.onload = init;
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
<div id="permalink">
|
<div id="permalink">
|
||||||
<a href="/" id="permalinkanchor"><%= t 'site.index.permalink' %></a><br/>
|
<a href="/" id="permalinkanchor"><%= t 'site.index.permalink' %></a><br/>
|
||||||
<a href="/" id="shortlinkanchor"><%= t 'site.index.shortlink' %></a><br/>
|
<a href="/" id="shortlinkanchor"><%= t 'site.index.shortlink' %></a><br/>
|
||||||
<a href="javascript:void();" id="ReportBug" class="reportProblem">Report a problem</a>
|
<a href="#" id="reportbuganchor">Report a problem</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="attribution">
|
<div id="attribution">
|
||||||
|
@ -142,34 +142,23 @@ end
|
||||||
map.addLayer(map.dataLayer);
|
map.addLayer(map.dataLayer);
|
||||||
|
|
||||||
map.osbLayer = new OpenLayers.Layer.OpenStreetBugs("OpenStreetBugs", {
|
map.osbLayer = new OpenLayers.Layer.OpenStreetBugs("OpenStreetBugs", {
|
||||||
serverURL : "/api/0.6/",
|
serverURL: "/api/0.6/",
|
||||||
iconOpen : new OpenLayers.Icon("/images/open_bug_marker.png", new OpenLayers.Size(22, 22), new OpenLayers.Pixel(-11, -11)),
|
iconOpen: new OpenLayers.Icon("<%= image_path "open_bug_marker.png" %>", new OpenLayers.Size(22, 22), new OpenLayers.Pixel(-11, -11)),
|
||||||
iconClosed : new OpenLayers.Icon("/images/closed_bug_marker.png", new OpenLayers.Size(22, 22), new OpenLayers.Pixel(-11, -11)),
|
iconClosed: new OpenLayers.Icon("<%= image_path "closed_bug_marker.png" %>", new OpenLayers.Size(22, 22), new OpenLayers.Pixel(-11, -11)),
|
||||||
readonly : false,
|
readonly: false,
|
||||||
setCookie : false,
|
setCookie: false,
|
||||||
cookieLifetime : 1000,
|
permalinkURL: "http://www.openstreetmap.org/",
|
||||||
cookiePath : "/my/map/",
|
theme: "<%= stylesheet_path "openstreetbugs" %>",
|
||||||
permalinkURL : "http://www.openstreetmap.org/",
|
visibility: false
|
||||||
theme : "/stylesheets/openstreetbugs.css",
|
|
||||||
visibility : false
|
|
||||||
});
|
});
|
||||||
|
|
||||||
map.addLayer(map.osbLayer);
|
map.addLayer(map.osbLayer);
|
||||||
|
|
||||||
map.osbControl = new OpenLayers.Control.OpenStreetBugs(map.osbLayer);
|
map.osbControl = new OpenLayers.Control.OpenStreetBugs(map.osbLayer);
|
||||||
|
|
||||||
map.addControl(map.osbControl);
|
map.addControl(map.osbControl);
|
||||||
|
|
||||||
var lBug = document.getElementById('ReportBug');
|
|
||||||
/* lBug.addEventListener('click',function (e) {
|
|
||||||
map.osbControl.activate(); document.getElementById("OpenLayers.Map_18_OpenLayers_Container").style.cursor = "crosshair" },false); */
|
|
||||||
lBug.addEventListener('click',function (e) {
|
|
||||||
map.osbControl.activate(); map.osbControl.addTemporaryMarker(map.getCenter());},false);
|
|
||||||
|
|
||||||
map.events.register("zoomend",map,function () { var zoom = map.getZoom(); var lBug = document.getElementById('ReportBug')
|
|
||||||
if (zoom > 11) { lBug.style.visibility = 'visible';} else {lBug.style.visibility = "hidden";}});
|
|
||||||
|
|
||||||
|
$("reportbuganchor").observe("click", addBug);
|
||||||
|
|
||||||
|
map.events.register("zoomend", map, allowBugReports);
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% unless object_zoom %>
|
<% unless object_zoom %>
|
||||||
|
@ -333,6 +322,19 @@ end
|
||||||
<% end %>
|
<% end %>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addBug() {
|
||||||
|
map.osbControl.activate();
|
||||||
|
map.osbControl.addTemporaryMarker(map.getCenter());
|
||||||
|
}
|
||||||
|
|
||||||
|
function allowBugReports() {
|
||||||
|
if (map.getZoom() > 11) {
|
||||||
|
$("reportbuganchor").style.visibility = "visible";
|
||||||
|
} else {
|
||||||
|
$("reportbuganchor").style.visibility = "hidden";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mapInit();
|
mapInit();
|
||||||
|
|
||||||
Event.observe(window, "load", installEditHandler);
|
Event.observe(window, "load", installEditHandler);
|
||||||
|
|
|
@ -76,25 +76,20 @@ ActionController::Routing::Routes.draw do |map|
|
||||||
map.connect "api/#{API_VERSION}/swf/trackpoints", :controller =>'swf', :action =>'trackpoints'
|
map.connect "api/#{API_VERSION}/swf/trackpoints", :controller =>'swf', :action =>'trackpoints'
|
||||||
|
|
||||||
# Map Bugs API
|
# Map Bugs API
|
||||||
map.connect "api/#{API_VERSION}/bugs/getBugs", :controller =>'map_bugs', :action =>'get_bugs'
|
map.connect "api/#{API_VERSION}/bugs/getBugs", :controller => 'map_bugs', :action => 'get_bugs'
|
||||||
map.connect "api/#{API_VERSION}/bugs/addPOIexec", :controller =>'map_bugs', :action =>'add_bug'
|
map.connect "api/#{API_VERSION}/bugs/addPOIexec", :controller => 'map_bugs', :action => 'add_bug'
|
||||||
map.connect "api/#{API_VERSION}/bugs/closePOIexec", :controller =>'map_bugs', :action =>'close_bug'
|
map.connect "api/#{API_VERSION}/bugs/closePOIexec", :controller => 'map_bugs', :action => 'close_bug'
|
||||||
map.connect "api/#{API_VERSION}/bugs/editPOIexec", :controller =>'map_bugs', :action =>'edit_bug'
|
map.connect "api/#{API_VERSION}/bugs/editPOIexec", :controller => 'map_bugs', :action => 'edit_bug'
|
||||||
map.connect "api/#{API_VERSION}/bugs/getGPX", :controller =>'map_bugs', :action =>'gpx_bugs'
|
map.connect "api/#{API_VERSION}/bugs/getGPX", :controller => 'map_bugs', :action => 'gpx_bugs'
|
||||||
map.connect "api/#{API_VERSION}/bugs/getRSSfeed", :controller =>'map_bugs', :action =>'rss'
|
map.connect "api/#{API_VERSION}/bugs/getRSSfeed", :controller => 'map_bugs', :action => 'rss'
|
||||||
|
|
||||||
map.connect "api/#{API_VERSION}/bugs", :controller => 'map_bugs', :action => 'get_bugs'
|
map.connect "api/#{API_VERSION}/bugs", :controller => 'map_bugs', :action => 'get_bugs'
|
||||||
map.connect "api/#{API_VERSION}/bugs/search", :controller => 'map_bugs', :action => 'search'
|
map.connect "api/#{API_VERSION}/bugs/search", :controller => 'map_bugs', :action => 'search'
|
||||||
map.connect "api/#{API_VERSION}/bugs/rss", :controller =>'map_bugs', :action =>'rss'
|
map.connect "api/#{API_VERSION}/bugs/rss", :controller =>'map_bugs', :action => 'rss'
|
||||||
map.connect "api/#{API_VERSION}/bug/create", :controller => 'map_bugs', :action => 'add_bug'
|
map.connect "api/#{API_VERSION}/bug/create", :controller => 'map_bugs', :action => 'add_bug'
|
||||||
map.connect "api/#{API_VERSION}/bug/:id/comment", :controller => 'map_bugs', :action => 'edit_bug', :id => /\d+/
|
map.connect "api/#{API_VERSION}/bug/:id/comment", :controller => 'map_bugs', :action => 'edit_bug', :id => /\d+/
|
||||||
map.connect "api/#{API_VERSION}/bug/:id/close", :controller => 'map_bugs', :action => 'close_bug', :id => /\d+/
|
map.connect "api/#{API_VERSION}/bug/:id/close", :controller => 'map_bugs', :action => 'close_bug', :id => /\d+/
|
||||||
map.connect "api/#{API_VERSION}/bug/:id", :controller => 'map_bugs', :action => 'read', :id => /\d+/, :conditions => { :method => :get }
|
map.connect "api/#{API_VERSION}/bug/:id", :controller => 'map_bugs', :action => 'read', :id => /\d+/, :conditions => { :method => :get }
|
||||||
map.connect "api/#{API_VERSION}/bug/:id", :controller => 'map_bugs', :action => 'delete', :id => /\d+/, :conditions => { :method => :delete }
|
map.connect "api/#{API_VERSION}/bug/:id", :controller => 'map_bugs', :action => 'delete', :id => /\d+/, :conditions => { :method => :delete }
|
||||||
|
|
||||||
map.connect '/user/:display_name/bugs', :controller => 'map_bugs', :action => 'my_bugs'
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Data browsing
|
# Data browsing
|
||||||
map.connect '/browse/start', :controller => 'browse', :action => 'start'
|
map.connect '/browse/start', :controller => 'browse', :action => 'start'
|
||||||
|
@ -110,6 +105,7 @@ ActionController::Routing::Routes.draw do |map|
|
||||||
map.connect '/browse/changesets/feed', :controller => 'changeset', :action => 'list', :format => :atom
|
map.connect '/browse/changesets/feed', :controller => 'changeset', :action => 'list', :format => :atom
|
||||||
map.connect '/browse/changesets', :controller => 'changeset', :action => 'list'
|
map.connect '/browse/changesets', :controller => 'changeset', :action => 'list'
|
||||||
map.connect '/browse/bug/:id', :controller => 'browse', :action => 'bug', :id => /\d+/
|
map.connect '/browse/bug/:id', :controller => 'browse', :action => 'bug', :id => /\d+/
|
||||||
|
map.connect '/user/:display_name/bugs', :controller => 'map_bugs', :action => 'my_bugs'
|
||||||
map.connect '/browse', :controller => 'changeset', :action => 'list'
|
map.connect '/browse', :controller => 'changeset', :action => 'list'
|
||||||
|
|
||||||
# web site
|
# web site
|
||||||
|
|
|
@ -2,8 +2,7 @@ require 'lib/migrate'
|
||||||
|
|
||||||
class AddMapBugTables < ActiveRecord::Migration
|
class AddMapBugTables < ActiveRecord::Migration
|
||||||
def self.up
|
def self.up
|
||||||
|
create_enumeration :map_bug_status_enum, ["open", "closed", "hidden"]
|
||||||
create_enumeration :map_bug_status_enum, ["open", "closed","hidden"]
|
|
||||||
|
|
||||||
create_table :map_bugs do |t|
|
create_table :map_bugs do |t|
|
||||||
t.column :id, :bigint, :null => false
|
t.column :id, :bigint, :null => false
|
||||||
|
@ -14,20 +13,21 @@ class AddMapBugTables < ActiveRecord::Migration
|
||||||
t.datetime :date_created, :null => false
|
t.datetime :date_created, :null => false
|
||||||
t.string :nearby_place
|
t.string :nearby_place
|
||||||
t.string :text
|
t.string :text
|
||||||
t.column :status, :map_bug_status_enum, :null => false
|
t.column :status, :map_bug_status_enum, :null => false
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index :map_bugs, [:tile,:status], :name => "map_bugs_tile_idx"
|
add_index :map_bugs, [:tile, :status], :name => "map_bugs_tile_idx"
|
||||||
add_index :map_bugs, [:last_changed], :name => "map_bugs_changed_idx"
|
add_index :map_bugs, [:last_changed], :name => "map_bugs_changed_idx"
|
||||||
add_index :map_bugs, [:date_created], :name => "map_bugs_created_idx"
|
add_index :map_bugs, [:date_created], :name => "map_bugs_created_idx"
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.down
|
def self.down
|
||||||
remove_index :map_bugs, :name => "map_bugs_tile_idx"
|
remove_index :map_bugs, :name => "map_bugs_tile_idx"
|
||||||
remove_index :map_bugs, :name => "map_bugs_changed_idx"
|
remove_index :map_bugs, :name => "map_bugs_changed_idx"
|
||||||
remove_index :map_bugs, :name => "map_bugs_created_idx"
|
remove_index :map_bugs, :name => "map_bugs_created_idx"
|
||||||
|
|
||||||
drop_table :map_bugs
|
drop_table :map_bugs
|
||||||
drop_enumeration :map_bug_status_enum
|
|
||||||
|
drop_enumeration :map_bug_status_enum
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,35 +2,33 @@ require 'lib/migrate'
|
||||||
|
|
||||||
class RefactorMapBugTables < ActiveRecord::Migration
|
class RefactorMapBugTables < ActiveRecord::Migration
|
||||||
def self.up
|
def self.up
|
||||||
|
|
||||||
|
|
||||||
create_table :map_bug_comment do |t|
|
create_table :map_bug_comment do |t|
|
||||||
t.column :id, :bigint, :null => false
|
t.column :id, :bigint, :null => false
|
||||||
t.column :bug_id, :bigint, :null => false
|
t.column :bug_id, :bigint, :null => false
|
||||||
t.boolean :visible, :null => false
|
t.boolean :visible, :null => false
|
||||||
t.datetime :date_created, :null => false
|
t.datetime :date_created, :null => false
|
||||||
t.string :commenter_name
|
t.string :commenter_name
|
||||||
t.string :commenter_ip
|
t.string :commenter_ip
|
||||||
t.column :commenter_id, :bigint
|
t.column :commenter_id, :bigint
|
||||||
t.string :comment
|
t.string :comment
|
||||||
end
|
end
|
||||||
|
|
||||||
remove_column :map_bugs, :text
|
remove_column :map_bugs, :text
|
||||||
|
|
||||||
add_index :map_bug_comment, [:bug_id], :name => "map_bug_comment_id_idx"
|
add_index :map_bug_comment, [:bug_id], :name => "map_bug_comment_id_idx"
|
||||||
add_foreign_key :map_bug_comment, [:bug_id], :map_bugs, [:id]
|
|
||||||
add_foreign_key :map_bug_comment, [:commenter_id], :users, [:id]
|
|
||||||
|
|
||||||
|
add_foreign_key :map_bug_comment, [:bug_id], :map_bugs, [:id]
|
||||||
|
add_foreign_key :map_bug_comment, [:commenter_id], :users, [:id]
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.down
|
def self.down
|
||||||
|
remove_foreign_key :map_bug_comment, [:commenter_id]
|
||||||
add_column :map_bugs, :text, :string
|
remove_foreign_key :map_bug_comment, [:bug_id]
|
||||||
|
|
||||||
remove_index :map_bugs, :name => "map_bug_comment_id_idx"
|
remove_index :map_bugs, :name => "map_bug_comment_id_idx"
|
||||||
remove_foreign_key :map_bug_comment, [:bug_id]
|
|
||||||
remove_foreign_key :map_bug_comment, [:commenter_id]
|
|
||||||
|
|
||||||
drop_table :map_bugs_comment
|
add_column :map_bugs, :text, :string
|
||||||
|
|
||||||
|
drop_table :map_bug_comment
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,10 +2,10 @@ require 'lib/migrate'
|
||||||
|
|
||||||
class ChangeMapBugCommentType < ActiveRecord::Migration
|
class ChangeMapBugCommentType < ActiveRecord::Migration
|
||||||
def self.up
|
def self.up
|
||||||
change_column :map_bug_comment, :comment, :text
|
change_column :map_bug_comment, :comment, :text
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.down
|
def self.down
|
||||||
change_column :map_bug_comment, :comment, :string
|
change_column :map_bug_comment, :comment, :string
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,12 +2,10 @@ require 'lib/migrate'
|
||||||
|
|
||||||
class AddDateClosed < ActiveRecord::Migration
|
class AddDateClosed < ActiveRecord::Migration
|
||||||
def self.up
|
def self.up
|
||||||
|
add_column :map_bugs, :date_closed, :timestamp
|
||||||
add_column :map_bugs, :date_closed, :timestamp
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.down
|
def self.down
|
||||||
|
remove_column :map_bugs, :date_closed
|
||||||
remove_column :map_bugs, :date_closed
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,13 +2,14 @@ require 'lib/migrate'
|
||||||
|
|
||||||
class AddMapBugCommentEvent < ActiveRecord::Migration
|
class AddMapBugCommentEvent < ActiveRecord::Migration
|
||||||
def self.up
|
def self.up
|
||||||
create_enumeration :map_bug_event_enum, ["opened", "closed","reopened","commented","hidden"]
|
create_enumeration :map_bug_event_enum, ["opened", "closed", "reopened", "commented", "hidden"]
|
||||||
add_column :map_bug_comment, :event, :map_bug_event_enum
|
|
||||||
|
add_column :map_bug_comment, :event, :map_bug_event_enum
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.down
|
def self.down
|
||||||
|
remove_column :map_bug_comment, :event
|
||||||
|
|
||||||
remove_column :map_bug_comment, :event
|
drop_enumeration :map_bug_event_enum
|
||||||
drop_enumeration :map_bug_event_enum
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -54,7 +54,8 @@ private
|
||||||
return self.find(:all, options)
|
return self.find(:all, options)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def find_by_area_no_quadtile(minlat, minlon, maxlat, maxlon, options)
|
|
||||||
|
def find_by_area_no_quadtile(minlat, minlon, maxlat, maxlon, options)
|
||||||
self.with_scope(:find => {:conditions => OSM.sql_for_area_no_quadtile(minlat, minlon, maxlat, maxlon)}) do
|
self.with_scope(:find => {:conditions => OSM.sql_for_area_no_quadtile(minlat, minlon, maxlat, maxlon)}) do
|
||||||
return self.find(:all, options)
|
return self.find(:all, options)
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
a.reportProblem {
|
/* Rules for map bug reporting */
|
||||||
font-size:150%;
|
|
||||||
|
#reportbuganchor {
|
||||||
|
font-size: 150%;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,34 +5,33 @@ class MapBugsControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
def test_map_bug_create_success
|
def test_map_bug_create_success
|
||||||
assert_difference('MapBug.count') do
|
assert_difference('MapBug.count') do
|
||||||
assert_difference('MapBugComment.count') do
|
assert_difference('MapBugComment.count') do
|
||||||
post :add_bug, {:lat => -1.0, :lon => -1.0, :name => "new_tester", :text => "This is a comment"}
|
post :add_bug, {:lat => -1.0, :lon => -1.0, :name => "new_tester", :text => "This is a comment"}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
assert_response :success
|
assert_response :success
|
||||||
id = @response.body.sub(/ok/,"").to_i
|
id = @response.body.sub(/ok/,"").to_i
|
||||||
get :read, {:id => id, :format => 'json'}
|
get :read, {:id => id, :format => 'json'}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
js = @response.body
|
js = @response.body
|
||||||
assert_match "\"status\":\"open\"", js
|
assert_match "\"status\":\"open\"", js
|
||||||
assert_match "\"comment\":\"This is a comment\"", js
|
assert_match "\"comment\":\"This is a comment\"", js
|
||||||
assert_match "\"commenter_name\":\"new_tester (a)\"", js
|
assert_match "\"commenter_name\":\"new_tester (a)\"", js
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_map_bug_comment_create_success
|
def test_map_bug_comment_create_success
|
||||||
assert_difference('MapBugComment.count') do
|
assert_difference('MapBugComment.count') do
|
||||||
post :edit_bug, {:id => 2, :name => "new_tester2", :text => "This is an additional comment"}
|
post :edit_bug, {:id => 2, :name => "new_tester2", :text => "This is an additional comment"}
|
||||||
end
|
end
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
get :read, {:id => 2, :format => 'json'}
|
get :read, {:id => 2, :format => 'json'}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
js = @response.body
|
js = @response.body
|
||||||
assert_match "\"id\":2", js
|
assert_match "\"id\":2", js
|
||||||
assert_match "\"status\":\"open\"", js
|
assert_match "\"status\":\"open\"", js
|
||||||
assert_match "\"comment\":\"This is an additional comment\"", js
|
assert_match "\"comment\":\"This is an additional comment\"", js
|
||||||
assert_match "\"commenter_name\":\"new_tester2 (a)\"", js
|
assert_match "\"commenter_name\":\"new_tester2 (a)\"", js
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_map_bug_read_success
|
def test_map_bug_read_success
|
||||||
|
@ -53,122 +52,118 @@ class MapBugsControllerTest < ActionController::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_map_bug_close_success
|
def test_map_bug_close_success
|
||||||
post :close_bug, {:id => 2}
|
post :close_bug, {:id => 2}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
get :read, {:id => 2, :format => 'json'}
|
get :read, {:id => 2, :format => 'json'}
|
||||||
js = @response.body
|
js = @response.body
|
||||||
assert_match "\"id\":2", js
|
assert_match "\"id\":2", js
|
||||||
assert_match "\"status\":\"closed\"", js
|
assert_match "\"status\":\"closed\"", js
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_get_bugs_success
|
def test_get_bugs_success
|
||||||
get :get_bugs, {:bbox=>'1,1,1.2,1.2'}
|
get :get_bugs, {:bbox=>'1,1,1.2,1.2'}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
get :get_bugs, {:bbox=>'1,1,1.2,1.2', :format => 'rss'}
|
get :get_bugs, {:bbox=>'1,1,1.2,1.2', :format => 'rss'}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
get :get_bugs, {:bbox=>'1,1,1.2,1.2', :format => 'json'}
|
get :get_bugs, {:bbox=>'1,1,1.2,1.2', :format => 'json'}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
get :get_bugs, {:bbox=>'1,1,1.2,1.2', :format => 'xml'}
|
get :get_bugs, {:bbox=>'1,1,1.2,1.2', :format => 'xml'}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
get :get_bugs, {:bbox=>'1,1,1.2,1.2', :format => 'gpx'}
|
get :get_bugs, {:bbox=>'1,1,1.2,1.2', :format => 'gpx'}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_get_bugs_large_area_success
|
def test_get_bugs_large_area_success
|
||||||
get :get_bugs, {:bbox=>'-10,-10,12,12'}
|
get :get_bugs, {:bbox=>'-10,-10,12,12'}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_get_bugs_closed_7_success
|
def test_get_bugs_closed_7_success
|
||||||
get :get_bugs, {:bbox=>'1,1,1.2,1.2', :closed => '7'}
|
get :get_bugs, {:bbox=>'1,1,1.2,1.2', :closed => '7'}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_get_bugs_closed_0_success
|
def test_get_bugs_closed_0_success
|
||||||
get :get_bugs, {:bbox=>'1,1,1.2,1.2', :closed => '0'}
|
get :get_bugs, {:bbox=>'1,1,1.2,1.2', :closed => '0'}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_get_bugs_closed_n1_success
|
def test_get_bugs_closed_n1_success
|
||||||
get :get_bugs, {:bbox=>'1,1,1.2,1.2', :closed => '-1'}
|
get :get_bugs, {:bbox=>'1,1,1.2,1.2', :closed => '-1'}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def test_search_success
|
def test_search_success
|
||||||
get :search, {:bbox=>'1,1,1.2,1.2', :q => 'bug 1'}
|
get :search, {:bbox=>'1,1,1.2,1.2', :q => 'bug 1'}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
get :search, {:bbox=>'1,1,1.2,1.2', :q => 'bug 1', :format => 'xml'}
|
get :search, {:bbox=>'1,1,1.2,1.2', :q => 'bug 1', :format => 'xml'}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
get :search, {:bbox=>'1,1,1.2,1.2', :q => 'bug 1', :format => 'json'}
|
get :search, {:bbox=>'1,1,1.2,1.2', :q => 'bug 1', :format => 'json'}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
get :search, {:bbox=>'1,1,1.2,1.2', :q => 'bug 1', :format => 'rss'}
|
get :search, {:bbox=>'1,1,1.2,1.2', :q => 'bug 1', :format => 'rss'}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
get :search, {:bbox=>'1,1,1.2,1.2', :q => 'bug 1', :format => 'gpx'}
|
get :search, {:bbox=>'1,1,1.2,1.2', :q => 'bug 1', :format => 'gpx'}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_rss_success
|
def test_rss_success
|
||||||
get :rss, {:bbox=>'1,1,1.2,1.2'}
|
get :rss, {:bbox=>'1,1,1.2,1.2'}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
get :rss
|
get :rss
|
||||||
assert_response :success
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_user_bugs_success
|
def test_user_bugs_success
|
||||||
get :my_bugs, {:display_name=>'test'}
|
get :my_bugs, {:display_name=>'test'}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
get :my_bugs, {:display_name=>'pulibc_test2'}
|
get :my_bugs, {:display_name=>'pulibc_test2'}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
||||||
get :my_bugs, {:display_name=>'non-existent'}
|
get :my_bugs, {:display_name=>'non-existent'}
|
||||||
assert_response :not_found
|
assert_response :not_found
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_map_bug_comment_create_not_found
|
def test_map_bug_comment_create_not_found
|
||||||
assert_no_difference('MapBugComment.count') do
|
assert_no_difference('MapBugComment.count') do
|
||||||
post :edit_bug, {:id => 12345, :name => "new_tester", :text => "This is an additional comment"}
|
post :edit_bug, {:id => 12345, :name => "new_tester", :text => "This is an additional comment"}
|
||||||
end
|
end
|
||||||
assert_response :not_found
|
assert_response :not_found
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_map_bug_close_not_found
|
def test_map_bug_close_not_found
|
||||||
post :close_bug, {:id => 12345}
|
post :close_bug, {:id => 12345}
|
||||||
assert_response :not_found
|
assert_response :not_found
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_map_bug_read_not_found
|
def test_map_bug_read_not_found
|
||||||
get :read, {:id => 12345}
|
get :read, {:id => 12345}
|
||||||
assert_response :not_found
|
assert_response :not_found
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_map_bug_read_gone
|
def test_map_bug_read_gone
|
||||||
get :read, {:id => 4}
|
get :read, {:id => 4}
|
||||||
assert_response :gone
|
assert_response :gone
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_map_bug_hidden_comment
|
def test_map_bug_hidden_comment
|
||||||
get :read, {:id => 5, :format => 'json'}
|
get :read, {:id => 5, :format => 'json'}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
js = @response.body
|
js = @response.body
|
||||||
assert_match "\"id\":5", js
|
assert_match "\"id\":5", js
|
||||||
assert_match "\"comment\":\"Valid comment for bug 5\"", js
|
assert_match "\"comment\":\"Valid comment for bug 5\"", js
|
||||||
assert_match "\"comment\":\"Another valid comment for bug 5\"", js
|
assert_match "\"comment\":\"Another valid comment for bug 5\"", js
|
||||||
assert_no_match /\"comment\":\"Spam for bug 5\"/, js
|
assert_no_match /\"comment\":\"Spam for bug 5\"/, js
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue