oauthable.rb 835 B

1234567891011121314151617181920212223242526272829
  1. require 'spec_helper'
  2. module Agents
  3. class OauthableTestAgent < Agent
  4. include Oauthable
  5. end
  6. end
  7. shared_examples_for Oauthable do
  8. before(:each) do
  9. @agent = described_class.new(:name => "somename")
  10. @agent.user = users(:jane)
  11. end
  12. it "should be oauthable" do
  13. @agent.oauthable?.should == true
  14. end
  15. describe "valid_services_for" do
  16. it "should return all available services without specifying valid_oauth_providers" do
  17. @agent = Agents::OauthableTestAgent.new
  18. @agent.valid_services_for(users(:bob)).collect(&:id).sort.should == [services(:generic), services(:global)].collect(&:id).sort
  19. end
  20. it "should filter the services based on the agent defaults" do
  21. @agent.valid_services_for(users(:bob)).to_a.should == Service.where(provider: @agent.valid_oauth_providers)
  22. end
  23. end
  24. end