-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tests for controllers #615
Changes from 3 commits
826868d
7a1d6b0
c5c5524
f8d4c79
60c1edf
4a105c9
9b41778
452e0b1
86a58f6
daa9907
5cd00cf
f8edcc7
573f312
732c8f6
bbad6ef
c18231d
e5e4d8c
6975a77
610c583
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
require 'test_helper' | ||
|
||
class AnnotationsControllerTest < ActionController::TestCase | ||
|
||
# called before every single test | ||
def setup | ||
@map = maps(:saugus) | ||
@annotation = annotations(:one) | ||
end | ||
|
||
# called after every single test | ||
def teardown | ||
end | ||
|
||
test "should create annotation if logged in " do | ||
before_count = @map.annotations.count | ||
session[:user_id] = 1 | ||
post :create, | ||
{ | ||
format: :json, | ||
map_id: 1, | ||
annotation: { | ||
properties: { | ||
annotation_type: 'polyline', | ||
textContent: 'Some cool text' | ||
}, | ||
geometry: { coordinates: [10,33] } | ||
} | ||
} | ||
|
||
@map.reload | ||
assert_response 302 | ||
assert_not_equal before_count, @map.annotations.count | ||
assert_redirected_to map_annotation_url(@map,@map.annotations.last) | ||
end | ||
|
||
test "should create annotation if not logged in " do | ||
before_count = @map.annotations.count | ||
post :create, | ||
{ | ||
format: :json, | ||
map_id: 1, | ||
annotation: { | ||
properties: { | ||
annotation_type: 'polyline', | ||
textContent: 'Some cool text' | ||
}, | ||
geometry: { coordinates: [10,33] } | ||
} | ||
} | ||
|
||
@map.reload | ||
assert_response 302 | ||
assert_not_equal before_count, @map.annotations.count | ||
assert_redirected_to map_annotation_url(@map,@map.annotations.last) | ||
end | ||
|
||
# test 'should show annotations' do | ||
# get :show, map_id: 1, id: @annotation.id | ||
|
||
# assert_response 200 | ||
# assert_includes @response.body, @annotation.text | ||
# end | ||
|
||
test 'should update annotations' do | ||
end | ||
|
||
test 'should destroy annotations' do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be blank? |
||
end | ||
|
||
# test 'should display index' do | ||
# get :index, map_id: 1 | ||
# assert_response :success | ||
# assert_includes @response.body, @annotation.text | ||
# end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,4 +68,36 @@ def teardown | |
assert_equal 'export not running', @response.body | ||
assert_equal 'text/html', @response.content_type | ||
end | ||
|
||
test 'progress with no export' do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
get :progress, id: 4 | ||
assert_response :success | ||
assert_equal 'export has not been run', @response.body | ||
end | ||
|
||
test 'progress completed' do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
get :progress, id: 2 | ||
assert_response :success | ||
assert_equal 'complete', @response.body | ||
end | ||
|
||
test 'progress failed' do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
get :progress, id: 3 | ||
assert_response :success | ||
assert_equal 'export failed', @response.body | ||
end | ||
|
||
#does not test the exporter client | ||
test "should display export status" do | ||
session[:user_id] = 1 | ||
get :status, id: @map.id | ||
assert_response :success | ||
end | ||
|
||
test "should display error if no export" do | ||
session[:user_id] = 1 | ||
get :status, id: 4 | ||
assert_response :success | ||
#assert_equal { status: 'export has not been run' }.to_json, @response.body | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
require 'test_helper' | ||
|
||
class UtilityControllerTest < ActionController::TestCase | ||
|
||
kaustubh-nair marked this conversation as resolved.
Show resolved
Hide resolved
|
||
test "tms_alt" do | ||
get(:tms_alt, | ||
kaustubh-nair marked this conversation as resolved.
Show resolved
Hide resolved
|
||
id: 1, | ||
kaustubh-nair marked this conversation as resolved.
Show resolved
Hide resolved
|
||
x: 10, | ||
y: 30, | ||
z: 40 | ||
) | ||
kaustubh-nair marked this conversation as resolved.
Show resolved
Hide resolved
kaustubh-nair marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
y = 2**40.to_i - 30.to_i - 1 | ||
assert_redirected_to "/tms/1/40/10/#{y}.png" | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be blank?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
update
anddestroy
actions don't workSo i left them blank for now.