Settings.id_key = create(:client_application).key
Settings.potlatch2_key = create(:client_application).key
-
- stub_hostip_requests
end
##
{ :path => "/fixthemap", :method => :get },
{ :controller => "site", :action => "fixthemap" }
)
+ assert_routing(
+ { :path => "/help", :method => :get },
+ { :controller => "site", :action => "help" }
+ )
+ assert_routing(
+ { :path => "/about", :method => :get },
+ { :controller => "site", :action => "about" }
+ )
+ assert_routing(
+ { :path => "/about/locale", :method => :get },
+ { :controller => "site", :action => "about", :about_locale => "locale" }
+ )
assert_routing(
{ :path => "/export", :method => :get },
{ :controller => "site", :action => "export" }
assert_redirected_to :controller => :users, :action => :login, :referer => "/edit"
end
+ # Test the error when trying to edit without public edits
+ def test_edit_non_public
+ get :edit, :session => { :user => create(:user, :data_public => false) }
+ assert_response :success
+ assert_template "edit"
+ assert_select "a[href='https://wiki.openstreetmap.org/wiki/Disabling_anonymous_edits']"
+ end
+
# Test the right editor gets used when the user hasn't set a preference
def test_edit_without_preference
get :edit, :session => { :user => create(:user) }
assert_equal 18, assigns(:zoom)
end
+ # Test editing inaccessible nodes
+ def test_edit_with_inaccessible_nodes
+ user = create(:user)
+ deleted_node = create(:node, :lat => 1.0, :lon => 1.0, :visible => false)
+
+ get :edit, :params => { :node => 99999 }, :session => { :user => user }
+ assert_response :success
+ assert_template "edit"
+ assert_nil assigns(:lat)
+ assert_nil assigns(:lon)
+ assert_nil assigns(:zoom)
+
+ get :edit, :params => { :node => deleted_node.id }, :session => { :user => user }
+ assert_response :success
+ assert_template "edit"
+ assert_nil assigns(:lat)
+ assert_nil assigns(:lon)
+ assert_nil assigns(:zoom)
+ end
+
# Test editing a specific way
def test_edit_with_way
user = create(:user)
node = create(:node, :lat => 3, :lon => 3)
- way = create(:way)
+ way = create(:way)
create(:way_node, :node => node, :way => way)
get :edit, :params => { :way => way.id }, :session => { :user => user }
assert_equal 17, assigns(:zoom)
end
+ # Test editing inaccessible ways
+ def test_edit_with_inaccessible_ways
+ user = create(:user)
+ deleted_way = create(:way, :visible => false)
+
+ get :edit, :params => { :way => 99999 }, :session => { :user => user }
+ assert_response :success
+ assert_template "edit"
+ assert_nil assigns(:lat)
+ assert_nil assigns(:lon)
+ assert_nil assigns(:zoom)
+
+ get :edit, :params => { :way => deleted_way.id }, :session => { :user => user }
+ assert_response :success
+ assert_template "edit"
+ assert_nil assigns(:lat)
+ assert_nil assigns(:lon)
+ assert_nil assigns(:zoom)
+ end
+
# Test editing a specific note
def test_edit_with_note
user = create(:user)
assert_equal 17, assigns(:zoom)
end
+ # Test editing inaccessible notes
+ def test_edit_with_inaccessible_notes
+ user = create(:user)
+ deleted_note = create(:note, :status => "hidden") do |n|
+ n.comments.create(:author_id => user.id)
+ end
+
+ get :edit, :params => { :note => 99999 }, :session => { :user => user }
+ assert_response :success
+ assert_template "edit"
+ assert_nil assigns(:lat)
+ assert_nil assigns(:lon)
+ assert_nil assigns(:zoom)
+
+ get :edit, :params => { :note => deleted_note.id }, :session => { :user => user }
+ assert_response :success
+ assert_template "edit"
+ assert_nil assigns(:lat)
+ assert_nil assigns(:lon)
+ assert_nil assigns(:zoom)
+ end
+
# Test editing a specific GPX trace
def test_edit_with_gpx
user = create(:user)
- gpx = create(:trace, :latitude => 1, :longitude => 1)
+ gpx = create(:trace, :latitude => 1, :longitude => 1)
get :edit, :params => { :gpx => gpx.id }, :session => { :user => user }
assert_response :success
assert_equal 16, assigns(:zoom)
end
+ # Test editing inaccessible GPX traces
+ def test_edit_with_inaccessible_gpxes
+ user = create(:user)
+ deleted_gpx = create(:trace, :deleted, :latitude => 1, :longitude => 1)
+ private_gpx = create(:trace, :latitude => 1, :longitude => 1, :visibility => "private")
+
+ get :edit, :params => { :gpx => 99999 }, :session => { :user => user }
+ assert_response :success
+ assert_template "edit"
+ assert_nil assigns(:lat)
+ assert_nil assigns(:lon)
+ assert_nil assigns(:zoom)
+
+ get :edit, :params => { :gpx => deleted_gpx.id }, :session => { :user => user }
+ assert_response :success
+ assert_template "edit"
+ assert_nil assigns(:lat)
+ assert_nil assigns(:lon)
+ assert_nil assigns(:zoom)
+
+ get :edit, :params => { :gpx => private_gpx.id }, :session => { :user => user }
+ assert_response :success
+ assert_template "edit"
+ assert_nil assigns(:lat)
+ assert_nil assigns(:lon)
+ assert_nil assigns(:zoom)
+ end
+
# Test the edit page redirects
def test_edit_redirect
get :edit, :params => { :lat => 4, :lon => 5 }
get :copyright
assert_response :success
assert_template "copyright"
+ assert_select "div[lang='en'][dir='ltr']"
+
+ get :copyright, :params => { :copyright_locale => "fr" }
+ assert_response :success
+ assert_template "copyright"
+ assert_select "div[lang='fr'][dir='ltr']"
+
+ get :copyright, :params => { :copyright_locale => "ar" }
+ assert_response :success
+ assert_template "copyright"
+ assert_select "div[lang='ar'][dir='rtl']"
end
# Test the welcome page
get :about
assert_response :success
assert_template "about"
+ assert_select "div[lang='en'][dir='ltr']"
+
+ get :about, :params => { :about_locale => "fr" }
+ assert_response :success
+ assert_template "about"
+ assert_select "div[lang='fr'][dir='ltr']"
+
+ get :about, :params => { :about_locale => "ar" }
+ assert_response :success
+ assert_template "about"
+ assert_select "div[lang='ar'][dir='rtl']"
end
# Test the export page