Sha256: dcc207f4d2b9282707c5bab58131bac4554e19a4910a9c08dee2f65c45866764

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

require 'spec_helper'

describe Spree::User do
  let(:user) { Factory(:user) }
  let(:omni_params) { {"provider" => "twitter", "uid" => 12345} }
  let(:auths) { mock "auths" }

  context "#apply_omniauth" do
    before { user.stub :user_authentications => auths }

    it "should build an associated auth source" do
      auths.should_receive(:build)
      user.apply_omniauth(omni_params)
    end
  end

  context "#password_required?" do
    before { user.password = nil }

    context "user authentications is empty" do
      it "should be true" do
        user.password_required?.should be_true
      end
    end

    context "user authentications is not empty" do
      before do
        user.stub :user_authentications => auths
        auths.stub(:empty?).and_return(false)
      end

      it "should be false" do
        user.password_required?.should be_false
      end
    end

    context "when the password has been set" do
      before { user.password = "foobar" }

      it "should be true" do
        user.password_required?.should be_true
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spree_social_onr-2.1.4 spec/models/spree/user_decorator_spec.rb