Add a few more tests
This commit is contained in:
parent
11af851248
commit
93fb360a08
5 changed files with 86 additions and 11 deletions
|
@ -299,17 +299,6 @@ class NotesController < ApplicationController
|
||||||
# utility functions below.
|
# utility functions below.
|
||||||
#------------------------------------------------------------
|
#------------------------------------------------------------
|
||||||
|
|
||||||
##
|
|
||||||
# Render an OK response
|
|
||||||
def render_ok
|
|
||||||
if params[:format] == "js"
|
|
||||||
render :text => "osbResponse();", :content_type => "text/javascript"
|
|
||||||
else
|
|
||||||
render :text => "ok " + @note.id.to_s + "\n", :content_type => "text/plain" if @note
|
|
||||||
render :text => "ok\n", :content_type => "text/plain" unless @note
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Get the maximum number of results to return
|
# Get the maximum number of results to return
|
||||||
def result_limit
|
def result_limit
|
||||||
|
|
|
@ -129,6 +129,8 @@ class DiaryEntryControllerTest < ActionController::TestCase
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_template :edit
|
assert_template :edit
|
||||||
|
|
||||||
|
assert_nil UserPreference.where(:user_id => users(:normal_user).id, :k => "diary.default_language").first
|
||||||
|
|
||||||
# Now try creating a diary entry
|
# Now try creating a diary entry
|
||||||
assert_difference "DiaryEntry.count", 1 do
|
assert_difference "DiaryEntry.count", 1 do
|
||||||
post :new, { :commit => "save",
|
post :new, { :commit => "save",
|
||||||
|
@ -145,6 +147,29 @@ class DiaryEntryControllerTest < ActionController::TestCase
|
||||||
assert_equal new_latitude.to_f, entry.latitude
|
assert_equal new_latitude.to_f, entry.latitude
|
||||||
assert_equal new_longitude.to_f, entry.longitude
|
assert_equal new_longitude.to_f, entry.longitude
|
||||||
assert_equal new_language_code, entry.language_code
|
assert_equal new_language_code, entry.language_code
|
||||||
|
|
||||||
|
assert_equal new_language_code, UserPreference.where(:user_id => users(:normal_user).id, :k => "diary.default_language").first.v
|
||||||
|
|
||||||
|
new_language_code = "de"
|
||||||
|
|
||||||
|
# Now try creating a diary entry in a different language
|
||||||
|
assert_difference "DiaryEntry.count", 1 do
|
||||||
|
post :new, { :commit => "save",
|
||||||
|
:diary_entry => { :title => new_title, :body => new_body, :latitude => new_latitude,
|
||||||
|
:longitude => new_longitude, :language_code => new_language_code } },
|
||||||
|
{ :user => users(:normal_user).id }
|
||||||
|
end
|
||||||
|
assert_response :redirect
|
||||||
|
assert_redirected_to :action => :list, :display_name => users(:normal_user).display_name
|
||||||
|
entry = DiaryEntry.order(:id).last
|
||||||
|
assert_equal users(:normal_user).id, entry.user_id
|
||||||
|
assert_equal new_title, entry.title
|
||||||
|
assert_equal new_body, entry.body
|
||||||
|
assert_equal new_latitude.to_f, entry.latitude
|
||||||
|
assert_equal new_longitude.to_f, entry.longitude
|
||||||
|
assert_equal new_language_code, entry.language_code
|
||||||
|
|
||||||
|
assert_equal new_language_code, UserPreference.where(:user_id => users(:normal_user).id, :k => "diary.default_language").first.v
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_new_spammy
|
def test_new_spammy
|
||||||
|
|
|
@ -618,6 +618,39 @@ class NotesControllerTest < ActionController::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_index_limit
|
||||||
|
get :index, :bbox => "1,1,1.2,1.2", :limit => 1, :format => "rss"
|
||||||
|
assert_response :success
|
||||||
|
assert_equal "application/rss+xml", @response.content_type
|
||||||
|
assert_select "rss", :count => 1 do
|
||||||
|
assert_select "channel", :count => 1 do
|
||||||
|
assert_select "item", :count => 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
get :index, :bbox => "1,1,1.2,1.2", :limit => 1, :format => "json"
|
||||||
|
assert_response :success
|
||||||
|
assert_equal "application/json", @response.content_type
|
||||||
|
js = ActiveSupport::JSON.decode(@response.body)
|
||||||
|
assert_not_nil js
|
||||||
|
assert_equal "FeatureCollection", js["type"]
|
||||||
|
assert_equal 1, js["features"].count
|
||||||
|
|
||||||
|
get :index, :bbox => "1,1,1.2,1.2", :limit => 1, :format => "xml"
|
||||||
|
assert_response :success
|
||||||
|
assert_equal "application/xml", @response.content_type
|
||||||
|
assert_select "osm", :count => 1 do
|
||||||
|
assert_select "note", :count => 1
|
||||||
|
end
|
||||||
|
|
||||||
|
get :index, :bbox => "1,1,1.2,1.2", :limit => 1, :format => "gpx"
|
||||||
|
assert_response :success
|
||||||
|
assert_equal "application/gpx+xml", @response.content_type
|
||||||
|
assert_select "gpx", :count => 1 do
|
||||||
|
assert_select "wpt", :count => 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_index_empty_area
|
def test_index_empty_area
|
||||||
get :index, :bbox => "5,5,5.1,5.1", :format => "rss"
|
get :index, :bbox => "5,5,5.1,5.1", :format => "rss"
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
|
@ -221,6 +221,33 @@ class SiteControllerTest < ActionController::TestCase
|
||||||
assert_template "index"
|
assert_template "index"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Test the right editor gets used when the browser is IE
|
||||||
|
def test_edit_with_ie
|
||||||
|
@request.env["HTTP_USER_AGENT"] = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)"
|
||||||
|
|
||||||
|
get :edit, {}, { :user => users(:public_user).id }
|
||||||
|
assert_response :success
|
||||||
|
assert_template "edit"
|
||||||
|
assert_template :partial => "_potlatch2", :count => 1
|
||||||
|
|
||||||
|
get :edit, { :editor => "id" }, { :user => users(:public_user).id }
|
||||||
|
assert_response :success
|
||||||
|
assert_template "edit"
|
||||||
|
assert_template :partial => "_potlatch2", :count => 1
|
||||||
|
|
||||||
|
@request.env["HTTP_USER_AGENT"] = "Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko"
|
||||||
|
|
||||||
|
get :edit, {}, { :user => users(:public_user).id }
|
||||||
|
assert_response :success
|
||||||
|
assert_template "edit"
|
||||||
|
assert_template :partial => "_potlatch2", :count => 1
|
||||||
|
|
||||||
|
get :edit, { :editor => "id" }, { :user => users(:public_user).id }
|
||||||
|
assert_response :success
|
||||||
|
assert_template "edit"
|
||||||
|
assert_template :partial => "_potlatch2", :count => 1
|
||||||
|
end
|
||||||
|
|
||||||
# Test editing a specific node
|
# Test editing a specific node
|
||||||
def test_edit_with_node
|
def test_edit_with_node
|
||||||
user = users(:public_user)
|
user = users(:public_user)
|
||||||
|
|
1
test/fixtures/users.yml
vendored
1
test/fixtures/users.yml
vendored
|
@ -75,6 +75,7 @@ moderator_user:
|
||||||
terms_agreed: "2010-01-01 11:22:33"
|
terms_agreed: "2010-01-01 11:22:33"
|
||||||
terms_seen: true
|
terms_seen: true
|
||||||
languages: en
|
languages: en
|
||||||
|
image_use_gravatar: false
|
||||||
|
|
||||||
administrator_user:
|
administrator_user:
|
||||||
id: 6
|
id: 6
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue