Sha256: 93361e791f0f9f4775c2f4ed15f126900ba9d85d8d66964b24d5529fd85e7333

Contents?: true

Size: 1.47 KB

Versions: 15

Compression:

Stored size: 1.47 KB

Contents

shared_examples_for "oauth2_controller" do
  describe "using 'create_from'" do
    before(:each) do
      stub_all_oauth2_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(:facebook, :user_info_mapping, {:username => "name"})
      lambda do
        get :test_create_from_provider, :provider => "facebook"
      end.should change(User, :count).by(1)
      User.first.username.should == "Noam Ben Ari"
    end

    it "should support nested attributes" do
      sorcery_model_property_set(:authentications_class, Authentication)
      sorcery_controller_external_property_set(:facebook, :user_info_mapping, {:username => "hometown/name"})
      lambda do
        get :test_create_from_provider, :provider => "facebook"
      end.should change(User, :count).by(1)
      User.first.username.should == "Haifa, Israel"
    end

    it "should not crash on missing nested attributes" do
      sorcery_model_property_set(:authentications_class, Authentication)
      sorcery_controller_external_property_set(:facebook, :user_info_mapping, {:username => "name", :created_at => "does/not/exist"})
      lambda do
        get :test_create_from_provider, :provider => "facebook"
      end.should change(User, :count).by(1)
      User.first.username.should == "Noam Ben Ari"
      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_oauth2_shared_examples.rb
sorcery-0.7.11 spec/shared_examples/controller_oauth2_shared_examples.rb
sorcery-0.7.10 spec/shared_examples/controller_oauth2_shared_examples.rb
sorcery-0.7.9 spec/shared_examples/controller_oauth2_shared_examples.rb
sorcery-0.7.8 spec/shared_examples/controller_oauth2_shared_examples.rb
sorcery-0.7.7 spec/shared_examples/controller_oauth2_shared_examples.rb
sorcery-0.7.6 spec/shared_examples/controller_oauth2_shared_examples.rb
sorcery-0.7.5 spec/shared_examples/controller_oauth2_shared_examples.rb
sorcery-0.7.4 spec/shared_examples/controller_oauth2_shared_examples.rb
sorcery-0.7.3 spec/shared_examples/controller_oauth2_shared_examples.rb
sorcery-0.7.2 spec/shared_examples/controller_oauth2_shared_examples.rb
sorcery-0.7.1 spec/shared_examples/controller_oauth2_shared_examples.rb
sorcery-0.7.0 spec/shared_examples/controller_oauth2_shared_examples.rb
sorcery-0.6.1 spec/shared_examples/controller_oauth2_shared_examples.rb
sorcery-0.6.0 spec/shared_examples/controller_oauth2_shared_examples.rb