/oauth_plugin/generators/oauth_provider/templates/oauth_token_spec.rb

http://oauth-plugin.googlecode.com/ · Ruby · 55 lines · 43 code · 12 blank · 0 comment · 0 complexity · 9597f8843efb6abbc6ae6dc64e1e63f7 MD5 · raw file

  1. require File.dirname(__FILE__) + '/../spec_helper'
  2. describe RequestToken do
  3. fixtures :client_applications,:users,:oauth_tokens
  4. before(:each) do
  5. @token = RequestToken.create :client_application=>client_applications(:one)
  6. end
  7. it "should be valid" do
  8. @token.should be_valid
  9. end
  10. it "should not have errors" do
  11. @token.errors.should_not==[]
  12. end
  13. it "should have a token" do
  14. @token.token.should_not be_nil
  15. end
  16. it "should have a secret" do
  17. @token.secret.should_not be_nil
  18. end
  19. it "should not be authorized" do
  20. @token.should_not be_authorized
  21. end
  22. it "should not be invalidated" do
  23. @token.should_not be_invalidated
  24. end
  25. it "should authorize request" do
  26. @token.authorize!(users(:quentin))
  27. @token.should be_authorized
  28. @token.authorized_at.should_not be_nil
  29. @token.user.should==users(:quentin)
  30. end
  31. it "should not exchange without approval" do
  32. @token.exchange!.should==false
  33. @token.should_not be_invalidated
  34. end
  35. it "should not exchange without approval" do
  36. @token.authorize!(users(:quentin))
  37. @access=@token.exchange!
  38. @access.should_not==false
  39. @token.should be_invalidated
  40. @access.user.should==users(:quentin)
  41. @access.should be_authorized
  42. end
  43. end