Added an API token for each User to use when making API requests. (#3920)

The API key will be displayed on My Account page with a link to reset or
generate a new one.  All existing users will have a token generated by the
migration.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3217 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Eric Davis
2009-12-23 06:27:28 +00:00
parent 9f59cd64ab
commit aa9951b38b
8 changed files with 162 additions and 3 deletions
+34
View File
@@ -163,4 +163,38 @@ class MyControllerTest < ActionController::TestCase
should_redirect_to('my account') {'/my/account' }
end
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
end
end