diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-01-01 21:09:33 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-01-01 21:09:33 +0000 |
commit | be5169249a9af3104a3672984eb38c0b915dd4f5 (patch) | |
tree | f5a16971ba09ffb7fa9de49f23c336631c84253a /test/functional/my_controller_test.rb | |
parent | 8364f86af18691f44a84c70504f4bf44dd93bdab (diff) | |
download | redmine-be5169249a9af3104a3672984eb38c0b915dd4f5.tar.gz redmine-be5169249a9af3104a3672984eb38c0b915dd4f5.zip |
Test cleanup.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8465 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/functional/my_controller_test.rb')
-rw-r--r-- | test/functional/my_controller_test.rb | 98 |
1 files changed, 34 insertions, 64 deletions
diff --git a/test/functional/my_controller_test.rb b/test/functional/my_controller_test.rb index ff509674b..cac6a14ad 100644 --- a/test/functional/my_controller_test.rb +++ b/test/functional/my_controller_test.rb @@ -137,71 +137,41 @@ class MyControllerTest < ActionController::TestCase assert_equal ['documents', 'calendar', 'latestnews'], User.find(2).pref[:my_page_layout]['left'] end - context "POST to reset_rss_key" do - context "with an existing rss_token" do - setup do - @previous_token_value = User.find(2).rss_key # Will generate one if it's missing - post :reset_rss_key - end - - should "destroy the existing token" do - assert_not_equal @previous_token_value, User.find(2).rss_key - end - - should "create a new token" do - assert User.find(2).rss_token - end - - should_set_the_flash_to /reset/ - should_redirect_to('my account') {'/my/account' } - end - - context "with no rss_token" do - setup do - assert_nil User.find(2).rss_token - post :reset_rss_key - end - - should "create a new token" do - assert User.find(2).rss_token - end - - should_set_the_flash_to /reset/ - should_redirect_to('my account') {'/my/account' } - end + def test_reset_rss_key_with_existing_key + @previous_token_value = User.find(2).rss_key # Will generate one if it's missing + post :reset_rss_key + + assert_not_equal @previous_token_value, User.find(2).rss_key + assert User.find(2).rss_token + assert_match /reset/, flash[:notice] + assert_redirected_to '/my/account' + end + + def test_reset_rss_key_without_existing_key + assert_nil User.find(2).rss_token + post :reset_rss_key + + assert User.find(2).rss_token + assert_match /reset/, flash[:notice] + assert_redirected_to '/my/account' end - context "POST to reset_api_key" do - context "with an existing api_token" do - setup do - @previous_token_value = User.find(2).api_key # Will generate one if it's missing - post :reset_api_key - end - - should "destroy the existing token" do - assert_not_equal @previous_token_value, User.find(2).api_key - end - - should "create a new token" do - assert User.find(2).api_token - end - - should_set_the_flash_to /reset/ - should_redirect_to('my account') {'/my/account' } - end - - context "with no api_token" do - setup do - assert_nil User.find(2).api_token - post :reset_api_key - end - - should "create a new token" do - assert User.find(2).api_token - end - - should_set_the_flash_to /reset/ - should_redirect_to('my account') {'/my/account' } - end + def test_reset_api_key_with_existing_key + @previous_token_value = User.find(2).api_key # Will generate one if it's missing + post :reset_api_key + + assert_not_equal @previous_token_value, User.find(2).api_key + assert User.find(2).api_token + assert_match /reset/, flash[:notice] + assert_redirected_to '/my/account' + end + + def test_reset_api_key_without_existing_key + assert_nil User.find(2).api_token + post :reset_api_key + + assert User.find(2).api_token + assert_match /reset/, flash[:notice] + assert_redirected_to '/my/account' end end |