forked from publiclab/mapknitter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for controllers (publiclab#615)
* add utility test * Add exports and annotations controller tests' * Add tests for images * Fix codeclimate issues * Single quoted strings, huh :/ * Fix export controller test * Fix histogram ordering * Fix codeclimate issues * Fix image controller tests * Small fixes * Add rubocop.yml * Fix rubocop * Increase linelength * Fix rubocop * Rename tests for better readability * Rename tests * Fixing Codeclimate offenses
- Loading branch information
1 parent
ed40fef
commit 28ffb60
Showing
18 changed files
with
458 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -159,3 +159,4 @@ | |
end | ||
|
||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
end | ||
|
||
test 'should destroy annotations' do | ||
end | ||
|
||
# test 'should display index' do | ||
# get :index, map_id: 1 | ||
# assert_response :success | ||
# assert_includes @response.body, @annotation.text | ||
# end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.