mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-22 18:20:12 +01:00
Try fixing a few test deprecations
This commit is contained in:
parent
399e2c0b76
commit
a0768636c3
13 changed files with 43 additions and 49 deletions
|
|
@ -10,7 +10,7 @@ class ContextsControllerTest < ActionController::TestCase
|
|||
login_as :admin_user
|
||||
get :index
|
||||
end
|
||||
|
||||
|
||||
def test_show_sets_title
|
||||
login_as :admin_user
|
||||
get :show, params: { :id => "1" }
|
||||
|
|
@ -32,7 +32,7 @@ class ContextsControllerTest < ActionController::TestCase
|
|||
get :show, params: { :id => "1" }
|
||||
assert_template "contexts/show"
|
||||
end
|
||||
|
||||
|
||||
def test_get_edit_form_using_xhr
|
||||
login_as(:admin_user)
|
||||
get :edit, xhr: true, params: { :id => contexts(:errand).id }
|
||||
|
|
@ -54,26 +54,25 @@ class ContextsControllerTest < ActionController::TestCase
|
|||
end
|
||||
|
||||
# TXT feed
|
||||
|
||||
def test_text_feed_content
|
||||
login_as :admin_user
|
||||
get :index, params: { :format => "txt" }
|
||||
assert_equal 'text/plain', @response.content_type
|
||||
assert_equal 'text/plain', @response.media_type
|
||||
assert !(/ /.match(@response.body))
|
||||
end
|
||||
|
||||
|
||||
def test_text_feed_not_accessible_to_anonymous_user_without_token
|
||||
login_as nil
|
||||
get :index, params: { :format => "txt" }
|
||||
assert_response 401
|
||||
end
|
||||
|
||||
|
||||
def test_text_feed_not_accessible_to_anonymous_user_with_invalid_token
|
||||
login_as nil
|
||||
get :index, params: { :format => "txt", :token => 'foo' }
|
||||
assert_response 401
|
||||
end
|
||||
|
||||
|
||||
def test_text_feed_accessible_to_anonymous_user_with_valid_token
|
||||
login_as nil
|
||||
get :index, params: { :format => "txt", :token => users(:admin_user).token }
|
||||
|
|
@ -81,35 +80,33 @@ class ContextsControllerTest < ActionController::TestCase
|
|||
end
|
||||
|
||||
# REST xml
|
||||
|
||||
def test_show_xml_renders_context_to_xml
|
||||
login_as :admin_user
|
||||
get :show, params: { :id => "1", :format => 'xml' }
|
||||
assert_equal contexts(:agenda).to_xml( :except => :user_id ), @response.body
|
||||
end
|
||||
|
||||
|
||||
def test_show_with_nil_context_returns_404
|
||||
login_as :admin_user
|
||||
get :show, params: { :id => "0" }
|
||||
assert_equal 'Context not found', @response.body
|
||||
assert_response 404
|
||||
end
|
||||
|
||||
|
||||
def test_show_xml_with_nil_context_returns_404
|
||||
login_as :admin_user
|
||||
get :show, params: { :id => "0", :format => 'xml' }
|
||||
assert_response 404
|
||||
assert_select 'error', 'Context not found'
|
||||
end
|
||||
|
||||
# RSS
|
||||
|
||||
# RSS
|
||||
def test_rss_feed_content
|
||||
login_as :admin_user
|
||||
get :index, params: { :format => "rss" }
|
||||
assert_equal 'application/rss+xml', @response.content_type
|
||||
assert_equal 'application/rss+xml', @response.media_type
|
||||
#puts @response.body
|
||||
|
||||
|
||||
assert_select 'rss[version="2.0"]' do
|
||||
assert_select 'channel' do
|
||||
assert_select '>title', 'Tracks Contexts'
|
||||
|
|
@ -131,19 +128,19 @@ class ContextsControllerTest < ActionController::TestCase
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def test_rss_feed_not_accessible_to_anonymous_user_without_token
|
||||
login_as nil
|
||||
get :index, params: { :format => "rss" }
|
||||
assert_response 401
|
||||
end
|
||||
|
||||
|
||||
def test_rss_feed_not_accessible_to_anonymous_user_with_invalid_token
|
||||
login_as nil
|
||||
get :index, params: { :format => "rss", :token => 'foo' }
|
||||
assert_response 401
|
||||
end
|
||||
|
||||
|
||||
def test_rss_feed_accessible_to_anonymous_user_with_valid_token
|
||||
login_as nil
|
||||
get :index, params: { :format => "rss", :token => users(:admin_user).token }
|
||||
|
|
@ -151,11 +148,10 @@ class ContextsControllerTest < ActionController::TestCase
|
|||
end
|
||||
|
||||
# ATOM
|
||||
|
||||
def test_atom_feed_content
|
||||
login_as :admin_user
|
||||
get :index, params: { :format => "atom" }
|
||||
assert_equal 'application/atom+xml', @response.content_type
|
||||
assert_equal 'application/atom+xml', @response.media_type
|
||||
assert_equal 'http://www.w3.org/2005/Atom', html_document.children[0].namespace.href
|
||||
assert_select 'feed' do
|
||||
assert_select '>title', 'Tracks Contexts'
|
||||
|
|
@ -171,24 +167,22 @@ class ContextsControllerTest < ActionController::TestCase
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def test_atom_feed_not_accessible_to_anonymous_user_without_token
|
||||
login_as nil
|
||||
get :index, params: { :format => "atom" }
|
||||
assert_response 401
|
||||
end
|
||||
|
||||
|
||||
def test_atom_feed_not_accessible_to_anonymous_user_with_invalid_token
|
||||
login_as nil
|
||||
get :index, params: { :format => "atom", :token => 'foo' }
|
||||
assert_response 401
|
||||
end
|
||||
|
||||
|
||||
def test_atom_feed_accessible_to_anonymous_user_with_valid_token
|
||||
login_as nil
|
||||
get :index, params: { :format => "atom", :token => users(:admin_user).token }
|
||||
assert_response :ok
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue