From 50c8638f95584dbd863de6da042755ea400ee40b Mon Sep 17 00:00:00 2001 From: Aaron Peckham Date: Tue, 7 May 2013 21:27:46 -0700 Subject: add test for redirecting to first dashboard, and returning a 404 if dashboard doesn't exist --- test/app_test.rb | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'test') diff --git a/test/app_test.rb b/test/app_test.rb index 445c538..f6fa537 100644 --- a/test/app_test.rb +++ b/test/app_test.rb @@ -6,13 +6,7 @@ class AppTest < Dashing::Test @connection = [] Sinatra::Application.settings.connections = [@connection] Sinatra::Application.settings.auth_token = nil - end - - def test_redirect_to_default_dashboard - Sinatra::Application.settings.default_dashboard = 'test1' - get '/' - assert_equal 302, last_response.status - assert_equal 'http://example.org/test1', last_response.location + Sinatra::Application.settings.default_dashboard = nil end def test_post_widgets_without_auth_token @@ -46,6 +40,23 @@ class AppTest < Dashing::Test assert_equal 200, last_response.status assert_equal 8, parse_data(@connection[0])['value'] end + + def test_redirect_to_default_dashboard + with_generated_project do + Sinatra::Application.settings.default_dashboard = 'test1' + get '/' + assert_equal 302, last_response.status + assert_equal 'http://example.org/test1', last_response.location + end + end + + def test_redirect_to_first_dashboard + with_generated_project do + get '/' + assert_equal 302, last_response.status + assert_equal 'http://example.org/sample', last_response.location + end + end def test_get_dashboard with_generated_project do @@ -54,6 +65,13 @@ class AppTest < Dashing::Test assert_include last_response.body, 'class="gridster"' end end + + def test_get_nonexistent_dashboard + with_generated_project do + get '/nodashboard' + assert_equal 404, last_response.status + end + end def test_get_widget with_generated_project do -- cgit v1.2.3