Merge branch 'master' into next
This commit is contained in:
commit
d3700e6201
471 changed files with 490115 additions and 102173 deletions
|
@ -557,7 +557,7 @@ CHANGESET
|
|||
end
|
||||
|
||||
def test_repeated_changeset_create
|
||||
30.times do
|
||||
3.times do
|
||||
basic_authorization create(:user).email, "test"
|
||||
|
||||
# create a temporary changeset
|
||||
|
|
|
@ -335,7 +335,7 @@ class DiaryEntryControllerTest < ActionController::TestCase
|
|||
# and when not logged in as the user who wrote the entry
|
||||
get :view,
|
||||
:params => { :display_name => entry.user.display_name, :id => entry.id },
|
||||
:session => { :user => entry.user }
|
||||
:session => { :user => create(:user) }
|
||||
assert_response :success
|
||||
assert_template "diary_entry/view"
|
||||
assert_select "title", :text => /Users' diaries | /, :count => 1
|
||||
|
@ -349,9 +349,7 @@ class DiaryEntryControllerTest < ActionController::TestCase
|
|||
assert_select "p", :text => /#{new_body}/, :count => 1
|
||||
assert_select "abbr[class=geo][title='#{number_with_precision(new_latitude, :precision => 4)}; #{number_with_precision(new_longitude, :precision => 4)}']", :count => 1
|
||||
# As we're not logged in, check that you cannot edit
|
||||
assert_select "li[class='hidden show_if_user_#{entry.user.id}']", :count => 1 do
|
||||
assert_select "a[href='/user/#{ERB::Util.u(entry.user.display_name)}/diary/#{entry.id}/edit']", :text => "Edit this entry", :count => 1
|
||||
end
|
||||
assert_select "a[href='/user/#{ERB::Util.u(entry.user.display_name)}/diary/#{entry.id}/edit']", false
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,44 +1,44 @@
|
|||
require "test_helper"
|
||||
|
||||
class MessageControllerTest < ActionController::TestCase
|
||||
class MessagesControllerTest < ActionController::TestCase
|
||||
##
|
||||
# test all routes which lead to this controller
|
||||
def test_routes
|
||||
assert_routing(
|
||||
{ :path => "/user/username/inbox", :method => :get },
|
||||
{ :controller => "message", :action => "inbox", :display_name => "username" }
|
||||
{ :path => "/messages/inbox", :method => :get },
|
||||
{ :controller => "messages", :action => "inbox" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/user/username/outbox", :method => :get },
|
||||
{ :controller => "message", :action => "outbox", :display_name => "username" }
|
||||
{ :path => "/messages/outbox", :method => :get },
|
||||
{ :controller => "messages", :action => "outbox" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/message/new/username", :method => :get },
|
||||
{ :controller => "message", :action => "new", :display_name => "username" }
|
||||
{ :controller => "messages", :action => "new", :display_name => "username" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/message/new/username", :method => :post },
|
||||
{ :controller => "message", :action => "new", :display_name => "username" }
|
||||
{ :controller => "messages", :action => "new", :display_name => "username" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/message/read/1", :method => :get },
|
||||
{ :controller => "message", :action => "read", :message_id => "1" }
|
||||
{ :path => "/messages/1", :method => :get },
|
||||
{ :controller => "messages", :action => "show", :id => "1" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/message/mark/1", :method => :post },
|
||||
{ :controller => "message", :action => "mark", :message_id => "1" }
|
||||
{ :controller => "messages", :action => "mark", :message_id => "1" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/message/reply/1", :method => :get },
|
||||
{ :controller => "message", :action => "reply", :message_id => "1" }
|
||||
{ :controller => "messages", :action => "reply", :message_id => "1" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/message/reply/1", :method => :post },
|
||||
{ :controller => "message", :action => "reply", :message_id => "1" }
|
||||
{ :controller => "messages", :action => "reply", :message_id => "1" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/message/delete/1", :method => :post },
|
||||
{ :controller => "message", :action => "delete", :message_id => "1" }
|
||||
{ :controller => "messages", :action => "destroy", :message_id => "1" }
|
||||
)
|
||||
end
|
||||
|
||||
|
@ -171,13 +171,14 @@ class MessageControllerTest < ActionController::TestCase
|
|||
:message => { :title => "Test Message", :body => "Test message body" } }
|
||||
end
|
||||
end
|
||||
assert_redirected_to inbox_path(:display_name => user.display_name)
|
||||
assert_redirected_to inbox_messages_path
|
||||
assert_equal "Message sent", flash[:notice]
|
||||
e = ActionMailer::Base.deliveries.first
|
||||
assert_equal [recipient_user.email], e.to
|
||||
assert_equal "[OpenStreetMap] Test Message", e.subject
|
||||
assert_match /Test message body/, e.text_part.decoded
|
||||
assert_match /Test message body/, e.html_part.decoded
|
||||
assert_match %r{#{SERVER_URL}/messages/[0-9]+}, e.text_part.decoded
|
||||
ActionMailer::Base.deliveries.clear
|
||||
m = Message.last
|
||||
assert_equal user.id, m.from_user_id
|
||||
|
@ -264,50 +265,50 @@ class MessageControllerTest < ActionController::TestCase
|
|||
end
|
||||
|
||||
##
|
||||
# test the read action
|
||||
def test_read
|
||||
# test the show action
|
||||
def test_show
|
||||
user = create(:user)
|
||||
recipient_user = create(:user)
|
||||
other_user = create(:user)
|
||||
unread_message = create(:message, :unread, :sender => user, :recipient => recipient_user)
|
||||
|
||||
# Check that the read message page requires us to login
|
||||
get :read, :params => { :message_id => unread_message.id }
|
||||
assert_redirected_to login_path(:referer => read_message_path(:message_id => unread_message.id))
|
||||
# Check that the show message page requires us to login
|
||||
get :show, :params => { :id => unread_message.id }
|
||||
assert_redirected_to login_path(:referer => message_path(:id => unread_message.id))
|
||||
|
||||
# Login as the wrong user
|
||||
session[:user] = other_user.id
|
||||
|
||||
# Check that we can't read the message
|
||||
get :read, :params => { :message_id => unread_message.id }
|
||||
assert_redirected_to login_path(:referer => read_message_path(:message_id => unread_message.id))
|
||||
get :show, :params => { :id => unread_message.id }
|
||||
assert_redirected_to login_path(:referer => message_path(:id => unread_message.id))
|
||||
assert_equal "You are logged in as `#{other_user.display_name}' but the message you have asked to read was not sent by or to that user. Please login as the correct user in order to read it.", flash[:notice]
|
||||
|
||||
# Login as the message sender
|
||||
session[:user] = user.id
|
||||
|
||||
# Check that the message sender can read the message
|
||||
get :read, :params => { :message_id => unread_message.id }
|
||||
get :show, :params => { :id => unread_message.id }
|
||||
assert_response :success
|
||||
assert_template "read"
|
||||
assert_template "show"
|
||||
assert_equal false, Message.find(unread_message.id).message_read
|
||||
|
||||
# Login as the message recipient
|
||||
session[:user] = recipient_user.id
|
||||
|
||||
# Check that the message recipient can read the message
|
||||
get :read, :params => { :message_id => unread_message.id }
|
||||
get :show, :params => { :id => unread_message.id }
|
||||
assert_response :success
|
||||
assert_template "read"
|
||||
assert_template "show"
|
||||
assert_equal true, Message.find(unread_message.id).message_read
|
||||
|
||||
# Asking to read a message with no ID should fail
|
||||
assert_raise ActionController::UrlGenerationError do
|
||||
get :read
|
||||
get :show
|
||||
end
|
||||
|
||||
# Asking to read a message with a bogus ID should fail
|
||||
get :read, :params => { :message_id => 99999 }
|
||||
get :show, :params => { :id => 99999 }
|
||||
assert_response :not_found
|
||||
assert_template "no_such_message"
|
||||
end
|
||||
|
@ -316,55 +317,45 @@ class MessageControllerTest < ActionController::TestCase
|
|||
# test the inbox action
|
||||
def test_inbox
|
||||
user = create(:user)
|
||||
other_user = create(:user)
|
||||
read_message = create(:message, :read, :recipient => user)
|
||||
# Check that the inbox page requires us to login
|
||||
get :inbox, :params => { :display_name => user.display_name }
|
||||
assert_redirected_to login_path(:referer => inbox_path(:display_name => user.display_name))
|
||||
get :inbox
|
||||
assert_redirected_to login_path(:referer => inbox_messages_path)
|
||||
|
||||
# Login
|
||||
session[:user] = user.id
|
||||
|
||||
# Check that we can view our inbox when logged in
|
||||
get :inbox, :params => { :display_name => user.display_name }
|
||||
get :inbox
|
||||
assert_response :success
|
||||
assert_template "inbox"
|
||||
assert_select "table.messages", :count => 1 do
|
||||
assert_select "tr", :count => 2
|
||||
assert_select "tr#inbox-#{read_message.id}.inbox-row", :count => 1
|
||||
end
|
||||
|
||||
# Check that we can't view somebody else's inbox when logged in
|
||||
get :inbox, :params => { :display_name => other_user.display_name }
|
||||
assert_redirected_to inbox_path(:display_name => user.display_name)
|
||||
end
|
||||
|
||||
##
|
||||
# test the outbox action
|
||||
def test_outbox
|
||||
user = create(:user)
|
||||
other_user = create(:user)
|
||||
create(:message, :sender => user)
|
||||
|
||||
# Check that the outbox page requires us to login
|
||||
get :outbox, :params => { :display_name => user.display_name }
|
||||
assert_redirected_to login_path(:referer => outbox_path(:display_name => user.display_name))
|
||||
get :outbox
|
||||
assert_redirected_to login_path(:referer => outbox_messages_path)
|
||||
|
||||
# Login
|
||||
session[:user] = user.id
|
||||
|
||||
# Check that we can view our outbox when logged in
|
||||
get :outbox, :params => { :display_name => user.display_name }
|
||||
get :outbox
|
||||
assert_response :success
|
||||
assert_template "outbox"
|
||||
assert_select "table.messages", :count => 1 do
|
||||
assert_select "tr", :count => 2
|
||||
assert_select "tr.inbox-row", :count => 1
|
||||
end
|
||||
|
||||
# Check that we can't view somebody else's outbox when logged in
|
||||
get :outbox, :params => { :display_name => other_user.display_name }
|
||||
assert_redirected_to outbox_path(:display_name => user.display_name)
|
||||
end
|
||||
|
||||
##
|
||||
|
@ -392,12 +383,12 @@ class MessageControllerTest < ActionController::TestCase
|
|||
|
||||
# Check that the marking a message read works
|
||||
post :mark, :params => { :message_id => unread_message.id, :mark => "read" }
|
||||
assert_redirected_to inbox_path(:display_name => recipient_user.display_name)
|
||||
assert_redirected_to inbox_messages_path
|
||||
assert_equal true, Message.find(unread_message.id).message_read
|
||||
|
||||
# Check that the marking a message unread works
|
||||
post :mark, :params => { :message_id => unread_message.id, :mark => "unread" }
|
||||
assert_redirected_to inbox_path(:display_name => recipient_user.display_name)
|
||||
assert_redirected_to inbox_messages_path
|
||||
assert_equal false, Message.find(unread_message.id).message_read
|
||||
|
||||
# Check that the marking a message read via XHR works
|
||||
|
@ -424,52 +415,52 @@ class MessageControllerTest < ActionController::TestCase
|
|||
end
|
||||
|
||||
##
|
||||
# test the delete action
|
||||
def test_delete
|
||||
# test the destroy action
|
||||
def test_destroy
|
||||
user = create(:user)
|
||||
second_user = create(:user)
|
||||
other_user = create(:user)
|
||||
read_message = create(:message, :read, :recipient => user, :sender => second_user)
|
||||
sent_message = create(:message, :unread, :recipient => second_user, :sender => user)
|
||||
|
||||
# Check that the deleting a message requires us to login
|
||||
post :delete, :params => { :message_id => read_message.id }
|
||||
# Check that destroying a message requires us to login
|
||||
post :destroy, :params => { :message_id => read_message.id }
|
||||
assert_response :forbidden
|
||||
|
||||
# Login as a user with no messages
|
||||
session[:user] = other_user.id
|
||||
|
||||
# Check that deleting a message we didn't send or receive fails
|
||||
post :delete, :params => { :message_id => read_message.id }
|
||||
# Check that destroying a message we didn't send or receive fails
|
||||
post :destroy, :params => { :message_id => read_message.id }
|
||||
assert_response :not_found
|
||||
assert_template "no_such_message"
|
||||
|
||||
# Login as the message recipient_user
|
||||
session[:user] = user.id
|
||||
|
||||
# Check that the deleting a received message works
|
||||
post :delete, :params => { :message_id => read_message.id }
|
||||
assert_redirected_to inbox_path(:display_name => user.display_name)
|
||||
# Check that the destroy a received message works
|
||||
post :destroy, :params => { :message_id => read_message.id }
|
||||
assert_redirected_to inbox_messages_path
|
||||
assert_equal "Message deleted", flash[:notice]
|
||||
m = Message.find(read_message.id)
|
||||
assert_equal true, m.from_user_visible
|
||||
assert_equal false, m.to_user_visible
|
||||
|
||||
# Check that the deleting a sent message works
|
||||
post :delete, :params => { :message_id => sent_message.id, :referer => outbox_path(:display_name => user.display_name) }
|
||||
assert_redirected_to outbox_path(:display_name => user.display_name)
|
||||
# Check that the destroying a sent message works
|
||||
post :destroy, :params => { :message_id => sent_message.id, :referer => outbox_messages_path }
|
||||
assert_redirected_to outbox_messages_path
|
||||
assert_equal "Message deleted", flash[:notice]
|
||||
m = Message.find(sent_message.id)
|
||||
assert_equal false, m.from_user_visible
|
||||
assert_equal true, m.to_user_visible
|
||||
|
||||
# Asking to delete a message with no ID should fail
|
||||
# Asking to destroy a message with no ID should fail
|
||||
assert_raise ActionController::UrlGenerationError do
|
||||
post :delete
|
||||
post :destroy
|
||||
end
|
||||
|
||||
# Asking to delete a message with a bogus ID should fail
|
||||
post :delete, :params => { :message_id => 99999 }
|
||||
# Asking to destroy a message with a bogus ID should fail
|
||||
post :destroy, :params => { :message_id => 99999 }
|
||||
assert_response :not_found
|
||||
assert_template "no_such_message"
|
||||
end
|
|
@ -55,7 +55,7 @@ class OldNodeControllerTest < ActionController::TestCase
|
|||
versions[xml_node["version"]] = xml_doc.to_s
|
||||
|
||||
# randomly move the node about
|
||||
20.times do
|
||||
3.times do
|
||||
# move the node somewhere else
|
||||
xml_node["lat"] = precision(rand * 180 - 90).to_s
|
||||
xml_node["lon"] = precision(rand * 360 - 180).to_s
|
||||
|
@ -70,7 +70,7 @@ class OldNodeControllerTest < ActionController::TestCase
|
|||
end
|
||||
|
||||
# add a bunch of random tags
|
||||
30.times do
|
||||
3.times do
|
||||
xml_tag = XML::Node.new("tag")
|
||||
xml_tag["k"] = random_string
|
||||
xml_tag["v"] = random_string
|
||||
|
@ -105,7 +105,7 @@ class OldNodeControllerTest < ActionController::TestCase
|
|||
versions[xml_node["version"]] = xml_doc.to_s
|
||||
|
||||
# randomly move the node about
|
||||
20.times do
|
||||
3.times do
|
||||
# move the node somewhere else
|
||||
xml_node["lat"] = precision(rand * 180 - 90).to_s
|
||||
xml_node["lon"] = precision(rand * 360 - 180).to_s
|
||||
|
@ -120,7 +120,7 @@ class OldNodeControllerTest < ActionController::TestCase
|
|||
end
|
||||
|
||||
# add a bunch of random tags
|
||||
30.times do
|
||||
3.times do
|
||||
xml_tag = XML::Node.new("tag")
|
||||
xml_tag["k"] = random_string
|
||||
xml_tag["v"] = random_string
|
||||
|
|
|
@ -2,7 +2,7 @@ require "test_helper"
|
|||
require "digest"
|
||||
require "minitest/mock"
|
||||
|
||||
class TraceControllerTest < ActionController::TestCase
|
||||
class TracesControllerTest < ActionController::TestCase
|
||||
def setup
|
||||
@gpx_trace_dir = Object.send("remove_const", "GPX_TRACE_DIR")
|
||||
Object.const_set("GPX_TRACE_DIR", Rails.root.join("test", "gpx", "traces"))
|
||||
|
@ -27,140 +27,140 @@ class TraceControllerTest < ActionController::TestCase
|
|||
def test_routes
|
||||
assert_routing(
|
||||
{ :path => "/api/0.6/gpx/create", :method => :post },
|
||||
{ :controller => "trace", :action => "api_create" }
|
||||
{ :controller => "traces", :action => "api_create" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/api/0.6/gpx/1", :method => :get },
|
||||
{ :controller => "trace", :action => "api_read", :id => "1" }
|
||||
{ :controller => "traces", :action => "api_read", :id => "1" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/api/0.6/gpx/1", :method => :put },
|
||||
{ :controller => "trace", :action => "api_update", :id => "1" }
|
||||
{ :controller => "traces", :action => "api_update", :id => "1" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/api/0.6/gpx/1", :method => :delete },
|
||||
{ :controller => "trace", :action => "api_delete", :id => "1" }
|
||||
{ :controller => "traces", :action => "api_delete", :id => "1" }
|
||||
)
|
||||
assert_recognizes(
|
||||
{ :controller => "trace", :action => "api_read", :id => "1" },
|
||||
{ :controller => "traces", :action => "api_read", :id => "1" },
|
||||
{ :path => "/api/0.6/gpx/1/details", :method => :get }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/api/0.6/gpx/1/data", :method => :get },
|
||||
{ :controller => "trace", :action => "api_data", :id => "1" }
|
||||
{ :controller => "traces", :action => "api_data", :id => "1" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/api/0.6/gpx/1/data.xml", :method => :get },
|
||||
{ :controller => "trace", :action => "api_data", :id => "1", :format => "xml" }
|
||||
{ :controller => "traces", :action => "api_data", :id => "1", :format => "xml" }
|
||||
)
|
||||
|
||||
assert_routing(
|
||||
{ :path => "/traces", :method => :get },
|
||||
{ :controller => "trace", :action => "list" }
|
||||
{ :controller => "traces", :action => "list" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/traces/page/1", :method => :get },
|
||||
{ :controller => "trace", :action => "list", :page => "1" }
|
||||
{ :controller => "traces", :action => "list", :page => "1" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/traces/tag/tagname", :method => :get },
|
||||
{ :controller => "trace", :action => "list", :tag => "tagname" }
|
||||
{ :controller => "traces", :action => "list", :tag => "tagname" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/traces/tag/tagname/page/1", :method => :get },
|
||||
{ :controller => "trace", :action => "list", :tag => "tagname", :page => "1" }
|
||||
{ :controller => "traces", :action => "list", :tag => "tagname", :page => "1" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/user/username/traces", :method => :get },
|
||||
{ :controller => "trace", :action => "list", :display_name => "username" }
|
||||
{ :controller => "traces", :action => "list", :display_name => "username" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/user/username/traces/page/1", :method => :get },
|
||||
{ :controller => "trace", :action => "list", :display_name => "username", :page => "1" }
|
||||
{ :controller => "traces", :action => "list", :display_name => "username", :page => "1" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/user/username/traces/tag/tagname", :method => :get },
|
||||
{ :controller => "trace", :action => "list", :display_name => "username", :tag => "tagname" }
|
||||
{ :controller => "traces", :action => "list", :display_name => "username", :tag => "tagname" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/user/username/traces/tag/tagname/page/1", :method => :get },
|
||||
{ :controller => "trace", :action => "list", :display_name => "username", :tag => "tagname", :page => "1" }
|
||||
{ :controller => "traces", :action => "list", :display_name => "username", :tag => "tagname", :page => "1" }
|
||||
)
|
||||
|
||||
assert_routing(
|
||||
{ :path => "/traces/mine", :method => :get },
|
||||
{ :controller => "trace", :action => "mine" }
|
||||
{ :controller => "traces", :action => "mine" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/traces/mine/page/1", :method => :get },
|
||||
{ :controller => "trace", :action => "mine", :page => "1" }
|
||||
{ :controller => "traces", :action => "mine", :page => "1" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/traces/mine/tag/tagname", :method => :get },
|
||||
{ :controller => "trace", :action => "mine", :tag => "tagname" }
|
||||
{ :controller => "traces", :action => "mine", :tag => "tagname" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/traces/mine/tag/tagname/page/1", :method => :get },
|
||||
{ :controller => "trace", :action => "mine", :tag => "tagname", :page => "1" }
|
||||
{ :controller => "traces", :action => "mine", :tag => "tagname", :page => "1" }
|
||||
)
|
||||
|
||||
assert_routing(
|
||||
{ :path => "/traces/rss", :method => :get },
|
||||
{ :controller => "trace", :action => "georss", :format => :rss }
|
||||
{ :controller => "traces", :action => "georss", :format => :rss }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/traces/tag/tagname/rss", :method => :get },
|
||||
{ :controller => "trace", :action => "georss", :tag => "tagname", :format => :rss }
|
||||
{ :controller => "traces", :action => "georss", :tag => "tagname", :format => :rss }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/user/username/traces/rss", :method => :get },
|
||||
{ :controller => "trace", :action => "georss", :display_name => "username", :format => :rss }
|
||||
{ :controller => "traces", :action => "georss", :display_name => "username", :format => :rss }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/user/username/traces/tag/tagname/rss", :method => :get },
|
||||
{ :controller => "trace", :action => "georss", :display_name => "username", :tag => "tagname", :format => :rss }
|
||||
{ :controller => "traces", :action => "georss", :display_name => "username", :tag => "tagname", :format => :rss }
|
||||
)
|
||||
|
||||
assert_routing(
|
||||
{ :path => "/user/username/traces/1", :method => :get },
|
||||
{ :controller => "trace", :action => "view", :display_name => "username", :id => "1" }
|
||||
{ :controller => "traces", :action => "view", :display_name => "username", :id => "1" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/user/username/traces/1/picture", :method => :get },
|
||||
{ :controller => "trace", :action => "picture", :display_name => "username", :id => "1" }
|
||||
{ :controller => "traces", :action => "picture", :display_name => "username", :id => "1" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/user/username/traces/1/icon", :method => :get },
|
||||
{ :controller => "trace", :action => "icon", :display_name => "username", :id => "1" }
|
||||
{ :controller => "traces", :action => "icon", :display_name => "username", :id => "1" }
|
||||
)
|
||||
|
||||
assert_routing(
|
||||
{ :path => "/trace/create", :method => :get },
|
||||
{ :controller => "trace", :action => "create" }
|
||||
{ :path => "/traces/new", :method => :get },
|
||||
{ :controller => "traces", :action => "new" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/trace/create", :method => :post },
|
||||
{ :controller => "trace", :action => "create" }
|
||||
{ :path => "/traces", :method => :post },
|
||||
{ :controller => "traces", :action => "create" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/trace/1/data", :method => :get },
|
||||
{ :controller => "trace", :action => "data", :id => "1" }
|
||||
{ :controller => "traces", :action => "data", :id => "1" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/trace/1/data.xml", :method => :get },
|
||||
{ :controller => "trace", :action => "data", :id => "1", :format => "xml" }
|
||||
{ :controller => "traces", :action => "data", :id => "1", :format => "xml" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/trace/1/edit", :method => :get },
|
||||
{ :controller => "trace", :action => "edit", :id => "1" }
|
||||
{ :controller => "traces", :action => "edit", :id => "1" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/trace/1/edit", :method => :post },
|
||||
{ :controller => "trace", :action => "edit", :id => "1" }
|
||||
{ :controller => "traces", :action => "edit", :id => "1" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/trace/1/delete", :method => :post },
|
||||
{ :controller => "trace", :action => "delete", :id => "1" }
|
||||
{ :controller => "traces", :action => "delete", :id => "1" }
|
||||
)
|
||||
end
|
||||
|
||||
|
@ -214,7 +214,7 @@ class TraceControllerTest < ActionController::TestCase
|
|||
|
||||
# Now try when logged in
|
||||
get :mine, :session => { :user => user }
|
||||
assert_redirected_to :controller => "trace", :action => "list", :display_name => user.display_name
|
||||
assert_redirected_to :action => "list", :display_name => user.display_name
|
||||
|
||||
# Fetch the actual list
|
||||
get :list, :params => { :display_name => user.display_name }, :session => { :user => user }
|
||||
|
@ -508,34 +508,34 @@ class TraceControllerTest < ActionController::TestCase
|
|||
assert_response :not_found
|
||||
end
|
||||
|
||||
# Test fetching the create page
|
||||
def test_create_get
|
||||
# Test fetching the new trace page
|
||||
def test_new_get
|
||||
# First with no auth
|
||||
get :create
|
||||
get :new
|
||||
assert_response :redirect
|
||||
assert_redirected_to :controller => :user, :action => :login, :referer => trace_create_path
|
||||
assert_redirected_to :controller => :user, :action => :login, :referer => new_trace_path
|
||||
|
||||
# Now authenticated as a user with gps.trace.visibility set
|
||||
user = create(:user)
|
||||
create(:user_preference, :user => user, :k => "gps.trace.visibility", :v => "identifiable")
|
||||
get :create, :session => { :user => user }
|
||||
get :new, :session => { :user => user }
|
||||
assert_response :success
|
||||
assert_template :create
|
||||
assert_template :new
|
||||
assert_select "select#trace_visibility option[value=identifiable][selected]", 1
|
||||
|
||||
# Now authenticated as a user with gps.trace.public set
|
||||
second_user = create(:user)
|
||||
create(:user_preference, :user => second_user, :k => "gps.trace.public", :v => "default")
|
||||
get :create, :session => { :user => second_user }
|
||||
get :new, :session => { :user => second_user }
|
||||
assert_response :success
|
||||
assert_template :create
|
||||
assert_template :new
|
||||
assert_select "select#trace_visibility option[value=public][selected]", 1
|
||||
|
||||
# Now authenticated as a user with no preferences
|
||||
third_user = create(:user)
|
||||
get :create, :session => { :user => third_user }
|
||||
get :new, :session => { :user => third_user }
|
||||
assert_response :success
|
||||
assert_template :create
|
||||
assert_template :new
|
||||
assert_select "select#trace_visibility option[value=private][selected]", 1
|
||||
end
|
||||
|
|
@ -567,7 +567,7 @@ class UserControllerTest < ActionController::TestCase
|
|||
stub_gravatar_request(user.new_email, 200)
|
||||
confirm_string = user.tokens.create.token
|
||||
# precondition gravatar should be turned off
|
||||
assert !user.image_use_gravatar
|
||||
assert_not user.image_use_gravatar
|
||||
post :confirm_email, :params => { :confirm_string => confirm_string }
|
||||
assert_response :redirect
|
||||
assert_redirected_to :action => :account, :display_name => user.display_name
|
||||
|
@ -588,7 +588,7 @@ class UserControllerTest < ActionController::TestCase
|
|||
assert_redirected_to :action => :account, :display_name => user.display_name
|
||||
assert_match /Confirmed your change of email address/, flash[:notice]
|
||||
# gravatar use should now be disabled
|
||||
assert !User.find(user.id).image_use_gravatar
|
||||
assert_not User.find(user.id).image_use_gravatar
|
||||
end
|
||||
|
||||
def test_terms_new_user
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
require "test_helper"
|
||||
|
||||
class UserPreferenceControllerTest < ActionController::TestCase
|
||||
class UserPreferencesControllerTest < ActionController::TestCase
|
||||
##
|
||||
# test all routes which lead to this controller
|
||||
def test_routes
|
||||
assert_routing(
|
||||
{ :path => "/api/0.6/user/preferences", :method => :get },
|
||||
{ :controller => "user_preference", :action => "read" }
|
||||
{ :controller => "user_preferences", :action => "read" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/api/0.6/user/preferences", :method => :put },
|
||||
{ :controller => "user_preference", :action => "update" }
|
||||
{ :controller => "user_preferences", :action => "update" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/api/0.6/user/preferences/key", :method => :get },
|
||||
{ :controller => "user_preference", :action => "read_one", :preference_key => "key" }
|
||||
{ :controller => "user_preferences", :action => "read_one", :preference_key => "key" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/api/0.6/user/preferences/key", :method => :put },
|
||||
{ :controller => "user_preference", :action => "update_one", :preference_key => "key" }
|
||||
{ :controller => "user_preferences", :action => "update_one", :preference_key => "key" }
|
||||
)
|
||||
assert_routing(
|
||||
{ :path => "/api/0.6/user/preferences/key", :method => :delete },
|
||||
{ :controller => "user_preference", :action => "delete_one", :preference_key => "key" }
|
||||
{ :controller => "user_preferences", :action => "delete_one", :preference_key => "key" }
|
||||
)
|
||||
end
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue