-
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 15 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,10 @@ | ||
Metrics/BlockLength: | ||
Max: 100 | ||
Metrics/LineLength: | ||
Max: 265 | ||
Style/ConditionalAssignment: | ||
enabled: false | ||
Style/IfUnlessModifier: | ||
enabled: false | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,7 @@ def self.histogram_cm_per_pixel | |
|
||
def self.histogram_cm_per_pixel_in_tens | ||
e = Export.where('cm_per_pixel != "" AND cm_per_pixel < 500') | ||
.order(cm_per_pixel: 'desc') | ||
.order('cm_per_pixel desc') | ||
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. I would prefer 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. @jainaman224 https://travis-ci.org/publiclab/mapknitter/builds/539536753#L1246-L1249 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. I think this is related to our MySQL adapter gem version. |
||
hist = [] | ||
(0..(e.first.cm_per_pixel)/10.to_i).each do |bin| | ||
hist[bin] = 0 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -159,3 +159,4 @@ | |
end | ||
|
||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
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 | ||
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? 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. The |
||
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 |
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.
Maybe this is not needed since #547 is ready to merge too. And we're using our standard stylesheet.