oauthable.rb 871 B

1234567891011121314151617181920212223242526272829
  1. require 'rails_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. expect(@agent.oauthable?).to eq(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. expect(@agent.valid_services_for(users(:bob)).collect(&:id).sort).to eq([services(:generic), services(:twitter), services(:global)].collect(&:id).sort)
  19. end
  20. it "should filter the services based on the agent defaults" do
  21. expect(@agent.valid_services_for(users(:bob)).to_a).to eq(Service.where(provider: @agent.valid_oauth_providers))
  22. end
  23. end
  24. end