Add some rudimentary initial tests for the map bugs api
This commit is contained in:
parent
35bbf82c20
commit
6d668f6f3a
3 changed files with 250 additions and 0 deletions
78
test/fixtures/map_bug_comment.yml
vendored
Normal file
78
test/fixtures/map_bug_comment.yml
vendored
Normal file
|
@ -0,0 +1,78 @@
|
|||
t1:
|
||||
id: 1
|
||||
bug_id: 1
|
||||
visible: true
|
||||
date_created: 2007-01-01 00:00:00
|
||||
commenter_name: 'testname'
|
||||
commenter_ip: '192.168.1.1'
|
||||
comment: 'This is the initial description of the bug 1'
|
||||
|
||||
|
||||
t2:
|
||||
id: 2
|
||||
bug_id: 2
|
||||
visible: true
|
||||
date_created: 2007-01-01 00:00:00
|
||||
commenter_name: 'testname'
|
||||
commenter_ip: '192.168.1.1'
|
||||
comment: 'This is the initial description of the bug 2'
|
||||
|
||||
|
||||
t3:
|
||||
id: 3
|
||||
bug_id: 2
|
||||
visible: true
|
||||
date_created: 2007-02-01 00:00:00
|
||||
commenter_name: 'testname'
|
||||
commenter_ip: '192.168.1.1'
|
||||
comment: 'This is an additional comment for bug 2'
|
||||
|
||||
|
||||
t4:
|
||||
id: 4
|
||||
bug_id: 3
|
||||
visible: true
|
||||
date_created: 2007-01-01 00:00:00
|
||||
commenter_name: 'testname'
|
||||
commenter_ip: '192.168.1.1'
|
||||
comment: 'This is the initial comment for bug 3'
|
||||
|
||||
t5:
|
||||
id: 5
|
||||
bug_id: 4
|
||||
visible: true
|
||||
date_created: 2007-01-01 00:00:00
|
||||
commenter_name: 'testname'
|
||||
commenter_ip: '192.168.1.1'
|
||||
comment: 'Spam for bug 4'
|
||||
|
||||
|
||||
t6:
|
||||
id: 6
|
||||
bug_id: 5
|
||||
visible: true
|
||||
date_created: 2007-01-01 00:00:00
|
||||
commenter_name: 'testname'
|
||||
commenter_ip: '192.168.1.1'
|
||||
comment: 'Valid Comment for bug 5'
|
||||
|
||||
t6:
|
||||
id: 7
|
||||
bug_id: 5
|
||||
visible: false
|
||||
date_created: 2007-02-01 00:00:00
|
||||
commenter_name: 'testname'
|
||||
commenter_ip: '192.168.1.1'
|
||||
comment: 'Spam for bug 5'
|
||||
|
||||
t8:
|
||||
id: 8
|
||||
bug_id: 5
|
||||
visible: true
|
||||
date_created: 2007-02-01 00:00:00
|
||||
commenter_name: 'testname'
|
||||
commenter_ip: '192.168.1.1'
|
||||
comment: 'Another valid comment for bug 5'
|
||||
|
||||
|
||||
|
49
test/fixtures/map_bugs.yml
vendored
Normal file
49
test/fixtures/map_bugs.yml
vendored
Normal file
|
@ -0,0 +1,49 @@
|
|||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
||||
<% SCALE = 10000000 unless defined?(SCALE) %>
|
||||
|
||||
open_bug:
|
||||
id: 1
|
||||
latitude: <%= 1*SCALE %>
|
||||
longitude: <%= 1*SCALE %>
|
||||
status: open
|
||||
tile: <%= QuadTile.tile_for_point(1,1) %>
|
||||
date_created: 2007-01-01 00:00:00
|
||||
last_changed: 2007-01-01 00:00:00
|
||||
|
||||
open_bug_with_comment:
|
||||
id: 2
|
||||
latitude: <%= 1.1*SCALE %>
|
||||
longitude: <%= 1.1*SCALE %>
|
||||
status: open
|
||||
tile: <%= QuadTile.tile_for_point(1.1,1.1) %>
|
||||
date_created: 2007-01-01 00:00:00
|
||||
last_changed: 2007-02-01 00:00:00
|
||||
|
||||
closed_bug_with_comment:
|
||||
id: 3
|
||||
latitude: <%= 1.2*SCALE %>
|
||||
longitude: <%= 1.2*SCALE %>
|
||||
status: closed
|
||||
tile: <%= QuadTile.tile_for_point(1.2,1.2) %>
|
||||
date_created: 2007-01-01 00:00:00
|
||||
last_changed: 2007-03-01 00:00:00
|
||||
date_closed: 2007-03-01 00:00:00
|
||||
|
||||
hidden_bug_with_comment:
|
||||
id: 4
|
||||
latitude: <%= 1.3*SCALE %>
|
||||
longitude: <%= 1.3*SCALE %>
|
||||
status: hidden
|
||||
tile: <%= QuadTile.tile_for_point(1.3,1.3) %>
|
||||
date_created: 2007-01-01 00:00:00
|
||||
last_changed: 2007-03-01 00:00:00
|
||||
|
||||
bug_with_hidden_comment:
|
||||
id: 5
|
||||
latitude: <%= 1.4*SCALE %>
|
||||
longitude: <%= 1.4*SCALE %>
|
||||
status: open
|
||||
tile: <%= QuadTile.tile_for_point(1.4,1.4) %>
|
||||
date_created: 2007-01-01 00:00:00
|
||||
last_changed: 2007-03-01 00:00:00
|
||||
|
123
test/functional/map_bugs_controller_test.rb
Normal file
123
test/functional/map_bugs_controller_test.rb
Normal file
|
@ -0,0 +1,123 @@
|
|||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
|
||||
class MapBugsControllerTest < ActionController::TestCase
|
||||
fixtures :users, :map_bugs, :map_bug_comment
|
||||
|
||||
def test_map_bug_create_success
|
||||
assert_difference('MapBug.count') do
|
||||
assert_difference('MapBugComment.count') do
|
||||
post :add_bug, {:lat => -1.0, :lon => -1.0, :name => "new_tester", :text => "This is a comment"}
|
||||
end
|
||||
end
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_map_bug_comment_create_success
|
||||
assert_difference('MapBugComment.count') do
|
||||
post :edit_bug, {:id => 2, :name => "new_tester", :text => "This is an additional comment"}
|
||||
end
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_map_bug_read_success
|
||||
get :read, {:id => 1}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_map_bug_read_xml_success
|
||||
get :read, {:id => 1, :format => 'xml'}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_map_bug_read_rss_success
|
||||
get :read, {:id => 1, :format => 'rss'}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_map_bug_read_json_success
|
||||
get :read, {:id => 1, :format => 'json'}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_map_bug_read_gpx_success
|
||||
get :read, {:id => 1, :format => 'gpx'}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_map_bug_close_success
|
||||
post :close_bug, {:id => 2}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_get_bugs_success
|
||||
get :get_bugs, {:bbox=>'1,1,1.2,1.2'}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_get_bugs_closed_7_success
|
||||
get :get_bugs, {:bbox=>'1,1,1.2,1.2', :closed => '7'}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_get_bugs_closed_0_success
|
||||
get :get_bugs, {:bbox=>'1,1,1.2,1.2', :closed => '0'}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_get_bugs_closed_n1_success
|
||||
get :get_bugs, {:bbox=>'1,1,1.2,1.2', :closed => '-1'}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_get_bugs_rss_success
|
||||
get :get_bugs, {:bbox=>'1,1,1.2,1.2', :format => 'rss'}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_get_bugs_json_success
|
||||
get :get_bugs, {:bbox=>'1,1,1.2,1.2', :format => 'json'}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_get_bugs_xml_success
|
||||
get :get_bugs, {:bbox=>'1,1,1.2,1.2', :format => 'xml'}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_get_bugs_gpx_success
|
||||
get :get_bugs, {:bbox=>'1,1,1.2,1.2', :format => 'gpx'}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
|
||||
def test_search_success
|
||||
get :search, {:bbox=>'1,1,1.2,1.2', :q => 'bug 1'}
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
def test_map_bug_comment_create_not_found
|
||||
assert_no_difference('MapBugComment.count') do
|
||||
post :edit_bug, {:id => 12345, :name => "new_tester", :text => "This is an additional comment"}
|
||||
end
|
||||
assert_response :not_found
|
||||
end
|
||||
|
||||
def test_map_bug_close_not_found
|
||||
post :close_bug, {:id => 12345}
|
||||
assert_response :not_found
|
||||
end
|
||||
|
||||
def test_map_bug_read_not_found
|
||||
get :read, {:id => 12345}
|
||||
assert_response :not_found
|
||||
end
|
||||
|
||||
def test_map_bug_read_gone
|
||||
get :read, {:id => 4}
|
||||
assert_response :gone
|
||||
end
|
||||
|
||||
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue