mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 15:20:13 +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
|
|
@ -9,8 +9,8 @@ class PreferencesController < ApplicationController
|
||||||
def update
|
def update
|
||||||
@prefs = current_user.prefs
|
@prefs = current_user.prefs
|
||||||
@user = current_user
|
@user = current_user
|
||||||
user_updated = current_user.update_attributes(user_params)
|
user_updated = current_user.update(user_params)
|
||||||
prefs_updated = current_user.preference.update_attributes(prefs_params)
|
prefs_updated = current_user.preference.update(prefs_params)
|
||||||
if (user_updated && prefs_updated)
|
if (user_updated && prefs_updated)
|
||||||
if params['user']['password'].present? # password updated?
|
if params['user']['password'].present? # password updated?
|
||||||
logout_user t('preferences.password_changed')
|
logout_user t('preferences.password_changed')
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ class Context < ApplicationRecord
|
||||||
|
|
||||||
validates_presence_of :name, :message => "context must have a name"
|
validates_presence_of :name, :message => "context must have a name"
|
||||||
validates_length_of :name, :maximum => 255, :message => "context name must be less than 256 characters"
|
validates_length_of :name, :maximum => 255, :message => "context name must be less than 256 characters"
|
||||||
validates_uniqueness_of :name, :message => "already exists", :scope => "user_id"
|
validates_uniqueness_of :name, :message => "already exists", :scope => "user_id", :case_sensitive => false
|
||||||
|
|
||||||
def self.null_object
|
def self.null_object
|
||||||
NullContext.new
|
NullContext.new
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ class Project < ApplicationRecord
|
||||||
|
|
||||||
validates_presence_of :name
|
validates_presence_of :name
|
||||||
validates_length_of :name, :maximum => 255
|
validates_length_of :name, :maximum => 255
|
||||||
validates_uniqueness_of :name, :scope => "user_id"
|
validates_uniqueness_of :name, :scope => "user_id", :case_sensitive => true
|
||||||
|
|
||||||
acts_as_list :scope => 'user_id = #{user_id} AND state = \'#{state}\'', :top_of_list => 0
|
acts_as_list :scope => 'user_id = #{user_id} AND state = \'#{state}\'', :top_of_list => 0
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ class User < ApplicationRecord
|
||||||
validates_presence_of :password_confirmation, if: :password_required?
|
validates_presence_of :password_confirmation, if: :password_required?
|
||||||
validates_confirmation_of :password
|
validates_confirmation_of :password
|
||||||
validates_length_of :login, within: 3..80
|
validates_length_of :login, within: 3..80
|
||||||
validates_uniqueness_of :login, on: :create
|
validates_uniqueness_of :login, on: :create, :case_sensitive => false
|
||||||
validate :validate_auth_type
|
validate :validate_auth_type
|
||||||
validates :email, :allow_blank => true, format: { with: URI::MailTo::EMAIL_REGEXP }
|
validates :email, :allow_blank => true, format: { with: URI::MailTo::EMAIL_REGEXP }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,5 +21,5 @@
|
||||||
|
|
||||||
<div id="input_box">
|
<div id="input_box">
|
||||||
<%= render :partial => "shared/add_new_item_form" %>
|
<%= render :partial => "shared/add_new_item_form" %>
|
||||||
<%= render :file => "sidebar/sidebar" %>
|
<%= render :template => "sidebar/sidebar" %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -19,5 +19,5 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="input_box">
|
<div id="input_box">
|
||||||
<%= render :file => "sidebar/sidebar" %>
|
<%= render :template => "sidebar/sidebar" %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -42,5 +42,5 @@
|
||||||
|
|
||||||
<div id="input_box">
|
<div id="input_box">
|
||||||
<%= render :partial => "shared/add_new_item_form" %>
|
<%= render :partial => "shared/add_new_item_form" %>
|
||||||
<%= render :file => "sidebar/sidebar" %>
|
<%= render :template => "sidebar/sidebar" %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -12,5 +12,5 @@
|
||||||
|
|
||||||
<div id="input_box">
|
<div id="input_box">
|
||||||
<%= render :partial => "shared/add_new_item_form" %>
|
<%= render :partial => "shared/add_new_item_form" %>
|
||||||
<%= render :file => "sidebar/sidebar" %>
|
<%= render :template => "sidebar/sidebar" %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -27,5 +27,5 @@
|
||||||
|
|
||||||
<div id="input_box">
|
<div id="input_box">
|
||||||
<%= render :partial => "shared/add_new_item_form" %>
|
<%= render :partial => "shared/add_new_item_form" %>
|
||||||
<%= render :file => "sidebar/sidebar" %>
|
<%= render :template => "sidebar/sidebar" %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ class ContextsControllerTest < ActionController::TestCase
|
||||||
login_as :admin_user
|
login_as :admin_user
|
||||||
get :index
|
get :index
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_sets_title
|
def test_show_sets_title
|
||||||
login_as :admin_user
|
login_as :admin_user
|
||||||
get :show, params: { :id => "1" }
|
get :show, params: { :id => "1" }
|
||||||
|
|
@ -32,7 +32,7 @@ class ContextsControllerTest < ActionController::TestCase
|
||||||
get :show, params: { :id => "1" }
|
get :show, params: { :id => "1" }
|
||||||
assert_template "contexts/show"
|
assert_template "contexts/show"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_get_edit_form_using_xhr
|
def test_get_edit_form_using_xhr
|
||||||
login_as(:admin_user)
|
login_as(:admin_user)
|
||||||
get :edit, xhr: true, params: { :id => contexts(:errand).id }
|
get :edit, xhr: true, params: { :id => contexts(:errand).id }
|
||||||
|
|
@ -54,26 +54,25 @@ class ContextsControllerTest < ActionController::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
# TXT feed
|
# TXT feed
|
||||||
|
|
||||||
def test_text_feed_content
|
def test_text_feed_content
|
||||||
login_as :admin_user
|
login_as :admin_user
|
||||||
get :index, params: { :format => "txt" }
|
get :index, params: { :format => "txt" }
|
||||||
assert_equal 'text/plain', @response.content_type
|
assert_equal 'text/plain', @response.media_type
|
||||||
assert !(/ /.match(@response.body))
|
assert !(/ /.match(@response.body))
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_text_feed_not_accessible_to_anonymous_user_without_token
|
def test_text_feed_not_accessible_to_anonymous_user_without_token
|
||||||
login_as nil
|
login_as nil
|
||||||
get :index, params: { :format => "txt" }
|
get :index, params: { :format => "txt" }
|
||||||
assert_response 401
|
assert_response 401
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_text_feed_not_accessible_to_anonymous_user_with_invalid_token
|
def test_text_feed_not_accessible_to_anonymous_user_with_invalid_token
|
||||||
login_as nil
|
login_as nil
|
||||||
get :index, params: { :format => "txt", :token => 'foo' }
|
get :index, params: { :format => "txt", :token => 'foo' }
|
||||||
assert_response 401
|
assert_response 401
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_text_feed_accessible_to_anonymous_user_with_valid_token
|
def test_text_feed_accessible_to_anonymous_user_with_valid_token
|
||||||
login_as nil
|
login_as nil
|
||||||
get :index, params: { :format => "txt", :token => users(:admin_user).token }
|
get :index, params: { :format => "txt", :token => users(:admin_user).token }
|
||||||
|
|
@ -81,35 +80,33 @@ class ContextsControllerTest < ActionController::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
# REST xml
|
# REST xml
|
||||||
|
|
||||||
def test_show_xml_renders_context_to_xml
|
def test_show_xml_renders_context_to_xml
|
||||||
login_as :admin_user
|
login_as :admin_user
|
||||||
get :show, params: { :id => "1", :format => 'xml' }
|
get :show, params: { :id => "1", :format => 'xml' }
|
||||||
assert_equal contexts(:agenda).to_xml( :except => :user_id ), @response.body
|
assert_equal contexts(:agenda).to_xml( :except => :user_id ), @response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_with_nil_context_returns_404
|
def test_show_with_nil_context_returns_404
|
||||||
login_as :admin_user
|
login_as :admin_user
|
||||||
get :show, params: { :id => "0" }
|
get :show, params: { :id => "0" }
|
||||||
assert_equal 'Context not found', @response.body
|
assert_equal 'Context not found', @response.body
|
||||||
assert_response 404
|
assert_response 404
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_show_xml_with_nil_context_returns_404
|
def test_show_xml_with_nil_context_returns_404
|
||||||
login_as :admin_user
|
login_as :admin_user
|
||||||
get :show, params: { :id => "0", :format => 'xml' }
|
get :show, params: { :id => "0", :format => 'xml' }
|
||||||
assert_response 404
|
assert_response 404
|
||||||
assert_select 'error', 'Context not found'
|
assert_select 'error', 'Context not found'
|
||||||
end
|
end
|
||||||
|
|
||||||
# RSS
|
|
||||||
|
|
||||||
|
# RSS
|
||||||
def test_rss_feed_content
|
def test_rss_feed_content
|
||||||
login_as :admin_user
|
login_as :admin_user
|
||||||
get :index, params: { :format => "rss" }
|
get :index, params: { :format => "rss" }
|
||||||
assert_equal 'application/rss+xml', @response.content_type
|
assert_equal 'application/rss+xml', @response.media_type
|
||||||
#puts @response.body
|
#puts @response.body
|
||||||
|
|
||||||
assert_select 'rss[version="2.0"]' do
|
assert_select 'rss[version="2.0"]' do
|
||||||
assert_select 'channel' do
|
assert_select 'channel' do
|
||||||
assert_select '>title', 'Tracks Contexts'
|
assert_select '>title', 'Tracks Contexts'
|
||||||
|
|
@ -131,19 +128,19 @@ class ContextsControllerTest < ActionController::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_rss_feed_not_accessible_to_anonymous_user_without_token
|
def test_rss_feed_not_accessible_to_anonymous_user_without_token
|
||||||
login_as nil
|
login_as nil
|
||||||
get :index, params: { :format => "rss" }
|
get :index, params: { :format => "rss" }
|
||||||
assert_response 401
|
assert_response 401
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_rss_feed_not_accessible_to_anonymous_user_with_invalid_token
|
def test_rss_feed_not_accessible_to_anonymous_user_with_invalid_token
|
||||||
login_as nil
|
login_as nil
|
||||||
get :index, params: { :format => "rss", :token => 'foo' }
|
get :index, params: { :format => "rss", :token => 'foo' }
|
||||||
assert_response 401
|
assert_response 401
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_rss_feed_accessible_to_anonymous_user_with_valid_token
|
def test_rss_feed_accessible_to_anonymous_user_with_valid_token
|
||||||
login_as nil
|
login_as nil
|
||||||
get :index, params: { :format => "rss", :token => users(:admin_user).token }
|
get :index, params: { :format => "rss", :token => users(:admin_user).token }
|
||||||
|
|
@ -151,11 +148,10 @@ class ContextsControllerTest < ActionController::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
# ATOM
|
# ATOM
|
||||||
|
|
||||||
def test_atom_feed_content
|
def test_atom_feed_content
|
||||||
login_as :admin_user
|
login_as :admin_user
|
||||||
get :index, params: { :format => "atom" }
|
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_equal 'http://www.w3.org/2005/Atom', html_document.children[0].namespace.href
|
||||||
assert_select 'feed' do
|
assert_select 'feed' do
|
||||||
assert_select '>title', 'Tracks Contexts'
|
assert_select '>title', 'Tracks Contexts'
|
||||||
|
|
@ -171,24 +167,22 @@ class ContextsControllerTest < ActionController::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_atom_feed_not_accessible_to_anonymous_user_without_token
|
def test_atom_feed_not_accessible_to_anonymous_user_without_token
|
||||||
login_as nil
|
login_as nil
|
||||||
get :index, params: { :format => "atom" }
|
get :index, params: { :format => "atom" }
|
||||||
assert_response 401
|
assert_response 401
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_atom_feed_not_accessible_to_anonymous_user_with_invalid_token
|
def test_atom_feed_not_accessible_to_anonymous_user_with_invalid_token
|
||||||
login_as nil
|
login_as nil
|
||||||
get :index, params: { :format => "atom", :token => 'foo' }
|
get :index, params: { :format => "atom", :token => 'foo' }
|
||||||
assert_response 401
|
assert_response 401
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_atom_feed_accessible_to_anonymous_user_with_valid_token
|
def test_atom_feed_accessible_to_anonymous_user_with_valid_token
|
||||||
login_as nil
|
login_as nil
|
||||||
get :index, params: { :format => "atom", :token => users(:admin_user).token }
|
get :index, params: { :format => "atom", :token => users(:admin_user).token }
|
||||||
assert_response :ok
|
assert_response :ok
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ class ProjectsControllerTest < ActionController::TestCase
|
||||||
def test_rss_feed_content
|
def test_rss_feed_content
|
||||||
login_as(:admin_user)
|
login_as(:admin_user)
|
||||||
get :index, params: { :format => "rss" }
|
get :index, params: { :format => "rss" }
|
||||||
assert_equal 'application/rss+xml', @response.content_type
|
assert_equal 'application/rss+xml', @response.media_type
|
||||||
#puts @response.body
|
#puts @response.body
|
||||||
|
|
||||||
assert_select 'rss[version="2.0"]' do
|
assert_select 'rss[version="2.0"]' do
|
||||||
|
|
@ -128,7 +128,7 @@ class ProjectsControllerTest < ActionController::TestCase
|
||||||
def test_atom_feed_content
|
def test_atom_feed_content
|
||||||
login_as :admin_user
|
login_as :admin_user
|
||||||
get :index, params: { :format => "atom" }
|
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_equal 'http://www.w3.org/2005/Atom', html_document.children[0].namespace.href
|
||||||
assert_select 'feed' do
|
assert_select 'feed' do
|
||||||
assert_select '>title', 'Tracks Projects'
|
assert_select '>title', 'Tracks Projects'
|
||||||
|
|
@ -166,7 +166,7 @@ class ProjectsControllerTest < ActionController::TestCase
|
||||||
def test_text_feed_content
|
def test_text_feed_content
|
||||||
login_as :admin_user
|
login_as :admin_user
|
||||||
get :index, params: { :format => "txt" }
|
get :index, params: { :format => "txt" }
|
||||||
assert_equal 'text/plain', @response.content_type
|
assert_equal 'text/plain', @response.media_type
|
||||||
assert !(/ /.match(@response.body))
|
assert !(/ /.match(@response.body))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -238,7 +238,7 @@ class ProjectsControllerTest < ActionController::TestCase
|
||||||
def test_xml_content
|
def test_xml_content
|
||||||
login_as(:admin_user)
|
login_as(:admin_user)
|
||||||
get :index, params: { :format => "xml" }
|
get :index, params: { :format => "xml" }
|
||||||
assert_equal 'application/xml', @response.content_type
|
assert_equal 'application/xml', @response.media_type
|
||||||
|
|
||||||
assert_select 'projects' do
|
assert_select 'projects' do
|
||||||
assert_select 'project', 3 do
|
assert_select 'project', 3 do
|
||||||
|
|
|
||||||
|
|
@ -128,17 +128,17 @@ class TodosControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
get :tag, params: { name: 'first.last.m' }
|
get :tag, params: { name: 'first.last.m' }
|
||||||
assert_equal "text/html", request.format, "controller should set right content type"
|
assert_equal "text/html", request.format, "controller should set right content type"
|
||||||
assert_equal "text/html", @response.content_type
|
assert_equal "text/html", @response.media_type
|
||||||
assert_equal "first.last", assigns['tag_name'], ".m should be chomped"
|
assert_equal "first.last", assigns['tag_name'], ".m should be chomped"
|
||||||
|
|
||||||
get :tag, params: { name: 'first.last.txt' }
|
get :tag, params: { name: 'first.last.txt' }
|
||||||
assert_equal "text/plain", request.format, "controller should set right content type"
|
assert_equal "text/plain", request.format, "controller should set right content type"
|
||||||
assert_equal "text/plain", @response.content_type
|
assert_equal "text/plain", @response.media_type
|
||||||
assert_equal "first.last", assigns['tag_name'], ".txt should be chomped"
|
assert_equal "first.last", assigns['tag_name'], ".txt should be chomped"
|
||||||
|
|
||||||
get :tag, params: { name: 'first.last' }
|
get :tag, params: { name: 'first.last' }
|
||||||
assert_equal "text/html", request.format, "controller should set right content type"
|
assert_equal "text/html", request.format, "controller should set right content type"
|
||||||
assert_equal "text/html", @response.content_type
|
assert_equal "text/html", @response.media_type
|
||||||
assert_equal "first.last", assigns['tag_name'], ":name should be correct"
|
assert_equal "first.last", assigns['tag_name'], ":name should be correct"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -479,7 +479,7 @@ class TodosControllerTest < ActionController::TestCase
|
||||||
def test_rss_feed_not_completed
|
def test_rss_feed_not_completed
|
||||||
login_as(:admin_user)
|
login_as(:admin_user)
|
||||||
get :index, params: { :format => "rss" }
|
get :index, params: { :format => "rss" }
|
||||||
assert_equal 'application/rss+xml', @response.content_type
|
assert_equal 'application/rss+xml', @response.media_type
|
||||||
# puts @response.body
|
# puts @response.body
|
||||||
|
|
||||||
assert_select 'rss[version="2.0"]' do
|
assert_select 'rss[version="2.0"]' do
|
||||||
|
|
@ -502,7 +502,7 @@ class TodosControllerTest < ActionController::TestCase
|
||||||
def test_atom_feed_not_completed
|
def test_atom_feed_not_completed
|
||||||
login_as :admin_user
|
login_as :admin_user
|
||||||
get :index, params: { :format => "atom" }
|
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_equal 'http://www.w3.org/2005/Atom', html_document.children[0].namespace.href
|
||||||
assert_select 'feed' do
|
assert_select 'feed' do
|
||||||
assert_select '>title', 'Tracks Actions'
|
assert_select '>title', 'Tracks Actions'
|
||||||
|
|
@ -518,7 +518,7 @@ class TodosControllerTest < ActionController::TestCase
|
||||||
def test_text_feed_not_completed
|
def test_text_feed_not_completed
|
||||||
login_as(:admin_user)
|
login_as(:admin_user)
|
||||||
get :index, params: { :format => "txt" }
|
get :index, params: { :format => "txt" }
|
||||||
assert_equal 'text/plain', @response.content_type
|
assert_equal 'text/plain', @response.media_type
|
||||||
assert !(/ /.match(@response.body))
|
assert !(/ /.match(@response.body))
|
||||||
assert_number_of_items_in_text_feed 11
|
assert_number_of_items_in_text_feed 11
|
||||||
end
|
end
|
||||||
|
|
@ -526,7 +526,7 @@ class TodosControllerTest < ActionController::TestCase
|
||||||
def test_ical_feed_not_completed
|
def test_ical_feed_not_completed
|
||||||
login_as :admin_user
|
login_as :admin_user
|
||||||
get :index, params: { :format => "ics" }
|
get :index, params: { :format => "ics" }
|
||||||
assert_equal 'text/calendar', @response.content_type
|
assert_equal 'text/calendar', @response.media_type
|
||||||
assert !(/ /.match(@response.body))
|
assert !(/ /.match(@response.body))
|
||||||
assert_number_of_items_in_ical_feed 11
|
assert_number_of_items_in_ical_feed 11
|
||||||
end
|
end
|
||||||
|
|
@ -756,7 +756,7 @@ class TodosControllerTest < ActionController::TestCase
|
||||||
def test_mobile_index_uses_text_html_content_type
|
def test_mobile_index_uses_text_html_content_type
|
||||||
login_as(:admin_user)
|
login_as(:admin_user)
|
||||||
get :index, params: { :format => "m" }
|
get :index, params: { :format => "m" }
|
||||||
assert_equal 'text/html', @response.content_type
|
assert_equal 'text/html', @response.media_type
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_mobile_index_assigns_down_count
|
def test_mobile_index_assigns_down_count
|
||||||
|
|
|
||||||
|
|
@ -274,12 +274,12 @@ class UserTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_should_reset_password
|
def test_should_reset_password
|
||||||
users(:other_user).update_attributes(:password => 'new password', :password_confirmation => 'new password')
|
users(:other_user).update(:password => 'new password', :password_confirmation => 'new password')
|
||||||
assert_equal users(:other_user), User.authenticate('jane', 'new password')
|
assert_equal users(:other_user), User.authenticate('jane', 'new password')
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_should_not_rehash_password
|
def test_should_not_rehash_password
|
||||||
users(:other_user).update_attributes(:login => 'jane2')
|
users(:other_user).update(:login => 'jane2')
|
||||||
assert_equal users(:other_user), User.authenticate('jane2', 'sesame')
|
assert_equal users(:other_user), User.authenticate('jane2', 'sesame')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue