X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/2ad330d642df0048686f63dc7e86a7dbeb0b30e4..b8f6dbd403507edd14f04f3151c285e232607360:/vendor/plugins/oauth-plugin/generators/oauth_provider/templates/oauth_token_spec.rb diff --git a/vendor/plugins/oauth-plugin/generators/oauth_provider/templates/oauth_token_spec.rb b/vendor/plugins/oauth-plugin/generators/oauth_provider/templates/oauth_token_spec.rb new file mode 100644 index 000000000..594c204af --- /dev/null +++ b/vendor/plugins/oauth-plugin/generators/oauth_provider/templates/oauth_token_spec.rb @@ -0,0 +1,55 @@ +require File.dirname(__FILE__) + '/../spec_helper' + +describe RequestToken do + fixtures :client_applications, :users, :oauth_tokens + before(:each) do + @token = RequestToken.create :client_application => client_applications(:one) + end + + it "should be valid" do + @token.should be_valid + end + + it "should not have errors" do + @token.errors.should_not == [] + end + + it "should have a token" do + @token.token.should_not be_nil + end + + it "should have a secret" do + @token.secret.should_not be_nil + end + + it "should not be authorized" do + @token.should_not be_authorized + end + + it "should not be invalidated" do + @token.should_not be_invalidated + end + + it "should authorize request" do + @token.authorize!(users(:quentin)) + @token.should be_authorized + @token.authorized_at.should_not be_nil + @token.user.should == users(:quentin) + end + + it "should not exchange without approval" do + @token.exchange!.should == false + @token.should_not be_invalidated + end + + it "should not exchange without approval" do + @token.authorize!(users(:quentin)) + @access = @token.exchange! + @access.should_not == false + @token.should be_invalidated + + @access.user.should == users(:quentin) + @access.should be_authorized + end + +end