mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-22 10:10:12 +01:00
get project integrations and login controller tests running
This commit is contained in:
parent
59a4d5ede0
commit
96db48dd86
36 changed files with 179 additions and 223 deletions
|
|
@ -1,15 +1,8 @@
|
|||
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
||||
require File.expand_path(File.dirname(__FILE__) + '/todo_container_controller_test_base')
|
||||
require 'projects_controller'
|
||||
|
||||
# Re-raise errors caught by the controller.
|
||||
class ProjectsController; def rescue_action(e) raise e end; end
|
||||
|
||||
class ProjectsControllerTest < TodoContainerControllerTestBase
|
||||
fixtures :users, :todos, :preferences, :projects, :contexts, :recurring_todos
|
||||
class ProjectsControllerTest < ActionController::TestCase
|
||||
|
||||
def setup
|
||||
perform_setup(Project, ProjectsController)
|
||||
end
|
||||
|
||||
def test_projects_list
|
||||
|
|
@ -23,35 +16,32 @@ class ProjectsControllerTest < TodoContainerControllerTestBase
|
|||
get :show, :id => p.to_param
|
||||
assert_not_nil assigns['deferred']
|
||||
assert_equal 1, assigns['deferred'].size
|
||||
|
||||
|
||||
t = p.todos.not_completed[0]
|
||||
t.show_from = 1.days.from_now.utc
|
||||
t.save!
|
||||
|
||||
|
||||
get :show, :id => p.to_param
|
||||
assert_equal 2, assigns['deferred'].size
|
||||
end
|
||||
|
||||
|
||||
def test_show_exposes_next_project_in_same_state
|
||||
login_as :admin_user
|
||||
get :show, :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
|
||||
assert_equal(projects(:timemachine), assigns['previous_project'])
|
||||
end
|
||||
|
||||
|
||||
def test_create_project_via_ajax_increments_number_of_projects
|
||||
login_as :other_user
|
||||
assert_ajax_create_increments_count 'My New Project'
|
||||
end
|
||||
|
||||
def test_create_with_comma_in_name_increments_number_of_projects
|
||||
assert_ajax_create_increments_count 'foo,bar'
|
||||
end
|
||||
|
||||
|
||||
def test_todo_state_is_project_hidden_after_hiding_project
|
||||
p = projects(:timemachine)
|
||||
todos = p.todos.find_in_state(:all, :active)
|
||||
|
|
@ -75,12 +65,14 @@ class ProjectsControllerTest < TodoContainerControllerTestBase
|
|||
assert p.reload().active?
|
||||
end
|
||||
|
||||
# RSS
|
||||
|
||||
def test_rss_feed_content
|
||||
login_as(:admin_user)
|
||||
get :index, { :format => "rss" }
|
||||
assert_equal 'application/rss+xml', @response.content_type
|
||||
#puts @response.body
|
||||
|
||||
|
||||
assert_xml_select 'rss[version="2.0"]' do
|
||||
assert_select 'channel' do
|
||||
assert_select '>title', 'Tracks Projects'
|
||||
|
|
@ -102,7 +94,7 @@ class ProjectsControllerTest < TodoContainerControllerTestBase
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def test_rss_feed_not_accessible_to_anonymous_user_without_token
|
||||
login_as nil
|
||||
get :index, { :format => "rss" }
|
||||
|
|
@ -125,8 +117,8 @@ class ProjectsControllerTest < TodoContainerControllerTestBase
|
|||
login_as :admin_user
|
||||
get :index, { :format => "atom" }
|
||||
assert_equal 'application/atom+xml', @response.content_type
|
||||
#puts @response.body
|
||||
|
||||
# puts @response.body
|
||||
|
||||
assert_xml_select 'feed[xmlns="http://www.w3.org/2005/Atom"]' do
|
||||
assert_select '>title', 'Tracks Projects'
|
||||
assert_select '>subtitle', "Lists all the projects for #{users(:admin_user).display_name}"
|
||||
|
|
@ -159,7 +151,7 @@ class ProjectsControllerTest < TodoContainerControllerTestBase
|
|||
get :index, { :format => "atom", :token => users(:admin_user).token }
|
||||
assert_response :ok
|
||||
end
|
||||
|
||||
|
||||
def test_text_feed_content
|
||||
login_as :admin_user
|
||||
get :index, { :format => "txt" }
|
||||
|
|
@ -171,10 +163,10 @@ class ProjectsControllerTest < TodoContainerControllerTestBase
|
|||
login_as :admin_user
|
||||
p = projects(:timemachine)
|
||||
p.todos.each { |t| t.destroy }
|
||||
|
||||
|
||||
get :index, { :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))
|
||||
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
|
||||
|
|
@ -194,12 +186,12 @@ class ProjectsControllerTest < TodoContainerControllerTestBase
|
|||
get :index, { :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'
|
||||
|
||||
|
||||
assert_equal 1, projects(:gardenclean).position
|
||||
assert_equal 2, projects(:moremoney).position
|
||||
assert_equal 3, projects(:timemachine).position
|
||||
|
|
@ -211,15 +203,15 @@ class ProjectsControllerTest < TodoContainerControllerTestBase
|
|||
post :alphabetize, :state => "active", :format => 'js'
|
||||
assert_equal 1, projects(:timemachine).position
|
||||
assert_equal 2, projects(:gardenclean).position
|
||||
assert_equal 3, projects(:moremoney).position
|
||||
assert_equal 3, projects(:moremoney).position
|
||||
end
|
||||
|
||||
|
||||
def test_alphabetize_assigns_state
|
||||
login_as :admin_user
|
||||
post :alphabetize, :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'
|
||||
|
|
@ -230,7 +222,4 @@ class ProjectsControllerTest < TodoContainerControllerTestBase
|
|||
assert_equal projects(:moremoney), exposed_projects[2]
|
||||
end
|
||||
|
||||
def protect_against_forgery?
|
||||
false
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue