get "/note/new" => "browse#new_note"
get "/user/:display_name/history" => "changesets#index"
get "/user/:display_name/history/feed" => "changesets#feed", :defaults => { :format => :atom }
- get "/user/:display_name/notes" => "notes#mine"
+ get "/user/:display_name/notes" => "notes#mine", :as => :my_notes
get "/history/friends" => "changesets#index", :friends => true, :as => "friend_changesets", :defaults => { :format => :html }
get "/history/nearby" => "changesets#index", :nearby => true, :as => "nearby_changesets", :defaults => { :format => :html }
require "test_helper"
-class NotesControllerTest < ActionController::TestCase
+class NotesControllerTest < ActionDispatch::IntegrationTest
def setup
super
# Stub nominatim response for note locations
end
# Note that the table rows include a header row
- get :mine, :params => { :display_name => first_user.display_name }
+ get my_notes_path(:display_name => first_user.display_name)
assert_response :success
assert_select "table.note_list tr", :count => 2
- get :mine, :params => { :display_name => second_user.display_name }
+ get my_notes_path(:display_name => second_user.display_name)
assert_response :success
assert_select "table.note_list tr", :count => 2
- get :mine, :params => { :display_name => "non-existent" }
+ get my_notes_path(:display_name => "non-existent")
assert_response :not_found
- session[:user] = moderator_user.id
+ session_for(moderator_user)
- get :mine, :params => { :display_name => first_user.display_name }
+ get my_notes_path(:display_name => first_user.display_name)
assert_response :success
assert_select "table.note_list tr", :count => 2
- get :mine, :params => { :display_name => second_user.display_name }
+ get my_notes_path(:display_name => second_user.display_name)
assert_response :success
assert_select "table.note_list tr", :count => 3
- get :mine, :params => { :display_name => "non-existent" }
+ get my_notes_path(:display_name => "non-existent")
assert_response :not_found
end
create(:note_comment, :note => note, :author => user)
end
- get :mine, :params => { :display_name => user.display_name }
+ get my_notes_path(:display_name => user.display_name)
assert_response :success
assert_select "table.note_list tr", :count => 11
- get :mine, :params => { :display_name => user.display_name, :page => 2 }
+ get my_notes_path(:display_name => user.display_name, :page => 2)
assert_response :success
assert_select "table.note_list tr", :count => 11
end
require "test_helper"
-class OauthClientsControllerTest < ActionController::TestCase
+class OauthClientsControllerTest < ActionDispatch::IntegrationTest
##
# test all routes which lead to this controller
def test_routes
create_list(:client_application, 2, :user => user)
create_list(:access_token, 2, :user => user)
- get :index,
- :params => { :display_name => user.display_name }
+ get oauth_clients_path(:display_name => user.display_name)
assert_response :redirect
assert_redirected_to login_path(:referer => oauth_clients_path(:display_name => user.display_name))
- get :index,
- :params => { :display_name => user.display_name },
- :session => { :user => user }
+ session_for(user)
+
+ get oauth_clients_path(:display_name => user.display_name)
assert_response :success
assert_template "index"
assert_select "div.client_application", 2
def test_new
user = create(:user)
- get :new,
- :params => { :display_name => user.display_name }
+ get new_oauth_client_path(:display_name => user.display_name)
assert_response :redirect
assert_redirected_to login_path(:referer => new_oauth_client_path(:display_name => user.display_name))
- get :new,
- :params => { :display_name => user.display_name },
- :session => { :user => user }
+ session_for(user)
+
+ get new_oauth_client_path(:display_name => user.display_name)
assert_response :success
assert_template "new"
assert_select "form", 1 do
user = create(:user)
assert_difference "ClientApplication.count", 0 do
- post :create, :params => { :display_name => user.display_name }
+ post oauth_clients_path(:display_name => user.display_name)
end
assert_response :forbidden
+ session_for(user)
+
assert_difference "ClientApplication.count", 0 do
- post :create,
- :params => { :display_name => user.display_name,
- :client_application => { :name => "Test Application" } },
- :session => { :user => user }
+ post oauth_clients_path(:display_name => user.display_name,
+ :client_application => { :name => "Test Application" })
end
assert_response :success
assert_template "new"
assert_difference "ClientApplication.count", 1 do
- post :create,
- :params => { :display_name => user.display_name,
- :client_application => { :name => "Test Application",
- :url => "http://test.example.com/" } },
- :session => { :user => user }
+ post oauth_clients_path(:display_name => user.display_name,
+ :client_application => { :name => "Test Application",
+ :url => "http://test.example.com/" })
end
assert_response :redirect
assert_redirected_to oauth_client_path(:id => ClientApplication.find_by(:name => "Test Application").id)
client = create(:client_application, :user => user)
other_client = create(:client_application)
- get :show,
- :params => { :display_name => user.display_name, :id => client.id }
+ get oauth_client_path(:display_name => user.display_name, :id => client)
assert_response :redirect
assert_redirected_to login_path(:referer => oauth_client_path(:display_name => user.display_name, :id => client.id))
- get :show,
- :params => { :display_name => user.display_name, :id => other_client.id },
- :session => { :user => user }
+ session_for(user)
+
+ get oauth_client_path(:display_name => user.display_name, :id => other_client)
assert_response :not_found
assert_template "not_found"
- get :show,
- :params => { :display_name => user.display_name, :id => client.id },
- :session => { :user => user }
+ get oauth_client_path(:display_name => user.display_name, :id => client)
assert_response :success
assert_template "show"
end
client = create(:client_application, :user => user)
other_client = create(:client_application)
- get :edit,
- :params => { :display_name => user.display_name, :id => client.id }
+ get edit_oauth_client_path(:display_name => user.display_name, :id => client)
assert_response :redirect
assert_redirected_to login_path(:referer => edit_oauth_client_path(:display_name => user.display_name, :id => client.id))
- get :edit,
- :params => { :display_name => user.display_name, :id => other_client.id },
- :session => { :user => user }
+ session_for(user)
+
+ get edit_oauth_client_path(:display_name => user.display_name, :id => other_client)
assert_response :not_found
assert_template "not_found"
- get :edit,
- :params => { :display_name => user.display_name, :id => client.id },
- :session => { :user => user }
+ get edit_oauth_client_path(:display_name => user.display_name, :id => client)
assert_response :success
assert_template "edit"
assert_select "form", 1 do
client = create(:client_application, :user => user)
other_client = create(:client_application)
- put :update,
- :params => { :display_name => user.display_name, :id => client.id }
+ put oauth_client_path(:display_name => user.display_name, :id => client)
assert_response :forbidden
- put :update,
- :params => { :display_name => user.display_name, :id => other_client.id },
- :session => { :user => user }
+ session_for(user)
+
+ put oauth_client_path(:display_name => user.display_name, :id => other_client)
assert_response :not_found
assert_template "not_found"
- put :update,
- :params => { :display_name => user.display_name,
- :id => client.id,
- :client_application => { :name => "New Name", :url => nil } },
- :session => { :user => user }
+ put oauth_client_path(:display_name => user.display_name, :id => client,
+ :client_application => { :name => "New Name", :url => nil })
assert_response :success
assert_template "edit"
- put :update,
- :params => { :display_name => user.display_name,
- :id => client.id,
- :client_application => { :name => "New Name", :url => "http://new.example.com/url" } },
- :session => { :user => user }
+ put oauth_client_path(:display_name => user.display_name, :id => client,
+ :client_application => { :name => "New Name", :url => "http://new.example.com/url" })
assert_response :redirect
assert_redirected_to oauth_client_path(:id => client.id)
end
other_client = create(:client_application)
assert_difference "ClientApplication.count", 0 do
- delete :destroy,
- :params => { :display_name => user.display_name, :id => client.id }
+ delete oauth_client_path(:display_name => user.display_name, :id => client)
end
assert_response :forbidden
+ session_for(user)
+
assert_difference "ClientApplication.count", 0 do
- delete :destroy,
- :params => { :display_name => user.display_name, :id => other_client.id },
- :session => { :user => user }
+ delete oauth_client_path(:display_name => user.display_name, :id => other_client)
end
assert_response :not_found
assert_template "not_found"
assert_difference "ClientApplication.count", -1 do
- delete :destroy,
- :params => { :display_name => user.display_name, :id => client.id },
- :session => { :user => user }
+ delete oauth_client_path(:display_name => user.display_name, :id => client)
end
assert_response :redirect
assert_redirected_to oauth_clients_path(:display_name => user.display_name)
require "test_helper"
-class OauthControllerTest < ActionController::TestCase
+class OauthControllerTest < ActionDispatch::IntegrationTest
##
# test all routes which lead to this controller
def test_routes
require "test_helper"
-class RedactionsControllerTest < ActionController::TestCase
+class RedactionsControllerTest < ActionDispatch::IntegrationTest
##
# test all routes which lead to this controller
def test_routes
def test_index
create(:redaction)
- get :index
+ get redactions_path
assert_response :success
assert_template :index
assert_select "ul#redaction_list", 1 do
end
def test_new
- get :new
+ get new_redaction_path
assert_response :redirect
assert_redirected_to login_path(:referer => new_redaction_path)
end
def test_new_moderator
- session[:user] = create(:moderator_user).id
+ session_for(create(:moderator_user))
- get :new
+ get new_redaction_path
assert_response :success
assert_template :new
end
def test_new_non_moderator
- session[:user] = create(:user).id
+ session_for(create(:user))
- get :new
+ get new_redaction_path
assert_response :redirect
assert_redirected_to :controller => "errors", :action => "forbidden"
end
def test_create_moderator
- session[:user] = create(:moderator_user).id
+ session_for(create(:moderator_user))
- post :create, :params => { :redaction => { :title => "Foo", :description => "Description here." } }
+ post redactions_path(:redaction => { :title => "Foo", :description => "Description here." })
assert_response :redirect
assert_redirected_to(redaction_path(Redaction.find_by(:title => "Foo")))
end
def test_create_moderator_invalid
- session[:user] = create(:moderator_user).id
+ session_for(create(:moderator_user))
- post :create, :params => { :redaction => { :title => "Foo", :description => "" } }
+ post redactions_path(:redaction => { :title => "Foo", :description => "" })
assert_response :success
assert_template :new
end
def test_create_non_moderator
- session[:user] = create(:user).id
+ session_for(create(:user))
- post :create, :params => { :redaction => { :title => "Foo", :description => "Description here." } }
+ post redactions_path(:redaction => { :title => "Foo", :description => "Description here." })
assert_response :redirect
assert_redirected_to :controller => "errors", :action => "forbidden"
end
def test_destroy_moderator_empty
- session[:user] = create(:moderator_user).id
+ session_for(create(:moderator_user))
# create an empty redaction
redaction = create(:redaction)
- delete :destroy, :params => { :id => redaction.id }
+ delete redaction_path(:id => redaction)
assert_response :redirect
assert_redirected_to(redactions_path)
end
def test_destroy_moderator_non_empty
- session[:user] = create(:moderator_user).id
+ session_for(create(:moderator_user))
# create elements in the redaction
redaction = create(:redaction)
create(:old_node, :redaction => redaction)
- delete :destroy, :params => { :id => redaction.id }
+ delete redaction_path(:id => redaction)
assert_response :redirect
assert_redirected_to(redaction_path(redaction))
assert_match(/^Redaction is not empty/, flash[:error])
end
def test_delete_non_moderator
- session[:user] = create(:user).id
+ session_for(create(:user))
- delete :destroy, :params => { :id => create(:redaction).id }
+ delete redaction_path(:id => create(:redaction))
assert_response :redirect
assert_redirected_to :controller => "errors", :action => "forbidden"
end
def test_edit
redaction = create(:redaction)
- get :edit, :params => { :id => redaction.id }
+ get edit_redaction_path(:id => redaction)
assert_response :redirect
assert_redirected_to login_path(:referer => edit_redaction_path(redaction))
end
def test_edit_moderator
- session[:user] = create(:moderator_user).id
+ session_for(create(:moderator_user))
- get :edit, :params => { :id => create(:redaction).id }
+ get edit_redaction_path(:id => create(:redaction))
assert_response :success
end
def test_edit_non_moderator
- session[:user] = create(:user).id
+ session_for(create(:user))
- get :edit, :params => { :id => create(:redaction).id }
+ get edit_redaction_path(:id => create(:redaction))
assert_response :redirect
assert_redirected_to :controller => "errors", :action => "forbidden"
end
def test_update_moderator
- session[:user] = create(:moderator_user).id
+ session_for(create(:moderator_user))
redaction = create(:redaction)
- put :update, :params => { :id => redaction.id, :redaction => { :title => "Foo", :description => "Description here." } }
+ put redaction_path(:id => redaction, :redaction => { :title => "Foo", :description => "Description here." })
assert_response :redirect
assert_redirected_to(redaction_path(redaction))
end
def test_update_moderator_invalid
- session[:user] = create(:moderator_user).id
+ session_for(create(:moderator_user))
redaction = create(:redaction)
- put :update, :params => { :id => redaction.id, :redaction => { :title => "Foo", :description => "" } }
+ put redaction_path(:id => redaction, :redaction => { :title => "Foo", :description => "" })
assert_response :success
assert_template :edit
end
def test_updated_non_moderator
- session[:user] = create(:user).id
+ session_for(create(:user))
redaction = create(:redaction)
- put :update, :params => { :id => redaction.id, :redaction => { :title => "Foo", :description => "Description here." } }
+ put redaction_path(:id => redaction, :redaction => { :title => "Foo", :description => "Description here." })
assert_response :redirect
assert_redirected_to :controller => "errors", :action => "forbidden"
end
require "test_helper"
-class ReportsControllerTest < ActionController::TestCase
+class ReportsControllerTest < ActionDispatch::IntegrationTest
def test_new_report_without_login
target_user = create(:user)
- get :new, :params => { :reportable_id => target_user.id, :reportable_type => "User" }
+ get new_report_path(:reportable_id => target_user.id, :reportable_type => "User")
assert_response :redirect
assert_redirected_to login_path(:referer => new_report_path(:reportable_id => target_user.id, :reportable_type => "User"))
end
def test_new_report_after_login
target_user = create(:user)
- session[:user] = create(:user).id
+ session_for(create(:user))
# Create an Issue and a report
- get :new, :params => { :reportable_id => target_user.id, :reportable_type => "User" }
+ get new_report_path(:reportable_id => target_user.id, :reportable_type => "User")
assert_response :success
assert_difference "Issue.count", 1 do
details = "Details of a report"
category = "other"
- post :create,
- :params => {
- :report => {
- :details => details,
- :category => category,
- :issue => { :reportable_id => target_user.id, :reportable_type => "User" }
- }
- }
+ post reports_path(:report => {
+ :details => details,
+ :category => category,
+ :issue => { :reportable_id => target_user.id, :reportable_type => "User" }
+ })
end
assert_response :redirect
assert_redirected_to user_path(target_user)
target_user = create(:user)
# Login
- session[:user] = create(:user).id
+ session_for(create(:user))
# Create an Issue and a report
- get :new, :params => { :reportable_id => target_user.id, :reportable_type => "User" }
+ get new_report_path(:reportable_id => target_user.id, :reportable_type => "User")
assert_response :success
assert_difference "Issue.count", 1 do
details = "Details of a report"
category = "other"
- post :create,
- :params => {
- :report => {
- :details => details,
- :category => category,
- :issue => { :reportable_id => target_user.id, :reportable_type => "User" }
- }
- }
+ post reports_path(:report => {
+ :details => details,
+ :category => category,
+ :issue => { :reportable_id => target_user.id, :reportable_type => "User" }
+ })
end
assert_response :redirect
assert_redirected_to user_path(target_user)
assert_equal 1, issue.reports.count
- get :new, :params => { :reportable_id => target_user.id, :reportable_type => "User" }
+ get new_report_path(:reportable_id => target_user.id, :reportable_type => "User")
assert_response :success
# Report without details
assert_no_difference "Issue.count" do
category = "other"
- post :create,
- :params => {
- :report => {
- :category => category,
- :issue => { :reportable_id => 1, :reportable_type => "User" }
- }
- }
+ post reports_path(:report => {
+ :category => category,
+ :issue => { :reportable_id => 1, :reportable_type => "User" }
+ })
end
assert_response :redirect
target_user = create(:user)
# Login
- session[:user] = create(:user).id
+ session_for(create(:user))
# Create an Issue and a report
- get :new, :params => { :reportable_id => target_user.id, :reportable_type => "User" }
+ get new_report_path(:reportable_id => target_user.id, :reportable_type => "User")
assert_response :success
assert_difference "Issue.count", 1 do
details = "Details of a report"
category = "other"
- post :create,
- :params => {
- :report => {
- :details => details,
- :category => category,
- :issue => { :reportable_id => target_user.id, :reportable_type => "User" }
- }
- }
+ post reports_path(:report => {
+ :details => details,
+ :category => category,
+ :issue => { :reportable_id => target_user.id, :reportable_type => "User" }
+ })
end
assert_response :redirect
assert_redirected_to user_path(target_user)
assert_equal 1, issue.reports.count
# Create a report for an existing Issue
- get :new, :params => { :reportable_id => target_user.id, :reportable_type => "User" }
+ get new_report_path(:reportable_id => target_user.id, :reportable_type => "User")
assert_response :success
assert_no_difference "Issue.count" do
details = "Details of another report under the same issue"
category = "other"
- post :create,
- :params => {
- :report => {
- :details => details,
- :category => category,
- :issue => { :reportable_id => target_user.id, :reportable_type => "User" }
- }
- }
+ post reports_path(:report => {
+ :details => details,
+ :category => category,
+ :issue => { :reportable_id => target_user.id, :reportable_type => "User" }
+ })
end
assert_response :redirect