This repository has been archived by the owner on Nov 15, 2018. It is now read-only.
forked from spree-contrib/spree_social
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
45 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters