mirror of
https://github.com/TracksApp/tracks.git
synced 2025-09-21 21:40:48 +02:00
Use the keyword args syntax for controller actions
Co-Authored-By: Dan Rice <dnrce@users.noreply.github.com>
This commit is contained in:
parent
755a7a1b80
commit
2f85a42f91
19 changed files with 258 additions and 241 deletions
|
@ -15,7 +15,7 @@ class ProjectsControllerTest < ActionController::TestCase
|
|||
def test_show_exposes_deferred_todos
|
||||
p = projects(:timemachine)
|
||||
login_as :admin_user
|
||||
get :show, :id => p.to_param
|
||||
get :show, params: { :id => p.to_param }
|
||||
assert_not_nil assigns['deferred_todos']
|
||||
assert_equal 1, assigns['deferred_todos'].size
|
||||
|
||||
|
@ -23,7 +23,7 @@ class ProjectsControllerTest < ActionController::TestCase
|
|||
t.show_from = 1.days.from_now.utc
|
||||
t.save!
|
||||
|
||||
get :show, :id => p.to_param
|
||||
get :show, params: { :id => p.to_param }
|
||||
assert_equal 2, assigns['deferred_todos'].size
|
||||
end
|
||||
|
||||
|
@ -39,13 +39,13 @@ class ProjectsControllerTest < ActionController::TestCase
|
|||
|
||||
def test_show_exposes_next_project_in_same_state
|
||||
login_as :admin_user
|
||||
get :show, :id => projects(:timemachine).to_param
|
||||
get :show, params: { :id => projects(:timemachine).to_param }
|
||||
assert_equal(projects(:moremoney), assigns['next_project'])
|
||||
end
|
||||
|
||||
def test_show_exposes_previous_project_in_same_state
|
||||
login_as :admin_user
|
||||
get :show, :id => projects(:moremoney).to_param
|
||||
get :show, params: { :id => projects(:moremoney).to_param }
|
||||
assert_equal(projects(:timemachine), assigns['previous_project'])
|
||||
end
|
||||
|
||||
|
@ -58,7 +58,7 @@ class ProjectsControllerTest < ActionController::TestCase
|
|||
p = projects(:timemachine)
|
||||
todos = p.todos.active
|
||||
login_as(:admin_user)
|
||||
xhr :post, :update, :id => 1, "project"=>{"name"=>p.name, "description"=>p.description, "state"=>"hidden"}
|
||||
post :update, xhr: true, params: { :id => 1, "project"=>{"name"=>p.name, "description"=>p.description, "state"=>"hidden"} }
|
||||
todos.each do |t|
|
||||
assert t.reload().hidden?
|
||||
end
|
||||
|
@ -69,8 +69,8 @@ class ProjectsControllerTest < ActionController::TestCase
|
|||
p = projects(:timemachine)
|
||||
todos = p.todos.active
|
||||
login_as(:admin_user)
|
||||
xhr :post, :update, :id => 1, "project"=>{"name"=>p.name, "description"=>p.description, "state"=>"hidden"}
|
||||
xhr :post, :update, :id => 1, "project"=>{"name"=>p.name, "description"=>p.description, "state"=>"active"}
|
||||
post :update, xhr: true, params: { :id => 1, "project"=>{"name"=>p.name, "description"=>p.description, "state"=>"hidden"} }
|
||||
post :update, xhr: true, params: { :id => 1, "project"=>{"name"=>p.name, "description"=>p.description, "state"=>"active"} }
|
||||
todos.each do |t|
|
||||
assert_equal :active, t.reload().aasm.current_state
|
||||
end
|
||||
|
@ -81,7 +81,7 @@ class ProjectsControllerTest < ActionController::TestCase
|
|||
|
||||
def test_rss_feed_content
|
||||
login_as(:admin_user)
|
||||
get :index, { :format => "rss" }
|
||||
get :index, params: { :format => "rss" }
|
||||
assert_equal 'application/rss+xml', @response.content_type
|
||||
#puts @response.body
|
||||
|
||||
|
@ -109,25 +109,25 @@ class ProjectsControllerTest < ActionController::TestCase
|
|||
|
||||
def test_rss_feed_not_accessible_to_anonymous_user_without_token
|
||||
login_as nil
|
||||
get :index, { :format => "rss" }
|
||||
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, { :format => "rss", :token => 'foo' }
|
||||
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, { :format => "rss", :token => users(:admin_user).token }
|
||||
get :index, params: { :format => "rss", :token => users(:admin_user).token }
|
||||
assert_response :ok
|
||||
end
|
||||
|
||||
def test_atom_feed_content
|
||||
login_as :admin_user
|
||||
get :index, { :format => "atom" }
|
||||
get :index, params: { :format => "atom" }
|
||||
assert_equal 'application/atom+xml', @response.content_type
|
||||
assert_equal 'http://www.w3.org/2005/Atom', html_document.children[0].namespace.href
|
||||
assert_select 'feed' do
|
||||
|
@ -147,25 +147,25 @@ class ProjectsControllerTest < ActionController::TestCase
|
|||
|
||||
def test_atom_feed_not_accessible_to_anonymous_user_without_token
|
||||
login_as nil
|
||||
get :index, { :format => "atom" }
|
||||
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, { :format => "atom", :token => 'foo' }
|
||||
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, { :format => "atom", :token => users(:admin_user).token }
|
||||
get :index, params: { :format => "atom", :token => users(:admin_user).token }
|
||||
assert_response :ok
|
||||
end
|
||||
|
||||
def test_text_feed_content
|
||||
login_as :admin_user
|
||||
get :index, { :format => "txt" }
|
||||
get :index, params: { :format => "txt" }
|
||||
assert_equal 'text/plain', @response.content_type
|
||||
assert !(/ /.match(@response.body))
|
||||
end
|
||||
|
@ -175,33 +175,33 @@ class ProjectsControllerTest < ActionController::TestCase
|
|||
p = projects(:timemachine)
|
||||
p.todos.each(&:destroy)
|
||||
|
||||
get :index, { :format => "txt", :only_active_with_no_next_actions => true }
|
||||
get :index, params: { :format => "txt", :only_active_with_no_next_actions => true }
|
||||
assert (/^\s*BUILD A WORKING TIME MACHINE\s+0 actions. Project is active.\s*$/.match(@response.body))
|
||||
assert !(/[1-9] actions/.match(@response.body))
|
||||
end
|
||||
|
||||
def test_text_feed_not_accessible_to_anonymous_user_without_token
|
||||
login_as nil
|
||||
get :index, { :format => "txt" }
|
||||
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, { :format => "txt", :token => 'foo' }
|
||||
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, { :format => "txt", :token => users(:admin_user).token }
|
||||
get :index, params: { :format => "txt", :token => users(:admin_user).token }
|
||||
assert_response :ok
|
||||
end
|
||||
|
||||
def test_actionize_sorts_active_projects_by_number_of_tasks
|
||||
login_as :admin_user
|
||||
u = users(:admin_user)
|
||||
post :actionize, :state => "active", :format => 'js'
|
||||
post :actionize, params: { :state => "active", :format => 'js' }
|
||||
|
||||
assert_equal 1, projects(:gardenclean).position
|
||||
assert_equal 2, projects(:moremoney).position
|
||||
|
@ -211,7 +211,7 @@ class ProjectsControllerTest < ActionController::TestCase
|
|||
def test_alphabetize_sorts_active_projects_alphabetically
|
||||
login_as :admin_user
|
||||
u = users(:admin_user)
|
||||
post :alphabetize, :state => "active", :format => 'js'
|
||||
post :alphabetize, params: { :state => "active", :format => 'js' }
|
||||
assert_equal 1, projects(:timemachine).position
|
||||
assert_equal 2, projects(:gardenclean).position
|
||||
assert_equal 3, projects(:moremoney).position
|
||||
|
@ -219,13 +219,13 @@ class ProjectsControllerTest < ActionController::TestCase
|
|||
|
||||
def test_alphabetize_assigns_state
|
||||
login_as :admin_user
|
||||
post :alphabetize, :state => "active", :format => 'js'
|
||||
post :alphabetize, params: { :state => "active", :format => 'js' }
|
||||
assert_equal "active", assigns['state']
|
||||
end
|
||||
|
||||
def test_alphabetize_assigns_projects
|
||||
login_as :admin_user
|
||||
post :alphabetize, :state => "active", :format => 'js'
|
||||
post :alphabetize, params: { :state => "active", :format => 'js' }
|
||||
exposed_projects = assigns['projects']
|
||||
assert_equal 3, exposed_projects.length
|
||||
assert_equal projects(:timemachine), exposed_projects[0]
|
||||
|
@ -237,7 +237,7 @@ class ProjectsControllerTest < ActionController::TestCase
|
|||
|
||||
def test_xml_content
|
||||
login_as(:admin_user)
|
||||
get :index, { :format => "xml" }
|
||||
get :index, params: { :format => "xml" }
|
||||
assert_equal 'application/xml', @response.content_type
|
||||
|
||||
assert_select 'projects' do
|
||||
|
@ -250,19 +250,19 @@ class ProjectsControllerTest < ActionController::TestCase
|
|||
|
||||
def test_xml_not_accessible_to_anonymous_user_without_token
|
||||
login_as nil
|
||||
get :index, { :format => "xml" }
|
||||
get :index, params: { :format => "xml" }
|
||||
assert_response 401
|
||||
end
|
||||
|
||||
def test_xml_not_accessible_to_anonymous_user_with_invalid_token
|
||||
login_as nil
|
||||
get :index, { :format => "xml", :token => 'foo' }
|
||||
get :index, params: { :format => "xml", :token => 'foo' }
|
||||
assert_response 401
|
||||
end
|
||||
|
||||
def test_xml_not_accessible_to_anonymous_user_with_valid_token
|
||||
login_as nil
|
||||
get :index, { :format => "xml", :token => users(:admin_user).token }
|
||||
get :index, params: { :format => "xml", :token => users(:admin_user).token }
|
||||
assert_response 401
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue