Merge branch 'master' into next
This commit is contained in:
commit
d3700e6201
471 changed files with 490115 additions and 102173 deletions
|
@ -3,6 +3,11 @@ require "capybara/poltergeist"
|
|||
|
||||
WebMock.disable_net_connect!(:allow_localhost => true)
|
||||
|
||||
# Work around weird debian/ubuntu phantomjs
|
||||
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=817277
|
||||
# https://github.com/ariya/phantomjs/issues/14376
|
||||
ENV["QT_QPA_PLATFORM"] = "phantom" if IO.popen(["phantomjs", "--version"], :err => :close).read.empty?
|
||||
|
||||
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
|
||||
ActionDispatch::SystemTesting::Server.silence_puma = true
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
@ -47,108 +47,6 @@ class ApplicationHelperTest < ActionView::TestCase
|
|||
assert_dom_equal "<a class=\"rsssmall\" href=\"/history/feed\"><img alt=\"Rss\" border=\"0\" height=\"16\" src=\"/images/RSS.png\" width=\"16\" /></a>", link
|
||||
end
|
||||
|
||||
def test_style_rules
|
||||
self.current_user = nil
|
||||
|
||||
css = style_rules
|
||||
assert_match /\.hidden /, css
|
||||
assert_match /\.hide_unless_logged_in /, css
|
||||
assert_no_match /\.hide_if_logged_in /, css
|
||||
assert_no_match /\.hide_if_user_/, css
|
||||
assert_no_match /\.show_if_user_/, css
|
||||
assert_match /\.hide_unless_administrator /, css
|
||||
assert_match /\.hide_unless_moderator /, css
|
||||
|
||||
self.current_user = create(:user)
|
||||
|
||||
css = style_rules
|
||||
assert_match /\.hidden /, css
|
||||
assert_no_match /\.hide_unless_logged_in /, css
|
||||
assert_match /\.hide_if_logged_in /, css
|
||||
assert_match /\.hide_if_user_#{current_user.id} /, css
|
||||
assert_match /\.show_if_user_#{current_user.id} /, css
|
||||
assert_match /\.hide_unless_administrator /, css
|
||||
assert_match /\.hide_unless_moderator /, css
|
||||
|
||||
self.current_user = create(:moderator_user)
|
||||
|
||||
css = style_rules
|
||||
assert_match /\.hidden /, css
|
||||
assert_no_match /\.hide_unless_logged_in /, css
|
||||
assert_match /\.hide_if_logged_in /, css
|
||||
assert_match /\.hide_if_user_#{current_user.id} /, css
|
||||
assert_match /\.show_if_user_#{current_user.id} /, css
|
||||
assert_match /\.hide_unless_administrator /, css
|
||||
assert_no_match /\.hide_unless_moderator /, css
|
||||
|
||||
self.current_user = create(:administrator_user)
|
||||
|
||||
css = style_rules
|
||||
assert_match /\.hidden /, css
|
||||
assert_no_match /\.hide_unless_logged_in /, css
|
||||
assert_match /\.hide_if_logged_in /, css
|
||||
assert_match /\.hide_if_user_#{current_user.id} /, css
|
||||
assert_match /\.show_if_user_#{current_user.id} /, css
|
||||
assert_no_match /\.hide_unless_administrator /, css
|
||||
assert_match /\.hide_unless_moderator /, css
|
||||
end
|
||||
|
||||
def test_if_logged_in
|
||||
html = if_logged_in { "Test 1" }
|
||||
assert_dom_equal "<div class=\"hide_unless_logged_in\">Test 1</div>", html
|
||||
|
||||
html = if_logged_in(:span) { "Test 2" }
|
||||
assert_dom_equal "<span class=\"hide_unless_logged_in\">Test 2</span>", html
|
||||
end
|
||||
|
||||
def test_if_not_logged_in
|
||||
html = if_not_logged_in { "Test 1" }
|
||||
assert_dom_equal "<div class=\"hide_if_logged_in\">Test 1</div>", html
|
||||
|
||||
html = if_not_logged_in(:span) { "Test 2" }
|
||||
assert_dom_equal "<span class=\"hide_if_logged_in\">Test 2</span>", html
|
||||
end
|
||||
|
||||
def test_if_user
|
||||
user = create(:user)
|
||||
|
||||
html = if_user(user) { "Test 1" }
|
||||
assert_dom_equal "<div class=\"hidden show_if_user_#{user.id}\">Test 1</div>", html
|
||||
|
||||
html = if_user(user, :span) { "Test 2" }
|
||||
assert_dom_equal "<span class=\"hidden show_if_user_#{user.id}\">Test 2</span>", html
|
||||
|
||||
html = if_user(nil) { "Test 3" }
|
||||
assert_nil html
|
||||
|
||||
html = if_user(nil, :span) { "Test 4" }
|
||||
assert_nil html
|
||||
end
|
||||
|
||||
def test_unless_user
|
||||
user = create(:user)
|
||||
|
||||
html = unless_user(user) { "Test 1" }
|
||||
assert_dom_equal "<div class=\"hide_if_user_#{user.id}\">Test 1</div>", html
|
||||
|
||||
html = unless_user(user, :span) { "Test 2" }
|
||||
assert_dom_equal "<span class=\"hide_if_user_#{user.id}\">Test 2</span>", html
|
||||
|
||||
html = unless_user(nil) { "Test 3" }
|
||||
assert_dom_equal "<div>Test 3</div>", html
|
||||
|
||||
html = unless_user(nil, :span) { "Test 4" }
|
||||
assert_dom_equal "<span>Test 4</span>", html
|
||||
end
|
||||
|
||||
def test_if_administrator
|
||||
html = if_administrator { "Test 1" }
|
||||
assert_dom_equal "<div class=\"hide_unless_administrator\">Test 1</div>", html
|
||||
|
||||
html = if_administrator(:span) { "Test 2" }
|
||||
assert_dom_equal "<span class=\"hide_unless_administrator\">Test 2</span>", html
|
||||
end
|
||||
|
||||
def test_richtext_area
|
||||
html = richtext_area(:message, :body, :cols => 40, :rows => 20)
|
||||
assert_not_nil html
|
||||
|
|
|
@ -127,13 +127,13 @@ class BrowseHelperTest < ActionView::TestCase
|
|||
assert_dom_equal "<a title=\"The Test article on Wikipedia\" href=\"https://en.wikipedia.org/wiki/Test?uselang=en\">Test</a>", html
|
||||
|
||||
html = format_value("wikidata", "Q42")
|
||||
assert_dom_equal "<a title=\"The Q42 item on Wikidata\" href=\"//www.wikidata.org/wiki/Q42?uselang=en\">Q42</a>", html
|
||||
assert_dom_equal "<a title=\"The Q42 item on Wikidata\" href=\"//www.wikidata.org/entity/Q42?uselang=en\">Q42</a>", html
|
||||
|
||||
html = format_value("operator:wikidata", "Q12;Q98")
|
||||
assert_dom_equal "<a title=\"The Q12 item on Wikidata\" href=\"//www.wikidata.org/wiki/Q12?uselang=en\">Q12</a>;<a title=\"The Q98 item on Wikidata\" href=\"//www.wikidata.org/wiki/Q98?uselang=en\">Q98</a>", html
|
||||
assert_dom_equal "<a title=\"The Q12 item on Wikidata\" href=\"//www.wikidata.org/entity/Q12?uselang=en\">Q12</a>;<a title=\"The Q98 item on Wikidata\" href=\"//www.wikidata.org/entity/Q98?uselang=en\">Q98</a>", html
|
||||
|
||||
html = format_value("name:etymology:wikidata", "Q123")
|
||||
assert_dom_equal "<a title=\"The Q123 item on Wikidata\" href=\"//www.wikidata.org/wiki/Q123?uselang=en\">Q123</a>", html
|
||||
assert_dom_equal "<a title=\"The Q123 item on Wikidata\" href=\"//www.wikidata.org/entity/Q123?uselang=en\">Q123</a>", html
|
||||
end
|
||||
|
||||
def test_icon_tags
|
||||
|
@ -198,7 +198,7 @@ class BrowseHelperTest < ActionView::TestCase
|
|||
assert_nil links
|
||||
|
||||
# No URLs allowed
|
||||
links = wikidata_links("wikidata", "http://www.wikidata.org/wiki/Q1")
|
||||
links = wikidata_links("wikidata", "http://www.wikidata.org/entity/Q1")
|
||||
assert_nil links
|
||||
|
||||
# No language-prefixes (as wikidata is multilanguage)
|
||||
|
@ -216,14 +216,14 @@ class BrowseHelperTest < ActionView::TestCase
|
|||
# A valid value
|
||||
links = wikidata_links("wikidata", "Q42")
|
||||
assert_equal 1, links.length
|
||||
assert_equal "//www.wikidata.org/wiki/Q42?uselang=en", links[0][:url]
|
||||
assert_equal "//www.wikidata.org/entity/Q42?uselang=en", links[0][:url]
|
||||
assert_equal "Q42", links[0][:title]
|
||||
|
||||
# the language of the wikidata-page should match the current locale
|
||||
I18n.locale = "zh-CN"
|
||||
links = wikidata_links("wikidata", "Q1234")
|
||||
assert_equal 1, links.length
|
||||
assert_equal "//www.wikidata.org/wiki/Q1234?uselang=zh-CN", links[0][:url]
|
||||
assert_equal "//www.wikidata.org/entity/Q1234?uselang=zh-CN", links[0][:url]
|
||||
assert_equal "Q1234", links[0][:title]
|
||||
I18n.locale = "en"
|
||||
|
||||
|
@ -235,31 +235,31 @@ class BrowseHelperTest < ActionView::TestCase
|
|||
|
||||
# This for example is an allowed key
|
||||
links = wikidata_links("operator:wikidata", "Q24")
|
||||
assert_equal "//www.wikidata.org/wiki/Q24?uselang=en", links[0][:url]
|
||||
assert_equal "//www.wikidata.org/entity/Q24?uselang=en", links[0][:url]
|
||||
assert_equal "Q24", links[0][:title]
|
||||
|
||||
# Another allowed key, this time with multiple values and I18n
|
||||
I18n.locale = "dsb"
|
||||
links = wikidata_links("brand:wikidata", "Q936;Q2013;Q1568346")
|
||||
assert_equal 3, links.length
|
||||
assert_equal "//www.wikidata.org/wiki/Q936?uselang=dsb", links[0][:url]
|
||||
assert_equal "//www.wikidata.org/entity/Q936?uselang=dsb", links[0][:url]
|
||||
assert_equal "Q936", links[0][:title]
|
||||
assert_equal "//www.wikidata.org/wiki/Q2013?uselang=dsb", links[1][:url]
|
||||
assert_equal "//www.wikidata.org/entity/Q2013?uselang=dsb", links[1][:url]
|
||||
assert_equal "Q2013", links[1][:title]
|
||||
assert_equal "//www.wikidata.org/wiki/Q1568346?uselang=dsb", links[2][:url]
|
||||
assert_equal "//www.wikidata.org/entity/Q1568346?uselang=dsb", links[2][:url]
|
||||
assert_equal "Q1568346", links[2][:title]
|
||||
I18n.locale = "en"
|
||||
|
||||
# and now with whitespaces...
|
||||
links = wikidata_links("subject:wikidata", "Q6542248 ;\tQ180\n ;\rQ364\t\n\r ;\nQ4006")
|
||||
assert_equal 4, links.length
|
||||
assert_equal "//www.wikidata.org/wiki/Q6542248?uselang=en", links[0][:url]
|
||||
assert_equal "//www.wikidata.org/entity/Q6542248?uselang=en", links[0][:url]
|
||||
assert_equal "Q6542248 ", links[0][:title]
|
||||
assert_equal "//www.wikidata.org/wiki/Q180?uselang=en", links[1][:url]
|
||||
assert_equal "//www.wikidata.org/entity/Q180?uselang=en", links[1][:url]
|
||||
assert_equal "\tQ180\n ", links[1][:title]
|
||||
assert_equal "//www.wikidata.org/wiki/Q364?uselang=en", links[2][:url]
|
||||
assert_equal "//www.wikidata.org/entity/Q364?uselang=en", links[2][:url]
|
||||
assert_equal "\rQ364\t\n\r ", links[2][:title]
|
||||
assert_equal "//www.wikidata.org/wiki/Q4006?uselang=en", links[3][:url]
|
||||
assert_equal "//www.wikidata.org/entity/Q4006?uselang=en", links[3][:url]
|
||||
assert_equal "\nQ4006", links[3][:title]
|
||||
end
|
||||
|
||||
|
|
|
@ -12,7 +12,9 @@ class UserChangesetCommentsTest < ActionDispatch::IntegrationTest
|
|||
assert_select "div#sidebar" do
|
||||
assert_select "div#sidebar_content" do
|
||||
assert_select "div.browse-section" do
|
||||
assert_select "div.notice.hide_if_logged_in"
|
||||
assert_select "div.notice" do
|
||||
assert_select "a[href='/login?referer=%2Fchangeset%2F#{changeset.id}']", :text => I18n.t("browse.changeset.join_discussion"), :count => 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -44,7 +44,7 @@ class UserTermsSeenTest < ActionDispatch::IntegrationTest
|
|||
|
||||
# should be carried through to a normal login with a message
|
||||
assert_response :success
|
||||
assert !flash[:notice].nil?
|
||||
assert_not flash[:notice].nil?
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -5,17 +5,17 @@ class AclTest < ActiveSupport::TestCase
|
|||
acl = create(:acl)
|
||||
assert acl.valid?
|
||||
acl.k = nil
|
||||
assert !acl.valid?
|
||||
assert_not acl.valid?
|
||||
end
|
||||
|
||||
def test_no_account_creation_by_subnet
|
||||
assert !Acl.no_account_creation("192.168.1.1")
|
||||
assert_not Acl.no_account_creation("192.168.1.1")
|
||||
create(:acl, :address => "192.168.0.0/16", :k => "no_account_creation")
|
||||
assert Acl.no_account_creation("192.168.1.1")
|
||||
end
|
||||
|
||||
def test_no_account_creation_by_domain
|
||||
assert !Acl.no_account_creation("192.168.1.1", "example.com")
|
||||
assert_not Acl.no_account_creation("192.168.1.1", "example.com")
|
||||
create(:acl, :domain => "example.com", :k => "no_account_creation")
|
||||
assert Acl.no_account_creation("192.168.1.1", "example.com")
|
||||
end
|
||||
|
|
|
@ -6,27 +6,27 @@ class ChangesetCommentTest < ActiveSupport::TestCase
|
|||
comment = create(:changeset_comment)
|
||||
|
||||
comment.author = nil
|
||||
assert !comment.valid?
|
||||
assert_not comment.valid?
|
||||
|
||||
comment.author_id = 999111
|
||||
assert !comment.valid?
|
||||
assert_not comment.valid?
|
||||
end
|
||||
|
||||
def test_does_not_accept_invalid_changeset
|
||||
comment = create(:changeset_comment)
|
||||
|
||||
comment.changeset = nil
|
||||
assert !comment.valid?
|
||||
assert_not comment.valid?
|
||||
|
||||
comment.changeset_id = 999111
|
||||
assert !comment.valid?
|
||||
assert_not comment.valid?
|
||||
end
|
||||
|
||||
def test_does_not_accept_empty_visible
|
||||
comment = create(:changeset_comment)
|
||||
|
||||
comment.visible = nil
|
||||
assert !comment.valid?
|
||||
assert_not comment.valid?
|
||||
end
|
||||
|
||||
def test_comments_of_changeset_count
|
||||
|
|
|
@ -62,7 +62,7 @@ class ChangesetTagTest < ActiveSupport::TestCase
|
|||
tag.k = existing.k
|
||||
tag.v = existing.v
|
||||
assert tag.new_record?
|
||||
assert !tag.valid?
|
||||
assert_not tag.valid?
|
||||
assert_raise(ActiveRecord::RecordInvalid) { tag.save! }
|
||||
assert tag.new_record?
|
||||
end
|
||||
|
|
|
@ -6,7 +6,7 @@ class IssueTest < ActiveSupport::TestCase
|
|||
|
||||
assert issue.valid?
|
||||
issue.assigned_role = "bogus"
|
||||
assert !issue.valid?
|
||||
assert_not issue.valid?
|
||||
end
|
||||
|
||||
def test_reported_user
|
||||
|
|
|
@ -5,11 +5,11 @@ class MessageTest < ActiveSupport::TestCase
|
|||
|
||||
def test_check_empty_message_fails
|
||||
message = Message.new
|
||||
assert !message.valid?
|
||||
assert_not message.valid?
|
||||
assert message.errors[:title].any?
|
||||
assert message.errors[:body].any?
|
||||
assert message.errors[:sent_on].any?
|
||||
assert !message.message_read
|
||||
assert_not message.message_read
|
||||
end
|
||||
|
||||
def test_validating_msgs
|
||||
|
@ -23,7 +23,7 @@ class MessageTest < ActiveSupport::TestCase
|
|||
message = create(:message, :unread)
|
||||
message.sender = nil
|
||||
message.recipient = nil
|
||||
assert !message.valid?
|
||||
assert_not message.valid?
|
||||
|
||||
assert_raise(ActiveRecord::RecordNotFound) { User.find(0) }
|
||||
message.from_user_id = 0
|
||||
|
|
|
@ -44,7 +44,7 @@ class NodeTagTest < ActiveSupport::TestCase
|
|||
tag.k = existing.k
|
||||
tag.v = existing.v
|
||||
assert tag.new_record?
|
||||
assert !tag.valid?
|
||||
assert_not tag.valid?
|
||||
assert_raise(ActiveRecord::RecordInvalid) { tag.save! }
|
||||
assert tag.new_record?
|
||||
end
|
||||
|
|
|
@ -20,7 +20,7 @@ class OldNodeTagTest < ActiveSupport::TestCase
|
|||
def test_length_key_invalid
|
||||
tag = create(:old_node_tag)
|
||||
tag.k = "k" * 256
|
||||
assert !tag.valid?
|
||||
assert_not tag.valid?
|
||||
assert tag.errors[:k].any?
|
||||
end
|
||||
|
||||
|
@ -45,7 +45,7 @@ class OldNodeTagTest < ActiveSupport::TestCase
|
|||
tag.k = existing.k
|
||||
tag.v = existing.v
|
||||
assert tag.new_record?
|
||||
assert !tag.valid?
|
||||
assert_not tag.valid?
|
||||
assert_raise(ActiveRecord::RecordInvalid) { tag.save! }
|
||||
assert tag.new_record?
|
||||
end
|
||||
|
|
|
@ -45,7 +45,7 @@ class OldRelationTagTest < ActiveSupport::TestCase
|
|||
tag.k = existing.k
|
||||
tag.v = existing.v
|
||||
assert tag.new_record?
|
||||
assert !tag.valid?
|
||||
assert_not tag.valid?
|
||||
assert_raise(ActiveRecord::RecordInvalid) { tag.save! }
|
||||
assert tag.new_record?
|
||||
end
|
||||
|
|
|
@ -45,7 +45,7 @@ class OldWayTagTest < ActiveSupport::TestCase
|
|||
tag.k = existing.k
|
||||
tag.v = existing.v
|
||||
assert tag.new_record?
|
||||
assert !tag.valid?
|
||||
assert_not tag.valid?
|
||||
assert_raise(ActiveRecord::RecordInvalid) { tag.save! }
|
||||
assert tag.new_record?
|
||||
end
|
||||
|
|
|
@ -44,7 +44,7 @@ class RelationTagTest < ActiveSupport::TestCase
|
|||
tag.k = existing.k
|
||||
tag.v = existing.v
|
||||
assert tag.new_record?
|
||||
assert !tag.valid?
|
||||
assert_not tag.valid?
|
||||
assert_raise(ActiveRecord::RecordInvalid) { tag.save! }
|
||||
assert tag.new_record?
|
||||
end
|
||||
|
|
|
@ -6,7 +6,7 @@ class ReportTest < ActiveSupport::TestCase
|
|||
|
||||
assert report.valid?
|
||||
report.issue = nil
|
||||
assert !report.valid?
|
||||
assert_not report.valid?
|
||||
end
|
||||
|
||||
def test_user_required
|
||||
|
@ -14,7 +14,7 @@ class ReportTest < ActiveSupport::TestCase
|
|||
|
||||
assert report.valid?
|
||||
report.user = nil
|
||||
assert !report.valid?
|
||||
assert_not report.valid?
|
||||
end
|
||||
|
||||
def test_details_required
|
||||
|
@ -22,7 +22,7 @@ class ReportTest < ActiveSupport::TestCase
|
|||
|
||||
assert report.valid?
|
||||
report.details = ""
|
||||
assert !report.valid?
|
||||
assert_not report.valid?
|
||||
end
|
||||
|
||||
def test_category_required
|
||||
|
@ -30,6 +30,6 @@ class ReportTest < ActiveSupport::TestCase
|
|||
|
||||
assert report.valid?
|
||||
report.category = ""
|
||||
assert !report.valid?
|
||||
assert_not report.valid?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,7 +5,7 @@ class TracepointTest < ActiveSupport::TestCase
|
|||
tracepoint = create(:tracepoint)
|
||||
assert tracepoint.valid?
|
||||
tracepoint.timestamp = nil
|
||||
assert !tracepoint.valid?
|
||||
assert_not tracepoint.valid?
|
||||
end
|
||||
|
||||
# Ensure the lat/lon is formatted as a decimal e.g. not 4.0e-05
|
||||
|
|
|
@ -5,7 +5,7 @@ class UserTest < ActiveSupport::TestCase
|
|||
|
||||
def test_invalid_with_empty_attributes
|
||||
user = User.new
|
||||
assert !user.valid?
|
||||
assert_not user.valid?
|
||||
assert user.errors[:email].any?
|
||||
assert user.errors[:pass_crypt].any?
|
||||
assert user.errors[:display_name].any?
|
||||
|
@ -25,7 +25,7 @@ class UserTest < ActiveSupport::TestCase
|
|||
:data_public => 1,
|
||||
:description => "desc"
|
||||
)
|
||||
assert !new_user.save
|
||||
assert_not new_user.save
|
||||
assert new_user.errors[:email].include?("has already been taken")
|
||||
end
|
||||
|
||||
|
@ -39,7 +39,7 @@ class UserTest < ActiveSupport::TestCase
|
|||
:data_public => 1,
|
||||
:description => "desc"
|
||||
)
|
||||
assert !new_user.save
|
||||
assert_not new_user.save
|
||||
assert new_user.errors[:display_name].include?("has already been taken")
|
||||
end
|
||||
|
||||
|
@ -69,12 +69,12 @@ class UserTest < ActiveSupport::TestCase
|
|||
user.display_name = "12"
|
||||
assert !user.valid?, "should not allow 2 char name"
|
||||
user.display_name = ""
|
||||
assert !user.valid?
|
||||
assert_not user.valid?
|
||||
user.display_name = nil
|
||||
# Don't understand why it isn't allowing a nil value,
|
||||
# when the validates statements specifically allow it
|
||||
# It appears the database does not allow null values
|
||||
assert !user.valid?
|
||||
assert_not user.valid?
|
||||
end
|
||||
|
||||
def test_display_name_valid
|
||||
|
@ -110,11 +110,11 @@ class UserTest < ActiveSupport::TestCase
|
|||
create(:friend, :befriender => alice, :befriendee => bob)
|
||||
|
||||
assert alice.is_friends_with?(bob)
|
||||
assert !alice.is_friends_with?(charlie)
|
||||
assert !bob.is_friends_with?(alice)
|
||||
assert !bob.is_friends_with?(charlie)
|
||||
assert !charlie.is_friends_with?(bob)
|
||||
assert !charlie.is_friends_with?(alice)
|
||||
assert_not alice.is_friends_with?(charlie)
|
||||
assert_not bob.is_friends_with?(alice)
|
||||
assert_not bob.is_friends_with?(charlie)
|
||||
assert_not charlie.is_friends_with?(bob)
|
||||
assert_not charlie.is_friends_with?(alice)
|
||||
end
|
||||
|
||||
def test_users_nearby
|
||||
|
|
|
@ -44,7 +44,7 @@ class WayTagTest < ActiveSupport::TestCase
|
|||
tag.k = existing.k
|
||||
tag.v = existing.v
|
||||
assert tag.new_record?
|
||||
assert !tag.valid?
|
||||
assert_not tag.valid?
|
||||
assert_raise(ActiveRecord::RecordInvalid) { tag.save! }
|
||||
assert tag.new_record?
|
||||
end
|
||||
|
|
18
test/system/diary_entry_test.rb
Normal file
18
test/system/diary_entry_test.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
require "application_system_test_case"
|
||||
|
||||
class DiaryEntrySystemTest < ApplicationSystemTestCase
|
||||
def setup
|
||||
create(:language, :code => "en")
|
||||
@diary_entry = create(:diary_entry)
|
||||
end
|
||||
|
||||
test "reply to diary entry should prefill the message subject" do
|
||||
sign_in_as(create(:user))
|
||||
visit diary_path
|
||||
|
||||
click_on "Reply to this entry"
|
||||
|
||||
assert page.has_content? "Send a new message"
|
||||
assert_equal "Re: #{@diary_entry.title}", page.find_field("Subject").value
|
||||
end
|
||||
end
|
|
@ -65,7 +65,7 @@ class IssuesTest < ApplicationSystemTestCase
|
|||
visit issues_path
|
||||
fill_in "search_by_user", :with => bad_user.display_name
|
||||
click_on "Search"
|
||||
assert !page.has_content?(I18n.t("issues.index.issues_not_found"))
|
||||
assert_not page.has_content?(I18n.t("issues.index.issues_not_found"))
|
||||
end
|
||||
|
||||
def test_commenting
|
||||
|
|
|
@ -11,7 +11,7 @@ class ReportDiaryCommentTest < ApplicationSystemTestCase
|
|||
visit diary_entry_path(@diary_entry.user.display_name, @diary_entry)
|
||||
assert page.has_content?(@comment.body)
|
||||
|
||||
assert !page.has_content?(I18n.t("diary_entry.diary_comment.report"))
|
||||
assert_not page.has_content?(I18n.t("diary_entry.diary_comment.report"))
|
||||
end
|
||||
|
||||
def test_it_works
|
||||
|
|
|
@ -10,7 +10,7 @@ class ReportDiaryEntryTest < ApplicationSystemTestCase
|
|||
visit diary_entry_path(@diary_entry.user.display_name, @diary_entry)
|
||||
assert page.has_content?(@diary_entry.title)
|
||||
|
||||
assert !page.has_content?(I18n.t("diary_entry.diary_entry.report"))
|
||||
assert_not page.has_content?(I18n.t("diary_entry.diary_entry.report"))
|
||||
end
|
||||
|
||||
def test_it_works
|
||||
|
@ -46,7 +46,7 @@ class ReportDiaryEntryTest < ApplicationSystemTestCase
|
|||
click_on "Create Report"
|
||||
|
||||
issue.reload
|
||||
assert !issue.resolved?
|
||||
assert_not issue.resolved?
|
||||
assert issue.open?
|
||||
end
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ class ReportNoteTest < ApplicationSystemTestCase
|
|||
visit browse_note_path(note)
|
||||
assert page.has_content?(note.comments.first.body)
|
||||
|
||||
assert !page.has_content?(I18n.t("browse.note.report"))
|
||||
assert_not page.has_content?(I18n.t("browse.note.report"))
|
||||
end
|
||||
|
||||
def test_can_report_anonymous_notes
|
||||
|
|
|
@ -6,7 +6,7 @@ class ReportUserTest < ApplicationSystemTestCase
|
|||
visit browse_note_path(note)
|
||||
assert page.has_content?(note.comments.first.body)
|
||||
|
||||
assert !page.has_content?(I18n.t("user.view.report"))
|
||||
assert_not page.has_content?(I18n.t("user.view.report"))
|
||||
end
|
||||
|
||||
def test_can_report_user
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue