Sha256: 4986629d9e820e75c036fdebe73c454065ed90b852334658b4901a87e0c47b38

Contents?: true

Size: 1.6 KB

Versions: 15

Compression:

Stored size: 1.6 KB

Contents

shared_examples_for "oauth_controller" do
  describe "using 'create_from'" do
    before(:each) do
      stub_all_oauth_requests!
      User.delete_all
      Authentication.delete_all
    end
      
    it "should create a new user" do
      sorcery_model_property_set(:authentications_class, Authentication)
      sorcery_controller_external_property_set(:twitter, :user_info_mapping, {:username => "screen_name"})
      lambda do
        get :test_create_from_provider, :provider => "twitter"
      end.should change(User, :count).by(1)
      User.first.username.should == "nbenari"
    end
    
    it "should support nested attributes" do
      sorcery_model_property_set(:authentications_class, Authentication)
      sorcery_controller_external_property_set(:twitter, :user_info_mapping, {:username => "status/text"})
      lambda do
        get :test_create_from_provider, :provider => "twitter"
      end.should change(User, :count).by(1)
      User.first.username.should == "coming soon to sorcery gem: twitter and facebook authentication support."
    end
    
    it "should not crash on missing nested attributes" do
      sorcery_model_property_set(:authentications_class, Authentication)
      sorcery_controller_external_property_set(:twitter, :user_info_mapping, {:username => "status/text", :created_at => "does/not/exist"})
      lambda do
        get :test_create_from_provider, :provider => "twitter"
      end.should change(User, :count).by(1)
      User.first.username.should == "coming soon to sorcery gem: twitter and facebook authentication support."
      User.first.created_at.should_not be_nil
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
sorcery-0.7.12 spec/shared_examples/controller_oauth_shared_examples.rb
sorcery-0.7.11 spec/shared_examples/controller_oauth_shared_examples.rb
sorcery-0.7.10 spec/shared_examples/controller_oauth_shared_examples.rb
sorcery-0.7.9 spec/shared_examples/controller_oauth_shared_examples.rb
sorcery-0.7.8 spec/shared_examples/controller_oauth_shared_examples.rb
sorcery-0.7.7 spec/shared_examples/controller_oauth_shared_examples.rb
sorcery-0.7.6 spec/shared_examples/controller_oauth_shared_examples.rb
sorcery-0.7.5 spec/shared_examples/controller_oauth_shared_examples.rb
sorcery-0.7.4 spec/shared_examples/controller_oauth_shared_examples.rb
sorcery-0.7.3 spec/shared_examples/controller_oauth_shared_examples.rb
sorcery-0.7.2 spec/shared_examples/controller_oauth_shared_examples.rb
sorcery-0.7.1 spec/shared_examples/controller_oauth_shared_examples.rb
sorcery-0.7.0 spec/shared_examples/controller_oauth_shared_examples.rb
sorcery-0.6.1 spec/shared_examples/controller_oauth_shared_examples.rb
sorcery-0.6.0 spec/shared_examples/controller_oauth_shared_examples.rb